LLVM 24.0.0git
InstCombineSimplifyDemanded.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "instcombine"

Functions

static bool ShrinkDemandedConstant (Instruction *I, unsigned OpNo, const APInt &Demanded)
 Check to see if the specified operand of the specified instruction is a constant integer.
static Value * simplifyShiftSelectingPackedElement (Instruction *I, const APInt &DemandedMask, InstCombinerImpl &IC, unsigned Depth)
 Let N = 2 * M.
static unsigned getBitWidth (Type *Ty, const DataLayout &DL)
 Returns the bitwidth of the given scalar or pointer type.
static bool canSkipDemandedEltsInInsertChain (InsertElementInst &IE, unsigned VWidth, unsigned DepthLimit)
 Return true if the top-level all-lanes demanded-elements query can be skipped for an intermediate insertelement chain node.
static Constant * getFPClassConstant (Type *Ty, FPClassTest Mask, bool IsCanonicalizing=false)
 For floating-point classes that resolve to a single bit pattern, return that value.
static Value * simplifyDemandedFPClassFabs (KnownFPClass &Known, Value *Src, FPClassTest DemandedMask, KnownFPClass KnownSrc, bool NSZ)
 Perform multiple-use aware simplfications for fabs(Src).
static FastMathFlags inferFastMathValueFlags (FastMathFlags FMF, FPClassTest ValidResults, ArrayRef< KnownFPClass > Known)
 Try to set an inferred no-nans or no-infs in FMF.
static FPClassTest adjustDemandedMaskFromFlags (FPClassTest DemandedMask, FastMathFlags FMF)
static Value * simplifyDemandedFPClassResult (Instruction *FPOp, FastMathFlags FMF, FPClassTest DemandedMask, KnownFPClass &Known, ArrayRef< KnownFPClass > KnownSrcs)
 Apply epilog fixups to a floating-point intrinsic.
static Value * simplifyDemandedFPClassFnegFabs (KnownFPClass &Known, Value *Src, FPClassTest DemandedMask, KnownFPClass KnownSrc, bool NSZ)
 Perform multiple-use aware simplfications for fneg(fabs(Src)).
static Value * simplifyDemandedFPClassCopysignMag (Value *MagSrc, FPClassTest DemandedMask, KnownFPClass KnownSrc, bool NSZ)
static Value * simplifyDemandedFPClassMinMax (KnownFPClass &Known, Intrinsic::ID IID, const CallInst *CI, FPClassTest DemandedMask, KnownFPClass KnownLHS, KnownFPClass KnownRHS, const Function &F, bool NSZ)
static Value * simplifyDemandedUseFPClassFPTrunc (InstCombinerImpl &IC, Instruction &I, FastMathFlags FMF, FPClassTest DemandedMask, KnownFPClass &Known, const SimplifyQuery &SQ, unsigned Depth)

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "instcombine"

Definition at line 26 of file InstCombineSimplifyDemanded.cpp.

Function Documentation

◆ adjustDemandedMaskFromFlags()

◆ canSkipDemandedEltsInInsertChain()

bool canSkipDemandedEltsInInsertChain ( InsertElementInst & IE,
unsigned VWidth,
unsigned DepthLimit )
static

Return true if the top-level all-lanes demanded-elements query can be skipped for an intermediate insertelement chain node.

This is limited to a bounded one-use chain with distinct in-range constant indices, where SDVE cannot remove a dead insert before hitting its depth limit.

Definition at line 1458 of file InstCombineSimplifyDemanded.cpp.

References llvm::sampleprof::Base, llvm::dyn_cast(), I, llvm::PatternMatch::m_Poison(), llvm::PatternMatch::match(), llvm::SmallBitVector::set(), and llvm::SmallBitVector::test().

Referenced by llvm::InstCombinerImpl::SimplifyDemandedVectorElts().

◆ getBitWidth()

unsigned getBitWidth ( Type * Ty,
const DataLayout & DL )
static

Returns the bitwidth of the given scalar or pointer type.

For vector types, returns the element type's bitwidth.

Definition at line 111 of file InstCombineSimplifyDemanded.cpp.

References llvm::BitWidth, and DL.

◆ getFPClassConstant()

◆ inferFastMathValueFlags()

FastMathFlags inferFastMathValueFlags ( FastMathFlags FMF,
FPClassTest ValidResults,
ArrayRef< KnownFPClass > Known )
static

Try to set an inferred no-nans or no-infs in FMF.

ValidResults is a mask of known valid results for the operator (already computed from the result, and the known operand inputs in Known)

Definition at line 2147 of file InstCombineSimplifyDemanded.cpp.

References llvm::all_of(), llvm::fcInf, llvm::fcNan, llvm::fcNone, llvm::KnownFPClass::isKnownNeverInfinity(), llvm::KnownFPClass::isKnownNeverNaN(), llvm::Known, llvm::FastMathFlags::noInfs(), llvm::FastMathFlags::noNaNs(), llvm::FastMathFlags::setNoInfs(), and llvm::FastMathFlags::setNoNaNs().

Referenced by simplifyDemandedFPClassResult(), and llvm::InstCombinerImpl::SimplifyDemandedUseFPClass().

◆ ShrinkDemandedConstant()

bool ShrinkDemandedConstant ( Instruction * I,
unsigned OpNo,
const APInt & Demanded )
static

Check to see if the specified operand of the specified instruction is a constant integer.

If so, check to see if there are any bits set in the constant that are not demanded. If so, shrink the constant and return true.

Definition at line 31 of file InstCombineSimplifyDemanded.cpp.

References assert(), C(), I, llvm::PatternMatch::m_APInt(), and llvm::PatternMatch::match().

Referenced by llvm::TargetLowering::ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), and llvm::InstCombinerImpl::SimplifyDemandedUseBits().

◆ simplifyDemandedFPClassCopysignMag()

◆ simplifyDemandedFPClassFabs()

Value * simplifyDemandedFPClassFabs ( KnownFPClass & Known,
Value * Src,
FPClassTest DemandedMask,
KnownFPClass KnownSrc,
bool NSZ )
static

Perform multiple-use aware simplfications for fabs(Src).

Returns a replacement value if it's simplified, otherwise nullptr. Updates Known with the known fpclass if not simplified.

Definition at line 2122 of file InstCombineSimplifyDemanded.cpp.

References llvm::KnownFPClass::fabs(), llvm::fcInf, llvm::fcNan, llvm::fcNegative, llvm::fcNone, llvm::KnownFPClass::getSignBit(), llvm::KnownFPClass::isKnownNever(), llvm::Known, llvm::KnownFPClass::knownNot(), and llvm::KnownFPClass::OrderedLessThanZeroMask.

Referenced by llvm::InstCombinerImpl::SimplifyDemandedUseFPClass(), and llvm::InstCombinerImpl::SimplifyMultipleUseDemandedFPClass().

◆ simplifyDemandedFPClassFnegFabs()

Value * simplifyDemandedFPClassFnegFabs ( KnownFPClass & Known,
Value * Src,
FPClassTest DemandedMask,
KnownFPClass KnownSrc,
bool NSZ )
static

Perform multiple-use aware simplfications for fneg(fabs(Src)).

Returns a replacement value if it's simplified, otherwise nullptr. Updates Known with the known fpclass if not simplified.

Definition at line 2204 of file InstCombineSimplifyDemanded.cpp.

References llvm::KnownFPClass::fabs(), llvm::fcInf, llvm::fcNan, llvm::fcNone, llvm::KnownFPClass::fneg(), llvm::KnownFPClass::getSignBit(), llvm::KnownFPClass::isKnownNever(), llvm::Known, llvm::KnownFPClass::knownNot(), and llvm::KnownFPClass::OrderedGreaterThanZeroMask.

Referenced by llvm::InstCombinerImpl::SimplifyDemandedUseFPClass(), and llvm::InstCombinerImpl::SimplifyMultipleUseDemandedFPClass().

◆ simplifyDemandedFPClassMinMax()

◆ simplifyDemandedFPClassResult()

Value * simplifyDemandedFPClassResult ( Instruction * FPOp,
FastMathFlags FMF,
FPClassTest DemandedMask,
KnownFPClass & Known,
ArrayRef< KnownFPClass > KnownSrcs )
static

Apply epilog fixups to a floating-point intrinsic.

See if the result can fold to a constant, or apply fast math flags.

Definition at line 2179 of file InstCombineSimplifyDemanded.cpp.

References llvm::Instruction::dropUBImplyingAttrsAndMetadata(), getFPClassConstant(), llvm::Value::getType(), inferFastMathValueFlags(), llvm::Known, and llvm::Instruction::setFastMathFlags().

Referenced by llvm::InstCombinerImpl::SimplifyDemandedUseFPClass(), and simplifyDemandedUseFPClassFPTrunc().

◆ simplifyDemandedUseFPClassFPTrunc()

◆ simplifyShiftSelectingPackedElement()

Value * simplifyShiftSelectingPackedElement ( Instruction * I,
const APInt & DemandedMask,
InstCombinerImpl & IC,
unsigned Depth )
static