LLVM  14.0.0git
Public Member Functions | List of all members
llvm::InstCombinerImpl Class Referencefinal

#include "Transforms/InstCombine/InstCombineInternal.h"

Inheritance diagram for llvm::InstCombinerImpl:
Inheritance graph
[legend]
Collaboration diagram for llvm::InstCombinerImpl:
Collaboration graph
[legend]

Public Member Functions

 InstCombinerImpl (InstructionWorklist &Worklist, BuilderTy &Builder, bool MinimizeSize, AAResults *AA, AssumptionCache &AC, TargetLibraryInfo &TLI, TargetTransformInfo &TTI, DominatorTree &DT, OptimizationRemarkEmitter &ORE, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI, const DataLayout &DL, LoopInfo *LI)
 
virtual ~InstCombinerImpl ()
 
bool run ()
 Run the combiner over the entire worklist until it is empty. More...
 
InstructionvisitFNeg (UnaryOperator &I)
 
InstructionvisitAdd (BinaryOperator &I)
 
InstructionvisitFAdd (BinaryOperator &I)
 
ValueOptimizePointerDifference (Value *LHS, Value *RHS, Type *Ty, bool isNUW)
 Optimize pointer differences into the same array into a size. More...
 
InstructionvisitSub (BinaryOperator &I)
 
InstructionvisitFSub (BinaryOperator &I)
 
InstructionvisitMul (BinaryOperator &I)
 
InstructionvisitFMul (BinaryOperator &I)
 
InstructionvisitURem (BinaryOperator &I)
 
InstructionvisitSRem (BinaryOperator &I)
 
InstructionvisitFRem (BinaryOperator &I)
 
bool simplifyDivRemOfSelectWithZeroOp (BinaryOperator &I)
 Fold a divide or remainder with a select instruction divisor when one of the select operands is zero. More...
 
InstructioncommonIRemTransforms (BinaryOperator &I)
 This function implements the transforms common to both integer remainder instructions (urem and srem). More...
 
InstructioncommonIDivTransforms (BinaryOperator &I)
 This function implements the transforms common to both integer division instructions (udiv and sdiv). More...
 
InstructionvisitUDiv (BinaryOperator &I)
 
InstructionvisitSDiv (BinaryOperator &I)
 
InstructionvisitFDiv (BinaryOperator &I)
 
ValuesimplifyRangeCheck (ICmpInst *Cmp0, ICmpInst *Cmp1, bool Inverted)
 Try to fold a signed range checked with lower bound 0 to an unsigned icmp. More...
 
InstructionvisitAnd (BinaryOperator &I)
 
InstructionvisitOr (BinaryOperator &I)
 
bool sinkNotIntoOtherHandOfAndOrOr (BinaryOperator &I)
 
InstructionvisitXor (BinaryOperator &I)
 
InstructionvisitShl (BinaryOperator &I)
 
ValuereassociateShiftAmtsOfTwoSameDirectionShifts (BinaryOperator *Sh0, const SimplifyQuery &SQ, bool AnalyzeForSignBitExtraction=false)
 
InstructioncanonicalizeCondSignextOfHighBitExtractToSignextHighBitExtract (BinaryOperator &I)
 
InstructionfoldVariableSignZeroExtensionOfVariableHighBitExtract (BinaryOperator &OldAShr)
 
InstructionvisitAShr (BinaryOperator &I)
 
InstructionvisitLShr (BinaryOperator &I)
 
InstructioncommonShiftTransforms (BinaryOperator &I)
 
InstructionvisitFCmpInst (FCmpInst &I)
 
CmpInstcanonicalizeICmpPredicate (CmpInst &I)
 If we have a comparison with a non-canonical predicate, if we can update all the users, invert the predicate and adjust all the users. More...
 
InstructionvisitICmpInst (ICmpInst &I)
 
InstructionFoldShiftByConstant (Value *Op0, Constant *Op1, BinaryOperator &I)
 
InstructioncommonCastTransforms (CastInst &CI)
 Implement the transforms common to all CastInst visitors. More...
 
InstructioncommonPointerCastTransforms (CastInst &CI)
 Implement the transforms for cast of pointer (bitcast/ptrtoint) More...
 
InstructionvisitTrunc (TruncInst &CI)
 
InstructionvisitZExt (ZExtInst &CI)
 
InstructionvisitSExt (SExtInst &CI)
 
InstructionvisitFPTrunc (FPTruncInst &CI)
 
InstructionvisitFPExt (CastInst &CI)
 
InstructionvisitFPToUI (FPToUIInst &FI)
 
InstructionvisitFPToSI (FPToSIInst &FI)
 
InstructionvisitUIToFP (CastInst &CI)
 
InstructionvisitSIToFP (CastInst &CI)
 
InstructionvisitPtrToInt (PtrToIntInst &CI)
 
InstructionvisitIntToPtr (IntToPtrInst &CI)
 
InstructionvisitBitCast (BitCastInst &CI)
 
InstructionvisitAddrSpaceCast (AddrSpaceCastInst &CI)
 
InstructionfoldItoFPtoI (CastInst &FI)
 fpto{s/u}i({u/s}itofp(X)) --> X or zext(X) or sext(X) or trunc(X) This is safe if the intermediate type has enough bits in its mantissa to accurately represent all values of X. More...
 
InstructionvisitSelectInst (SelectInst &SI)
 
InstructionvisitCallInst (CallInst &CI)
 CallInst simplification. More...
 
InstructionvisitInvokeInst (InvokeInst &II)
 
InstructionvisitCallBrInst (CallBrInst &CBI)
 
InstructionSliceUpIllegalIntegerPHI (PHINode &PN)
 This is an integer PHI and we know that it has an illegal type: see if it is only used by trunc or trunc(lshr) operations. More...
 
InstructionvisitPHINode (PHINode &PN)
 
InstructionvisitGetElementPtrInst (GetElementPtrInst &GEP)
 
InstructionvisitAllocaInst (AllocaInst &AI)
 
InstructionvisitAllocSite (Instruction &FI)
 
InstructionvisitFree (CallInst &FI)
 
InstructionvisitLoadInst (LoadInst &LI)
 
InstructionvisitStoreInst (StoreInst &SI)
 
InstructionvisitAtomicRMWInst (AtomicRMWInst &SI)
 
InstructionvisitUnconditionalBranchInst (BranchInst &BI)
 
InstructionvisitBranchInst (BranchInst &BI)
 
InstructionvisitFenceInst (FenceInst &FI)
 
InstructionvisitSwitchInst (SwitchInst &SI)
 
InstructionvisitReturnInst (ReturnInst &RI)
 
InstructionvisitUnreachableInst (UnreachableInst &I)
 
InstructionfoldAggregateConstructionIntoAggregateReuse (InsertValueInst &OrigIVI)
 Look for chain of insertvalue's that fully define an aggregate, and trace back the values inserted, see if they are all were extractvalue'd from the same source aggregate from the exact same element indexes. More...
 
InstructionvisitInsertValueInst (InsertValueInst &IV)
 Try to find redundant insertvalue instructions, like the following ones: %0 = insertvalue { i8, i32 } undef, i8 x, 0 %1 = insertvalue { i8, i32 } %0, i8 y, 0 Here the second instruction inserts values at the same indices, as the first one, making the first one redundant. More...
 
InstructionvisitInsertElementInst (InsertElementInst &IE)
 
InstructionvisitExtractElementInst (ExtractElementInst &EI)
 
InstructionvisitShuffleVectorInst (ShuffleVectorInst &SVI)
 
InstructionvisitExtractValueInst (ExtractValueInst &EV)
 
InstructionvisitLandingPadInst (LandingPadInst &LI)
 
InstructionvisitVAEndInst (VAEndInst &I)
 
ValuepushFreezeToPreventPoisonFromPropagating (FreezeInst &FI)
 
bool freezeDominatedUses (FreezeInst &FI)
 
InstructionvisitFreeze (FreezeInst &I)
 
InstructionvisitInstruction (Instruction &I)
 Specify what to return for unhandled instructions. More...
 
bool dominatesAllUses (const Instruction *DI, const Instruction *UI, const BasicBlock *DB) const
 True when DB dominates all uses of DI except UI. More...
 
bool replacedSelectWithOperand (SelectInst *SI, const ICmpInst *Icmp, const unsigned SIOpd)
 Try to replace select with select operand SIOpd in SI-ICmp sequence. More...
 
LoadInstcombineLoadToNewType (LoadInst &LI, Type *NewTy, const Twine &Suffix="")
 Helper to combine a load to a new type. More...
 
InstructionInsertNewInstBefore (Instruction *New, Instruction &Old)
 Inserts an instruction New before instruction Old. More...
 
InstructionInsertNewInstWith (Instruction *New, Instruction &Old)
 Same as InsertNewInstBefore, but also sets the debug loc. More...
 
InstructionreplaceInstUsesWith (Instruction &I, Value *V)
 A combiner-aware RAUW-like routine. More...
 
InstructionreplaceOperand (Instruction &I, unsigned OpNum, Value *V)
 Replace operand of instruction and add old operand to the worklist. More...
 
void replaceUse (Use &U, Value *NewValue)
 Replace use and add the previously used value to the worklist. More...
 
void CreateNonTerminatorUnreachable (Instruction *InsertAt)
 Create and insert the idiom we use to indicate a block is unreachable without having to rewrite the CFG from within InstCombine. More...
 
InstructioneraseInstFromFunction (Instruction &I) override
 Combiner aware instruction erasure. More...
 
void computeKnownBits (const Value *V, KnownBits &Known, unsigned Depth, const Instruction *CxtI) const
 
KnownBits computeKnownBits (const Value *V, unsigned Depth, const Instruction *CxtI) const
 
bool isKnownToBeAPowerOfTwo (const Value *V, bool OrZero=false, unsigned Depth=0, const Instruction *CxtI=nullptr)
 
bool MaskedValueIsZero (const Value *V, const APInt &Mask, unsigned Depth=0, const Instruction *CxtI=nullptr) const
 
unsigned ComputeNumSignBits (const Value *Op, unsigned Depth=0, const Instruction *CxtI=nullptr) const
 
OverflowResult computeOverflowForUnsignedMul (const Value *LHS, const Value *RHS, const Instruction *CxtI) const
 
OverflowResult computeOverflowForSignedMul (const Value *LHS, const Value *RHS, const Instruction *CxtI) const
 
OverflowResult computeOverflowForUnsignedAdd (const Value *LHS, const Value *RHS, const Instruction *CxtI) const
 
OverflowResult computeOverflowForSignedAdd (const Value *LHS, const Value *RHS, const Instruction *CxtI) const
 
OverflowResult computeOverflowForUnsignedSub (const Value *LHS, const Value *RHS, const Instruction *CxtI) const
 
OverflowResult computeOverflowForSignedSub (const Value *LHS, const Value *RHS, const Instruction *CxtI) const
 
OverflowResult computeOverflow (Instruction::BinaryOps BinaryOp, bool IsSigned, Value *LHS, Value *RHS, Instruction *CxtI) const
 
bool SimplifyAssociativeOrCommutative (BinaryOperator &I)
 Performs a few simplifications for operators which are associative or commutative. More...
 
ValueSimplifyUsingDistributiveLaws (BinaryOperator &I)
 Tries to simplify binary operations which some other binary operation distributes over. More...
 
ValueSimplifyAddWithRemainder (BinaryOperator &I)
 Tries to simplify add operations using the definition of remainder. More...
 
ValueSimplifySelectsFeedingBinaryOp (BinaryOperator &I, Value *LHS, Value *RHS)
 
ValuetryFactorization (BinaryOperator &, Instruction::BinaryOps, Value *, Value *, Value *, Value *)
 This tries to simplify binary operations by factorizing out common terms (e. More...
 
bool matchThreeWayIntCompare (SelectInst *SI, Value *&LHS, Value *&RHS, ConstantInt *&Less, ConstantInt *&Equal, ConstantInt *&Greater)
 Match a select chain which produces one of three values based on whether the LHS is less than, equal to, or greater than RHS respectively. More...
 
ValueSimplifyDemandedUseBits (Value *V, APInt DemandedMask, KnownBits &Known, unsigned Depth, Instruction *CxtI)
 Attempts to replace V with a simpler value based on the demanded bits. More...
 
bool SimplifyDemandedBits (Instruction *I, unsigned Op, const APInt &DemandedMask, KnownBits &Known, unsigned Depth=0) override
 This form of SimplifyDemandedBits simplifies the specified instruction operand if possible, updating it in place. More...
 
ValueSimplifyMultipleUseDemandedBits (Instruction *I, const APInt &DemandedMask, KnownBits &Known, unsigned Depth, Instruction *CxtI)
 Helper routine of SimplifyDemandedUseBits. More...
 
ValuesimplifyShrShlDemandedBits (Instruction *Shr, const APInt &ShrOp1, Instruction *Shl, const APInt &ShlOp1, const APInt &DemandedMask, KnownBits &Known)
 Helper routine of SimplifyDemandedUseBits. More...
 
bool SimplifyDemandedInstructionBits (Instruction &Inst)
 Tries to simplify operands to an integer instruction based on its demanded bits. More...
 
virtual ValueSimplifyDemandedVectorElts (Value *V, APInt DemandedElts, APInt &UndefElts, unsigned Depth=0, bool AllowMultipleUsers=false) override
 The specified value produces a vector with any number of elements. More...
 
InstructionfoldVectorBinop (BinaryOperator &Inst)
 Canonicalize the position of binops relative to shufflevector. More...
 
InstructionfoldVectorSelect (SelectInst &Sel)
 
InstructionfoldOpIntoPhi (Instruction &I, PHINode *PN)
 Given a binary operator, cast instruction, or select which has a PHI node as operand #0, see if we can fold the instruction into the PHI (which is only possible if all operands to the PHI are constants). More...
 
InstructionFoldOpIntoSelect (Instruction &Op, SelectInst *SI)
 Given an instruction with a select as one operand and a constant as the other operand, try to fold the binary operator into the select arguments. More...
 
InstructionfoldBinOpIntoSelectOrPhi (BinaryOperator &I)
 This is a convenience wrapper function for the above two functions. More...
 
InstructionfoldAddWithConstant (BinaryOperator &Add)
 
InstructionfoldPHIArgOpIntoPHI (PHINode &PN)
 Try to rotate an operation below a PHI node, using PHI nodes for its operands. More...
 
InstructionfoldPHIArgBinOpIntoPHI (PHINode &PN)
 If we have something like phi [add (a,b), add(a,c)] and if a/b/c and the adds all have a single user, turn this into a phi and a single binop. More...
 
InstructionfoldPHIArgInsertValueInstructionIntoPHI (PHINode &PN)
 If we have something like phi [insertvalue(a,b,0), insertvalue(c,d,0)], turn this into a phi[a,c] and phi[b,d] and a single insertvalue. More...
 
InstructionfoldPHIArgExtractValueInstructionIntoPHI (PHINode &PN)
 If we have something like phi [extractvalue(a,0), extractvalue(b,0)], turn this into a phi[a,b] and a single extractvalue. More...
 
InstructionfoldPHIArgGEPIntoPHI (PHINode &PN)
 
InstructionfoldPHIArgLoadIntoPHI (PHINode &PN)
 
InstructionfoldPHIArgZextsIntoPHI (PHINode &PN)
 TODO: This function could handle other cast types, but then it might require special-casing a cast from the 'i1' type. More...
 
InstructionfoldPHIArgIntToPtrToPHI (PHINode &PN)
 
InstructionfoldIntegerTypedPHI (PHINode &PN)
 If an integer typed PHI has only one use which is an IntToPtr operation, replace the PHI with an existing pointer typed PHI if it exists. More...
 
void PHIArgMergedDebugLoc (Instruction *Inst, PHINode &PN)
 Helper function for FoldPHIArgXIntoPHI() to set debug location for the folded operation. More...
 
InstructionfoldGEPICmp (GEPOperator *GEPLHS, Value *RHS, ICmpInst::Predicate Cond, Instruction &I)
 Fold comparisons between a GEP instruction and something else. More...
 
InstructionfoldAllocaCmp (ICmpInst &ICI, const AllocaInst *Alloca, const Value *Other)
 
InstructionfoldCmpLoadFromIndexedGlobal (GetElementPtrInst *GEP, GlobalVariable *GV, CmpInst &ICI, ConstantInt *AndCst=nullptr)
 This is called when we see this pattern: cmp pred (load (gep GV, ...)), cmpcst where GV is a global variable with a constant initializer. More...
 
InstructionfoldFCmpIntToFPConst (FCmpInst &I, Instruction *LHSI, Constant *RHSC)
 Fold fcmp ([us]itofp x, cst) if possible. More...
 
InstructionfoldICmpAddOpConst (Value *X, const APInt &C, ICmpInst::Predicate Pred)
 Fold "icmp pred (X+C), X". More...
 
InstructionfoldICmpWithCastOp (ICmpInst &ICI)
 Handle icmp (cast x), (cast or constant). More...
 
InstructionfoldICmpUsingKnownBits (ICmpInst &Cmp)
 Try to fold the comparison based on range information we can get by checking whether bits are known to be zero or one in the inputs. More...
 
InstructionfoldICmpWithDominatingICmp (ICmpInst &Cmp)
 Canonicalize icmp instructions based on dominating conditions. More...
 
InstructionfoldICmpWithConstant (ICmpInst &Cmp)
 Fold icmp Pred X, C. More...
 
InstructionfoldICmpInstWithConstant (ICmpInst &Cmp)
 Try to fold integer comparisons with a constant operand: icmp Pred X, C where X is some kind of instruction. More...
 
InstructionfoldICmpInstWithConstantNotInt (ICmpInst &Cmp)
 Handle icmp with constant (but not simple integer constant) RHS. More...
 
InstructionfoldICmpBinOp (ICmpInst &Cmp, const SimplifyQuery &SQ)
 Try to fold icmp (binop), X or icmp X, (binop). More...
 
InstructionfoldICmpEquality (ICmpInst &Cmp)
 
InstructionfoldIRemByPowerOfTwoToBitTest (ICmpInst &I)
 If we have: icmp eq/ne (urem/srem x, y), 0 iff y is a power-of-two, we can replace this with a bit test: icmp eq/ne (and x, (add y, -1)), 0. More...
 
InstructionfoldSignBitTest (ICmpInst &I)
 Fold equality-comparison between zero and any (maybe truncated) right-shift by one-less-than-bitwidth into a sign test on the original value. More...
 
InstructionfoldICmpWithZero (ICmpInst &Cmp)
 
ValuefoldMultiplicationOverflowCheck (ICmpInst &Cmp)
 Fold (-1 u/ x) u< y ((x * y) ?/ x) != y to @llvm. More...
 
InstructionfoldICmpSelectConstant (ICmpInst &Cmp, SelectInst *Select, ConstantInt *C)
 
InstructionfoldICmpTruncConstant (ICmpInst &Cmp, TruncInst *Trunc, const APInt &C)
 Fold icmp (trunc X, Y), C. More...
 
InstructionfoldICmpAndConstant (ICmpInst &Cmp, BinaryOperator *And, const APInt &C)
 Fold icmp (and X, Y), C. More...
 
InstructionfoldICmpXorConstant (ICmpInst &Cmp, BinaryOperator *Xor, const APInt &C)
 Fold icmp (xor X, Y), C. More...
 
InstructionfoldICmpOrConstant (ICmpInst &Cmp, BinaryOperator *Or, const APInt &C)
 Fold icmp (or X, Y), C. More...
 
InstructionfoldICmpMulConstant (ICmpInst &Cmp, BinaryOperator *Mul, const APInt &C)
 Fold icmp (mul X, Y), C. More...
 
InstructionfoldICmpShlConstant (ICmpInst &Cmp, BinaryOperator *Shl, const APInt &C)
 Fold icmp (shl X, Y), C. More...
 
InstructionfoldICmpShrConstant (ICmpInst &Cmp, BinaryOperator *Shr, const APInt &C)
 Fold icmp ({al}shr X, Y), C. More...
 
InstructionfoldICmpSRemConstant (ICmpInst &Cmp, BinaryOperator *UDiv, const APInt &C)
 
InstructionfoldICmpUDivConstant (ICmpInst &Cmp, BinaryOperator *UDiv, const APInt &C)
 Fold icmp (udiv X, Y), C. More...
 
InstructionfoldICmpDivConstant (ICmpInst &Cmp, BinaryOperator *Div, const APInt &C)
 Fold icmp ({su}div X, Y), C. More...
 
InstructionfoldICmpSubConstant (ICmpInst &Cmp, BinaryOperator *Sub, const APInt &C)
 Fold icmp (sub X, Y), C. More...
 
InstructionfoldICmpAddConstant (ICmpInst &Cmp, BinaryOperator *Add, const APInt &C)
 Fold icmp (add X, Y), C. More...
 
InstructionfoldICmpAndConstConst (ICmpInst &Cmp, BinaryOperator *And, const APInt &C1)
 Fold icmp (and X, C2), C1. More...
 
InstructionfoldICmpAndShift (ICmpInst &Cmp, BinaryOperator *And, const APInt &C1, const APInt &C2)
 Fold icmp (and (sh X, Y), C2), C1. More...
 
InstructionfoldICmpShrConstConst (ICmpInst &I, Value *ShAmt, const APInt &C1, const APInt &C2)
 Handle "(icmp eq/ne (ashr/lshr AP2, A), AP1)" -> (icmp eq/ne A, Log2(AP2/AP1)) -> (icmp eq/ne A, Log2(AP2) - Log2(AP1)). More...
 
InstructionfoldICmpShlConstConst (ICmpInst &I, Value *ShAmt, const APInt &C1, const APInt &C2)
 Handle "(icmp eq/ne (shl AP2, A), AP1)" -> (icmp eq/ne A, TrailingZeros(AP1) - TrailingZeros(AP2)). More...
 
InstructionfoldICmpBinOpEqualityWithConstant (ICmpInst &Cmp, BinaryOperator *BO, const APInt &C)
 Fold an icmp equality instruction with binary operator LHS and constant RHS: icmp eq/ne BO, C. More...
 
InstructionfoldICmpIntrinsicWithConstant (ICmpInst &ICI, IntrinsicInst *II, const APInt &C)
 Fold an icmp with LLVM intrinsic and constant operand: icmp Pred II, C. More...
 
InstructionfoldICmpEqIntrinsicWithConstant (ICmpInst &ICI, IntrinsicInst *II, const APInt &C)
 Fold an equality icmp with LLVM intrinsic and constant operand. More...
 
InstructionfoldICmpBitCast (ICmpInst &Cmp)
 
InstructionfoldSelectExtConst (SelectInst &Sel)
 
InstructionfoldSelectOpOp (SelectInst &SI, Instruction *TI, Instruction *FI)
 We have (select c, TI, FI), and we know that TI and FI have the same opcode. More...
 
InstructionfoldSelectIntoOp (SelectInst &SI, Value *, Value *)
 Try to fold the select into one of the operands to allow further optimization. More...
 
InstructionfoldSPFofSPF (Instruction *Inner, SelectPatternFlavor SPF1, Value *A, Value *B, Instruction &Outer, SelectPatternFlavor SPF2, Value *C)
 
InstructionfoldSelectInstWithICmp (SelectInst &SI, ICmpInst *ICI)
 
InstructionfoldSelectValueEquivalence (SelectInst &SI, ICmpInst &ICI)
 
ValueinsertRangeTest (Value *V, const APInt &Lo, const APInt &Hi, bool isSigned, bool Inside)
 Emit a computation of: (V >= Lo && V < Hi) if Inside is true, otherwise (V < Lo || V >= Hi). More...
 
InstructionPromoteCastOfAllocation (BitCastInst &CI, AllocaInst &AI)
 If we find a cast of an allocation instruction, try to eliminate the cast by moving the type information into the alloc. More...
 
bool mergeStoreIntoSuccessor (StoreInst &SI)
 Try to transform: if () { *P = v1; } else { *P = v2 } or: *P = v1; if () { *P = v2; } into a phi node with a store in the successor. More...
 
InstructionmatchBSwapOrBitReverse (Instruction &I, bool MatchBSwaps, bool MatchBitReversals)
 Given an initial instruction, check to see if it is the root of a bswap/bitreverse idiom. More...
 
InstructionSimplifyAnyMemTransfer (AnyMemTransferInst *MI)
 
InstructionSimplifyAnyMemSet (AnyMemSetInst *MI)
 
ValueEvaluateInDifferentType (Value *V, Type *Ty, bool isSigned)
 Given an expression that CanEvaluateTruncated or CanEvaluateSExtd returns true for, actually insert the code to evaluate the expression. More...
 
ValueDescale (Value *Val, APInt Scale, bool &NoSignedWrap)
 Returns a value X such that Val = X * Scale, or null if none. More...
 
- Public Member Functions inherited from llvm::InstCombiner
 InstCombiner (InstructionWorklist &Worklist, BuilderTy &Builder, bool MinimizeSize, AAResults *AA, AssumptionCache &AC, TargetLibraryInfo &TLI, TargetTransformInfo &TTI, DominatorTree &DT, OptimizationRemarkEmitter &ORE, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI, const DataLayout &DL, LoopInfo *LI)
 
virtual ~InstCombiner ()
 
void addToWorklist (Instruction *I)
 
AssumptionCachegetAssumptionCache () const
 
TargetLibraryInfogetTargetLibraryInfo () const
 
DominatorTreegetDominatorTree () const
 
const DataLayoutgetDataLayout () const
 
const SimplifyQuerygetSimplifyQuery () const
 
OptimizationRemarkEmittergetOptimizationRemarkEmitter () const
 
BlockFrequencyInfogetBlockFrequencyInfo () const
 
ProfileSummaryInfogetProfileSummaryInfo () const
 
LoopInfogetLoopInfo () const
 
Optional< Instruction * > targetInstCombineIntrinsic (IntrinsicInst &II)
 
Optional< Value * > targetSimplifyDemandedUseBitsIntrinsic (IntrinsicInst &II, APInt DemandedMask, KnownBits &Known, bool &KnownBitsComputed)
 
Optional< Value * > targetSimplifyDemandedVectorEltsIntrinsic (IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts, APInt &UndefElts2, APInt &UndefElts3, std::function< void(Instruction *, unsigned, APInt, APInt &)> SimplifyAndSetOp)
 
InstructionInsertNewInstBefore (Instruction *New, Instruction &Old)
 Inserts an instruction New before instruction Old. More...
 
InstructionInsertNewInstWith (Instruction *New, Instruction &Old)
 Same as InsertNewInstBefore, but also sets the debug loc. More...
 
InstructionreplaceInstUsesWith (Instruction &I, Value *V)
 A combiner-aware RAUW-like routine. More...
 
InstructionreplaceOperand (Instruction &I, unsigned OpNum, Value *V)
 Replace operand of instruction and add old operand to the worklist. More...
 
void replaceUse (Use &U, Value *NewValue)
 Replace use and add the previously used value to the worklist. More...
 
void computeKnownBits (const Value *V, KnownBits &Known, unsigned Depth, const Instruction *CxtI) const
 
KnownBits computeKnownBits (const Value *V, unsigned Depth, const Instruction *CxtI) const
 
bool isKnownToBeAPowerOfTwo (const Value *V, bool OrZero=false, unsigned Depth=0, const Instruction *CxtI=nullptr)
 
bool MaskedValueIsZero (const Value *V, const APInt &Mask, unsigned Depth=0, const Instruction *CxtI=nullptr) const
 
unsigned ComputeNumSignBits (const Value *Op, unsigned Depth=0, const Instruction *CxtI=nullptr) const
 
OverflowResult computeOverflowForUnsignedMul (const Value *LHS, const Value *RHS, const Instruction *CxtI) const
 
OverflowResult computeOverflowForSignedMul (const Value *LHS, const Value *RHS, const Instruction *CxtI) const
 
OverflowResult computeOverflowForUnsignedAdd (const Value *LHS, const Value *RHS, const Instruction *CxtI) const
 
OverflowResult computeOverflowForSignedAdd (const Value *LHS, const Value *RHS, const Instruction *CxtI) const
 
OverflowResult computeOverflowForUnsignedSub (const Value *LHS, const Value *RHS, const Instruction *CxtI) const
 
OverflowResult computeOverflowForSignedSub (const Value *LHS, const Value *RHS, const Instruction *CxtI) const
 
- Public Member Functions inherited from llvm::InstVisitor< InstCombinerImpl, Instruction * >
void visit (Iterator Start, Iterator End)
 
void visit (Module &M)
 
void visit (Function &F)
 
void visit (BasicBlock &BB)
 
void visit (Module *M)
 
void visit (Function *F)
 
void visit (BasicBlock *BB)
 
Instructionvisit (Instruction *I)
 
Instructionvisit (Instruction &I)
 
void visitModule (Module &M)
 
void visitFunction (Function &F)
 
void visitBasicBlock (BasicBlock &BB)
 
InstructionvisitICmpInst (ICmpInst &I)
 
InstructionvisitFCmpInst (FCmpInst &I)
 
InstructionvisitAllocaInst (AllocaInst &I)
 
InstructionvisitLoadInst (LoadInst &I)
 
InstructionvisitStoreInst (StoreInst &I)
 
InstructionvisitAtomicCmpXchgInst (AtomicCmpXchgInst &I)
 
InstructionvisitAtomicRMWInst (AtomicRMWInst &I)
 
InstructionvisitFenceInst (FenceInst &I)
 
InstructionvisitGetElementPtrInst (GetElementPtrInst &I)
 
InstructionvisitPHINode (PHINode &I)
 
InstructionvisitTruncInst (TruncInst &I)
 
InstructionvisitZExtInst (ZExtInst &I)
 
InstructionvisitSExtInst (SExtInst &I)
 
InstructionvisitFPTruncInst (FPTruncInst &I)
 
InstructionvisitFPExtInst (FPExtInst &I)
 
InstructionvisitFPToUIInst (FPToUIInst &I)
 
InstructionvisitFPToSIInst (FPToSIInst &I)
 
InstructionvisitUIToFPInst (UIToFPInst &I)
 
InstructionvisitSIToFPInst (SIToFPInst &I)
 
InstructionvisitPtrToIntInst (PtrToIntInst &I)
 
InstructionvisitIntToPtrInst (IntToPtrInst &I)
 
InstructionvisitBitCastInst (BitCastInst &I)
 
InstructionvisitAddrSpaceCastInst (AddrSpaceCastInst &I)
 
InstructionvisitSelectInst (SelectInst &I)
 
InstructionvisitVAArgInst (VAArgInst &I)
 
InstructionvisitExtractElementInst (ExtractElementInst &I)
 
InstructionvisitInsertElementInst (InsertElementInst &I)
 
InstructionvisitShuffleVectorInst (ShuffleVectorInst &I)
 
InstructionvisitExtractValueInst (ExtractValueInst &I)
 
InstructionvisitInsertValueInst (InsertValueInst &I)
 
InstructionvisitLandingPadInst (LandingPadInst &I)
 
InstructionvisitFuncletPadInst (FuncletPadInst &I)
 
InstructionvisitCleanupPadInst (CleanupPadInst &I)
 
InstructionvisitCatchPadInst (CatchPadInst &I)
 
InstructionvisitFreezeInst (FreezeInst &I)
 
InstructionvisitDbgDeclareInst (DbgDeclareInst &I)
 
InstructionvisitDbgValueInst (DbgValueInst &I)
 
InstructionvisitDbgVariableIntrinsic (DbgVariableIntrinsic &I)
 
InstructionvisitDbgLabelInst (DbgLabelInst &I)
 
InstructionvisitDbgInfoIntrinsic (DbgInfoIntrinsic &I)
 
InstructionvisitMemSetInst (MemSetInst &I)
 
InstructionvisitMemCpyInst (MemCpyInst &I)
 
InstructionvisitMemCpyInlineInst (MemCpyInlineInst &I)
 
InstructionvisitMemMoveInst (MemMoveInst &I)
 
InstructionvisitMemTransferInst (MemTransferInst &I)
 
InstructionvisitMemIntrinsic (MemIntrinsic &I)
 
InstructionvisitVAStartInst (VAStartInst &I)
 
InstructionvisitVAEndInst (VAEndInst &I)
 
InstructionvisitVACopyInst (VACopyInst &I)
 
InstructionvisitIntrinsicInst (IntrinsicInst &I)
 
InstructionvisitCallInst (CallInst &I)
 
InstructionvisitInvokeInst (InvokeInst &I)
 
InstructionvisitCallBrInst (CallBrInst &I)
 
InstructionvisitReturnInst (ReturnInst &I)
 
InstructionvisitBranchInst (BranchInst &I)
 
InstructionvisitSwitchInst (SwitchInst &I)
 
InstructionvisitIndirectBrInst (IndirectBrInst &I)
 
InstructionvisitResumeInst (ResumeInst &I)
 
InstructionvisitUnreachableInst (UnreachableInst &I)
 
InstructionvisitCleanupReturnInst (CleanupReturnInst &I)
 
InstructionvisitCatchReturnInst (CatchReturnInst &I)
 
InstructionvisitCatchSwitchInst (CatchSwitchInst &I)
 
InstructionvisitTerminator (Instruction &I)
 
InstructionvisitCastInst (CastInst &I)
 
InstructionvisitUnaryOperator (UnaryOperator &I)
 
InstructionvisitBinaryOperator (BinaryOperator &I)
 
InstructionvisitCmpInst (CmpInst &I)
 
InstructionvisitUnaryInstruction (UnaryInstruction &I)
 
InstructionvisitCallBase (CallBase &I)
 
void visitInstruction (Instruction &I)
 

Additional Inherited Members

- Public Types inherited from llvm::InstCombiner
using BuilderTy = IRBuilder< TargetFolder, IRBuilderCallbackInserter >
 An IRBuilder that automatically inserts new instructions into the worklist. More...
 
- Static Public Member Functions inherited from llvm::InstCombiner
static ValuepeekThroughBitcast (Value *V, bool OneUseOnly=false)
 Return the source operand of a potentially bitcasted value while optionally checking if it has one use. More...
 
static unsigned getComplexity (Value *V)
 Assign a complexity or rank value to LLVM Values. More...
 
static bool isCanonicalPredicate (CmpInst::Predicate Pred)
 Predicate canonicalization reduces the number of patterns that need to be matched by other transforms. More...
 
static bool isSignBitCheck (ICmpInst::Predicate Pred, const APInt &RHS, bool &TrueIfSigned)
 Given an exploded icmp instruction, return true if the comparison only checks the sign bit. More...
 
static ConstantAddOne (Constant *C)
 Add one to a Constant. More...
 
static ConstantSubOne (Constant *C)
 Subtract one from a Constant. More...
 
static llvm::Optional< std::pair< CmpInst::Predicate, Constant * > > getFlippedStrictnessPredicateAndConstant (CmpInst::Predicate Pred, Constant *C)
 
static bool shouldAvoidAbsorbingNotIntoSelect (const SelectInst &SI)
 
static bool isFreeToInvert (Value *V, bool WillInvertAllUses)
 Return true if the specified value is free to invert (apply ~ to). More...
 
static bool canFreelyInvertAllUsersOf (Value *V, Value *IgnoredUser)
 Given i1 V, can every user of V be freely adapted if V is changed to !V ? InstCombine's freelyInvertAllUsersOf() must be kept in sync with this fn. More...
 
static ConstantgetSafeVectorConstantForBinop (BinaryOperator::BinaryOps Opcode, Constant *In, bool IsRHSConstant)
 Some binary operators require special handling to avoid poison and undefined behavior. More...
 
- Public Attributes inherited from llvm::InstCombiner
uint64_t MaxArraySizeForCombine = 0
 Maximum size of array considered when transforming. More...
 
BuilderTyBuilder
 
- Protected Attributes inherited from llvm::InstCombiner
InstructionWorklistWorklist
 A worklist of the instructions that need to be simplified. More...
 
const bool MinimizeSize
 
AAResultsAA
 
AssumptionCacheAC
 
TargetLibraryInfoTLI
 
DominatorTreeDT
 
const DataLayoutDL
 
const SimplifyQuery SQ
 
OptimizationRemarkEmitterORE
 
BlockFrequencyInfoBFI
 
ProfileSummaryInfoPSI
 
LoopInfoLI
 
bool MadeIRChange = false
 

Detailed Description

Definition at line 61 of file InstCombineInternal.h.

Constructor & Destructor Documentation

◆ InstCombinerImpl()

llvm::InstCombinerImpl::InstCombinerImpl ( InstructionWorklist Worklist,
BuilderTy Builder,
bool  MinimizeSize,
AAResults AA,
AssumptionCache AC,
TargetLibraryInfo TLI,
TargetTransformInfo TTI,
DominatorTree DT,
OptimizationRemarkEmitter ORE,
BlockFrequencyInfo BFI,
ProfileSummaryInfo PSI,
const DataLayout DL,
LoopInfo LI 
)
inline

Definition at line 65 of file InstCombineInternal.h.

◆ ~InstCombinerImpl()

virtual llvm::InstCombinerImpl::~InstCombinerImpl ( )
inlinevirtual

Definition at line 74 of file InstCombineInternal.h.

Member Function Documentation

◆ canonicalizeCondSignextOfHighBitExtractToSignextHighBitExtract()

Instruction * InstCombinerImpl::canonicalizeCondSignextOfHighBitExtractToSignextHighBitExtract ( BinaryOperator I)

◆ canonicalizeICmpPredicate()

CmpInst * InstCombinerImpl::canonicalizeICmpPredicate ( CmpInst I)

If we have a comparison with a non-canonical predicate, if we can update all the users, invert the predicate and adjust all the users.

Definition at line 5572 of file InstCombineCompares.cpp.

References llvm::InstCombiner::canFreelyInvertAllUsersOf(), llvm::CmpInst::getInversePredicate(), I, and llvm::InstCombiner::isCanonicalPredicate().

◆ combineLoadToNewType()

LoadInst * InstCombinerImpl::combineLoadToNewType ( LoadInst LI,
Type NewTy,
const Twine Suffix = "" 
)

Helper to combine a load to a new type.

This just does the work of combining a load to a new type. It handles metadata, etc., and returns the new instruction. The NewTy should be the loaded value type. This will convert it to a pointer, cast the operand to that pointer type, load it, etc.

Note that this will create all of the instructions with whatever insert point the InstCombinerImpl currently is using.

Definition at line 470 of file InstCombineLoadStoreAlloca.cpp.

References assert(), Builder, llvm::copyMetadataForLoad(), llvm::LoadInst::getAlign(), llvm::Value::getName(), llvm::LoadInst::getOrdering(), llvm::LoadInst::getPointerAddressSpace(), llvm::LoadInst::getPointerOperand(), llvm::Type::getPointerTo(), llvm::LoadInst::getSyncScopeID(), llvm::Value::getType(), llvm::Instruction::isAtomic(), isSupportedAtomicType(), llvm::LoadInst::isVolatile(), llvm::PatternMatch::m_BitCast(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and llvm::LoadInst::setAtomic().

Referenced by combineLoadToOperationType(), removeBitcastsFromLoadStoreOnMinMax(), and unpackLoadToAggregate().

◆ commonCastTransforms()

Instruction * InstCombinerImpl::commonCastTransforms ( CastInst CI)

◆ commonIDivTransforms()

Instruction * InstCombinerImpl::commonIDivTransforms ( BinaryOperator I)

◆ commonIRemTransforms()

Instruction * InstCombinerImpl::commonIRemTransforms ( BinaryOperator I)

This function implements the transforms common to both integer remainder instructions (urem and srem).

It is called by the visitors to those integer remainder instructions. Common integer remainder transforms

Definition at line 1453 of file InstCombineMulDivRem.cpp.

References I, llvm::APInt::isMinSignedValue(), llvm::APInt::isMinValue(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), SI, and simplifyValueKnownNonZero().

◆ commonPointerCastTransforms()

Instruction * InstCombinerImpl::commonPointerCastTransforms ( CastInst CI)

Implement the transforms for cast of pointer (bitcast/ptrtoint)

Definition at line 2038 of file InstCombineCasts.cpp.

References GEP, and llvm::User::getOperand().

◆ commonShiftTransforms()

Instruction * InstCombinerImpl::commonShiftTransforms ( BinaryOperator I)

◆ computeKnownBits() [1/2]

void llvm::InstCombinerImpl::computeKnownBits ( const Value V,
KnownBits Known,
unsigned  Depth,
const Instruction CxtI 
) const
inline

◆ computeKnownBits() [2/2]

KnownBits llvm::InstCombinerImpl::computeKnownBits ( const Value V,
unsigned  Depth,
const Instruction CxtI 
) const
inline

Definition at line 469 of file InstCombineInternal.h.

References llvm::computeKnownBits(), llvm::Depth, and DL.

◆ ComputeNumSignBits()

unsigned llvm::InstCombinerImpl::ComputeNumSignBits ( const Value Op,
unsigned  Depth = 0,
const Instruction CxtI = nullptr 
) const
inline

Definition at line 485 of file InstCombineInternal.h.

References llvm::ComputeNumSignBits(), llvm::Depth, and DL.

Referenced by canEvaluateTruncated(), and processUGT_ADDCST_ADD().

◆ computeOverflow()

OverflowResult InstCombinerImpl::computeOverflow ( Instruction::BinaryOps  BinaryOp,
bool  IsSigned,
Value LHS,
Value RHS,
Instruction CxtI 
) const

◆ computeOverflowForSignedAdd()

OverflowResult llvm::InstCombinerImpl::computeOverflowForSignedAdd ( const Value LHS,
const Value RHS,
const Instruction CxtI 
) const
inline

Definition at line 508 of file InstCombineInternal.h.

References llvm::computeOverflowForSignedAdd(), and DL.

◆ computeOverflowForSignedMul()

OverflowResult llvm::InstCombinerImpl::computeOverflowForSignedMul ( const Value LHS,
const Value RHS,
const Instruction CxtI 
) const
inline

Definition at line 496 of file InstCombineInternal.h.

References llvm::computeOverflowForSignedMul(), and DL.

◆ computeOverflowForSignedSub()

OverflowResult llvm::InstCombinerImpl::computeOverflowForSignedSub ( const Value LHS,
const Value RHS,
const Instruction CxtI 
) const
inline

Definition at line 520 of file InstCombineInternal.h.

References llvm::computeOverflowForSignedSub(), and DL.

◆ computeOverflowForUnsignedAdd()

OverflowResult llvm::InstCombinerImpl::computeOverflowForUnsignedAdd ( const Value LHS,
const Value RHS,
const Instruction CxtI 
) const
inline

Definition at line 502 of file InstCombineInternal.h.

References llvm::computeOverflowForUnsignedAdd(), and DL.

◆ computeOverflowForUnsignedMul()

OverflowResult llvm::InstCombinerImpl::computeOverflowForUnsignedMul ( const Value LHS,
const Value RHS,
const Instruction CxtI 
) const
inline

Definition at line 490 of file InstCombineInternal.h.

References llvm::computeOverflowForUnsignedMul(), and DL.

◆ computeOverflowForUnsignedSub()

OverflowResult llvm::InstCombinerImpl::computeOverflowForUnsignedSub ( const Value LHS,
const Value RHS,
const Instruction CxtI 
) const
inline

Definition at line 514 of file InstCombineInternal.h.

References llvm::computeOverflowForUnsignedSub(), and DL.

◆ CreateNonTerminatorUnreachable()

void llvm::InstCombinerImpl::CreateNonTerminatorUnreachable ( Instruction InsertAt)
inline

Create and insert the idiom we use to indicate a block is unreachable without having to rewrite the CFG from within InstCombine.

Definition at line 434 of file InstCombineInternal.h.

References llvm::UndefValue::get(), llvm::Value::getContext(), llvm::Type::getInt1PtrTy(), and llvm::ConstantInt::getTrue().

◆ Descale()

Value * InstCombinerImpl::Descale ( Value Val,
APInt  Scale,
bool &  NoSignedWrap 
)

Returns a value X such that Val = X * Scale, or null if none.

Return a value X such that Val = X * Scale, or null if none.

If the multiplication is known not to overflow then NoSignedWrap is set.

If the multiplication is known not to overflow, then NoSignedWrap is set.

Definition at line 1316 of file InstructionCombining.cpp.

References assert(), llvm::APInt::exactLogBase2(), llvm::ConstantInt::get(), llvm::APInt::getBitWidth(), llvm::Instruction::getOpcode(), llvm::Value::getType(), llvm::Instruction::hasNoSignedWrap(), hasOneUse(), llvm::Value::hasOneUse(), llvm::APInt::isMinValue(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::APInt::sdivrem(), llvm::APInt::sext(), llvm::APInt::trunc(), and llvm::Instruction::user_back().

◆ dominatesAllUses()

bool InstCombinerImpl::dominatesAllUses ( const Instruction DI,
const Instruction UI,
const BasicBlock DB 
) const

True when DB dominates all uses of DI except UI.

Check that one use is in the same block as the definition and all other uses are in blocks dominated by a given block.

UI must be in the same block as DI. The routine checks that the DI parent and DB are different.

Parameters
DIDefinition
UIUse
DBBlock that must dominate all uses of DI outside the parent block
Returns
true when UI is the only use of DI in the parent block and all other uses of DI are in blocks dominated by DB.

Definition at line 5120 of file InstCombineCompares.cpp.

References assert(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), and llvm::Value::users().

◆ eraseInstFromFunction()

Instruction* llvm::InstCombinerImpl::eraseInstFromFunction ( Instruction I)
inlineoverridevirtual

Combiner aware instruction erasure.

When dealing with an instruction that has side effects or produces a void value, we can't rely on DCE to delete the instruction. Instead, visit methods should return the value returned by this function.

Implements llvm::InstCombiner.

Definition at line 447 of file InstCombineInternal.h.

References assert(), llvm::dbgs(), I, LLVM_DEBUG, and llvm::salvageDebugInfo().

Referenced by combineLoadToOperationType(), processUGT_ADDCST_ADD(), removeBitcastsFromLoadStoreOnMinMax(), removeTriviallyEmptyRange(), and visitAtomicRMWInst().

◆ EvaluateInDifferentType()

Value * InstCombinerImpl::EvaluateInDifferentType ( Value V,
Type Ty,
bool  isSigned 
)

◆ foldAddWithConstant()

Instruction * InstCombinerImpl::foldAddWithConstant ( BinaryOperator Add)

◆ foldAggregateConstructionIntoAggregateReuse()

Instruction * InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse ( InsertValueInst OrigIVI)

Look for chain of insertvalue's that fully define an aggregate, and trace back the values inserted, see if they are all were extractvalue'd from the same source aggregate from the exact same element indexes.

If they were, just reuse the source aggregate. This potentially deals with PHI indirections.

When analyzing the value that was inserted into an aggregate, we did not manage to find defining extractvalue instruction to analyze.

When analyzing the value that was inserted into an aggregate, we did manage to find defining extractvalue instruction[s], and everything matched perfectly - aggregate type, element insertion/extraction index.

When analyzing the value that was inserted into an aggregate, we did manage to find defining extractvalue instruction, but there was a mismatch: either the source type from which the extraction was didn't match the aggregate type into which the insertion was, or the extraction/insertion channels mismatched, or different elements had different source aggregates.

Definition at line 803 of file InstCombineVectorOps.cpp.

References llvm::all_of(), llvm::Type::ArrayTyID, assert(), BB, Builder, llvm::Depth, llvm::Value::DoPHITranslation(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::enumerate(), llvm::ArrayRef< T >::front(), llvm::Type::getArrayNumElements(), llvm::BasicBlock::getFirstNonPHI(), llvm::Value::getName(), llvm::Type::getStructNumElements(), llvm::Value::getType(), llvm::Type::getTypeID(), llvm::Optional< T >::getValueOr(), I, llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::insert(), llvm_unreachable, llvm::None, llvm::LegacyLegalizeActions::NotFound, llvm::pred_empty(), llvm::predecessors(), llvm::ArrayRef< T >::size(), and llvm::Type::StructTyID.

◆ foldAllocaCmp()

Instruction * InstCombinerImpl::foldAllocaCmp ( ICmpInst ICI,
const AllocaInst Alloca,
const Value Other 
)

◆ foldBinOpIntoSelectOrPhi()

Instruction * InstCombinerImpl::foldBinOpIntoSelectOrPhi ( BinaryOperator I)

This is a convenience wrapper function for the above two functions.

Definition at line 1269 of file InstructionCombining.cpp.

References I.

◆ foldCmpLoadFromIndexedGlobal()

Instruction * InstCombinerImpl::foldCmpLoadFromIndexedGlobal ( GetElementPtrInst GEP,
GlobalVariable GV,
CmpInst ICI,
ConstantInt AndCst = nullptr 
)

This is called when we see this pattern: cmp pred (load (gep GV, ...)), cmpcst where GV is a global variable with a constant initializer.

Try to simplify this into some simple computation that does not need the load. For example we can optimize "icmp eq (load (gep "foo", 0, i)), 0" into "icmp eq i, 3".

If AndCst is non-null, then the loaded value is masked with that constant before doing the comparison. This handles cases like "A[i]&4 == 0".

TrueRangeEnd/FalseRangeEnd - In conjunction with First*Element, these define a state machine that triggers for ranges of values that the index is true or false for. This triggers on things like "abbbbc"[i] == 'b'. This is -2 when undefined, -3 when overdefined, and otherwise the last index in the range (inclusive). We use -2 for undefined here because we use relative comparisons and don't want 0-1 to match -1.

Definition at line 108 of file InstCombineCompares.cpp.

References assert(), Builder, C1, llvm::ConstantFoldCompareInstOperands(), llvm::countTrailingZeros(), DL, llvm::numbers::e, GEP, llvm::ConstantInt::get(), llvm::ConstantExpr::getAnd(), llvm::ConstantExpr::getExtractValue(), llvm::TypeSize::getFixedSize(), llvm::GlobalVariable::getInitializer(), llvm::Type::getIntegerBitWidth(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::ConstantInt::getZExtValue(), i, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, and llvm::BitmaskEnumDetail::Mask().

◆ foldFCmpIntToFPConst()

Instruction * InstCombinerImpl::foldFCmpIntToFPConst ( FCmpInst I,
Instruction LHSI,
Constant RHSC 
)

Fold fcmp ([us]itofp x, cst) if possible.

Definition at line 6052 of file InstCombineCompares.cpp.

References assert(), Builder, llvm::APFloat::convertToInteger(), llvm::object::Equal, llvm::CmpInst::FCMP_OEQ, llvm::CmpInst::FCMP_OGE, llvm::CmpInst::FCMP_OGT, llvm::CmpInst::FCMP_OLE, llvm::CmpInst::FCMP_OLT, llvm::CmpInst::FCMP_ONE, llvm::CmpInst::FCMP_ORD, llvm::CmpInst::FCMP_UEQ, llvm::CmpInst::FCMP_UGE, llvm::CmpInst::FCMP_UGT, llvm::CmpInst::FCMP_ULE, llvm::CmpInst::FCMP_ULT, llvm::CmpInst::FCMP_UNE, llvm::CmpInst::FCMP_UNO, llvm::IntegerType::getBitWidth(), llvm::Type::getFPMantissaWidth(), llvm::ConstantExpr::getFPToSI(), llvm::ConstantExpr::getFPToUI(), llvm::APFloat::getLargest(), llvm::APInt::getMaxValue(), llvm::APInt::getMinValue(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::APFloat::getSemantics(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), llvm::ConstantExpr::getSIToFP(), llvm::Value::getType(), llvm::ConstantExpr::getUIToFP(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::APFloatBase::IEK_Inf, llvm::detail::ilogb(), llvm::APFloat::isNaN(), llvm::APFloat::isNegative(), llvm::APFloat::isZero(), llvm_unreachable, P, llvm::APFloatBase::rmNearestTiesToEven, llvm::APFloat::roundToIntegral(), llvm::SMax, llvm::SMin, llvm::UMax, and llvm::UMin.

◆ foldGEPICmp()

Instruction * InstCombinerImpl::foldGEPICmp ( GEPOperator GEPLHS,
Value RHS,
ICmpInst::Predicate  Cond,
Instruction I 
)

◆ foldICmpAddConstant()

Instruction * InstCombinerImpl::foldICmpAddConstant ( ICmpInst Cmp,
BinaryOperator Add,
const APInt C 
)

◆ foldICmpAddOpConst()

Instruction * InstCombinerImpl::foldICmpAddOpConst ( Value X,
const APInt C,
ICmpInst::Predicate  Pred 
)

◆ foldICmpAndConstant()

Instruction * InstCombinerImpl::foldICmpAndConstant ( ICmpInst Cmp,
BinaryOperator And,
const APInt C 
)

◆ foldICmpAndConstConst()

Instruction * InstCombinerImpl::foldICmpAndConstConst ( ICmpInst Cmp,
BinaryOperator And,
const APInt C1 
)

◆ foldICmpAndShift()

Instruction * InstCombinerImpl::foldICmpAndShift ( ICmpInst Cmp,
BinaryOperator And,
const APInt C1,
const APInt C2 
)

◆ foldICmpBinOp()

Instruction * InstCombinerImpl::foldICmpBinOp ( ICmpInst I,
const SimplifyQuery SQ 
)

Try to fold icmp (binop), X or icmp X, (binop).

TODO: A large part of this logic is duplicated in InstSimplify's simplifyICmpWithBinOp(). We should be able to share that and avoid the code duplication.

Definition at line 3941 of file InstCombineCompares.cpp.

References llvm::APInt::abs(), llvm::SimplifyQuery::AC, llvm::MCID::Add, assert(), B, Builder, C1, llvm::SimplifyQuery::CxtI, D, llvm::SimplifyQuery::DL, llvm::SimplifyQuery::DT, foldICmpWithLowBitMaskedVal(), foldICmpWithTruncSignExtendedVal(), foldICmpXNegX(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), llvm::ConstantInt::get(), llvm::Constant::getAllOnesValue(), llvm::ConstantInt::getFalse(), llvm::CmpInst::getFlippedStrictnessPredicate(), llvm::APInt::getLowBitsSet(), llvm::ConstantExpr::getNeg(), llvm::Constant::getNullValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::CmpInst::getSwappedPredicate(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::SimplifyQuery::getWithInstruction(), llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::ICmpInst::isEquality(), llvm::Instruction::isExact(), llvm::isKnownNonZero(), llvm::APInt::isNegative(), llvm::CmpInst::isSigned(), llvm::CmpInst::isUnsigned(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_Neg(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Value(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), llvm::APInt::uge(), llvm::APInt::ule(), X, and Y.

◆ foldICmpBinOpEqualityWithConstant()

Instruction * InstCombinerImpl::foldICmpBinOpEqualityWithConstant ( ICmpInst Cmp,
BinaryOperator BO,
const APInt C 
)

◆ foldICmpBitCast()

Instruction * InstCombinerImpl::foldICmpBitCast ( ICmpInst Cmp)

◆ foldICmpDivConstant()

Instruction * InstCombinerImpl::foldICmpDivConstant ( ICmpInst Cmp,
BinaryOperator Div,
const APInt C 
)

◆ foldICmpEqIntrinsicWithConstant()

Instruction * InstCombinerImpl::foldICmpEqIntrinsicWithConstant ( ICmpInst ICI,
IntrinsicInst II,
const APInt C 
)

◆ foldICmpEquality()

Instruction * InstCombinerImpl::foldICmpEquality ( ICmpInst Cmp)

◆ foldICmpInstWithConstant()

Instruction * InstCombinerImpl::foldICmpInstWithConstant ( ICmpInst Cmp)

Try to fold integer comparisons with a constant operand: icmp Pred X, C where X is some kind of instruction.

Definition at line 3010 of file InstCombineCompares.cpp.

References llvm::MCID::Add, I, LLVM_FALLTHROUGH, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), and SI.

◆ foldICmpInstWithConstantNotInt()

Instruction * InstCombinerImpl::foldICmpInstWithConstantNotInt ( ICmpInst Cmp)

◆ foldICmpIntrinsicWithConstant()

Instruction * InstCombinerImpl::foldICmpIntrinsicWithConstant ( ICmpInst ICI,
IntrinsicInst II,
const APInt C 
)

◆ foldICmpMulConstant()

Instruction * InstCombinerImpl::foldICmpMulConstant ( ICmpInst Cmp,
BinaryOperator Mul,
const APInt C 
)

◆ foldICmpOrConstant()

Instruction * InstCombinerImpl::foldICmpOrConstant ( ICmpInst Cmp,
BinaryOperator Or,
const APInt C 
)

◆ foldICmpSelectConstant()

Instruction * InstCombinerImpl::foldICmpSelectConstant ( ICmpInst Cmp,
SelectInst Select,
ConstantInt C 
)

◆ foldICmpShlConstant()

Instruction * InstCombinerImpl::foldICmpShlConstant ( ICmpInst Cmp,
BinaryOperator Shl,
const APInt C 
)

◆ foldICmpShlConstConst()

Instruction * InstCombinerImpl::foldICmpShlConstConst ( ICmpInst I,
Value ShAmt,
const APInt C1,
const APInt C2 
)

Handle "(icmp eq/ne (shl AP2, A), AP1)" -> (icmp eq/ne A, TrailingZeros(AP1) - TrailingZeros(AP2)).

Definition at line 1197 of file InstCombineCompares.cpp.

References assert(), llvm::APInt::countTrailingZeros(), llvm::ConstantInt::get(), llvm::APInt::getBitWidth(), llvm::CmpInst::getInversePredicate(), llvm::Constant::getNullValue(), I, llvm::APInt::isZero(), Shift, and llvm::APInt::shl().

◆ foldICmpShrConstant()

Instruction * InstCombinerImpl::foldICmpShrConstant ( ICmpInst Cmp,
BinaryOperator Shr,
const APInt C 
)

◆ foldICmpShrConstConst()

Instruction * InstCombinerImpl::foldICmpShrConstConst ( ICmpInst I,
Value ShAmt,
const APInt C1,
const APInt C2 
)

◆ foldICmpSRemConstant()

Instruction * InstCombinerImpl::foldICmpSRemConstant ( ICmpInst Cmp,
BinaryOperator UDiv,
const APInt C 
)

◆ foldICmpSubConstant()

Instruction * InstCombinerImpl::foldICmpSubConstant ( ICmpInst Cmp,
BinaryOperator Sub,
const APInt C 
)

◆ foldICmpTruncConstant()

Instruction * InstCombinerImpl::foldICmpTruncConstant ( ICmpInst Cmp,
TruncInst Trunc,
const APInt C 
)

◆ foldICmpUDivConstant()

Instruction * InstCombinerImpl::foldICmpUDivConstant ( ICmpInst Cmp,
BinaryOperator UDiv,
const APInt C 
)

◆ foldICmpUsingKnownBits()

Instruction * InstCombinerImpl::foldICmpUsingKnownBits ( ICmpInst Cmp)

Try to fold the comparison based on range information we can get by checking whether bits are known to be zero or one in the inputs.

Definition at line 5223 of file InstCombineCompares.cpp.

References assert(), B, llvm::BitWidth, llvm::APInt::ceilLogBase2(), llvm::KnownBits::countMinTrailingZeros(), llvm::APInt::countTrailingZeros(), DL, llvm::SelectPatternResult::Flavor, llvm::ConstantInt::get(), llvm::APInt::getActiveBits(), llvm::APInt::getAllOnes(), llvm::ConstantInt::getBool(), getDemandedBitsLHSMask(), llvm::ConstantInt::getFalse(), llvm::Constant::getIntegerValue(), llvm::CmpInst::getInversePredicate(), llvm::KnownBits::getMaxValue(), llvm::KnownBits::getMinValue(), llvm::Constant::getNullValue(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::KnownBits::getSignedMaxValue(), llvm::KnownBits::getSignedMinValue(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::Type::isIntOrIntVectorTy(), llvm::SelectPatternResult::isMinOrMax(), llvm::APInt::isNegative(), llvm::APInt::isOne(), llvm::APInt::isPowerOf2(), llvm::KnownBits::isZero(), llvm_unreachable, llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_MaxOrMin(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::matchSelectPattern(), llvm::KnownBits::One, llvm::APInt::sle(), llvm::APInt::slt(), llvm::APInt::ule(), llvm::APInt::ult(), X, and llvm::KnownBits::Zero.

◆ foldICmpWithCastOp()

Instruction * InstCombinerImpl::foldICmpWithCastOp ( ICmpInst ICI)

◆ foldICmpWithConstant()

Instruction * InstCombinerImpl::foldICmpWithConstant ( ICmpInst Cmp)

Fold icmp Pred X, C.

TODO: This code structure does not make sense. The saturating add fold should be moved to some other helper and extended as noted below (it is also possible that code has been made unnecessary - do we canonicalize IR to overflow/saturating intrinsics or not?).

Definition at line 1420 of file InstCombineCompares.cpp.

References llvm::PHINode::addIncoming(), llvm::all_of(), B, Builder, llvm::ConstantExpr::getCompare(), llvm::CmpInst::ICMP_UGT, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::predecessors(), processUGT_ADDCST_ADD(), and llvm::Value::takeName().

◆ foldICmpWithDominatingICmp()

Instruction * InstCombinerImpl::foldICmpWithDominatingICmp ( ICmpInst Cmp)

◆ foldICmpWithZero()

Instruction * InstCombinerImpl::foldICmpWithZero ( ICmpInst Cmp)

◆ foldICmpXorConstant()

Instruction * InstCombinerImpl::foldICmpXorConstant ( ICmpInst Cmp,
BinaryOperator Xor,
const APInt C 
)

◆ foldIntegerTypedPHI()

Instruction * InstCombinerImpl::foldIntegerTypedPHI ( PHINode PN)

◆ foldIRemByPowerOfTwoToBitTest()

Instruction * InstCombinerImpl::foldIRemByPowerOfTwoToBitTest ( ICmpInst I)

◆ foldItoFPtoI()

Instruction * InstCombinerImpl::foldItoFPtoI ( CastInst FI)

fpto{s/u}i({u/s}itofp(X)) --> X or zext(X) or sext(X) or trunc(X) This is safe if the intermediate type has enough bits in its mantissa to accurately represent all values of X.

For example, this won't work with i64 -> float -> i64.

Definition at line 1956 of file InstCombineCasts.cpp.

References assert(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), int, isKnownExactCastIntToFP(), and X.

◆ foldMultiplicationOverflowCheck()

Value * InstCombinerImpl::foldMultiplicationOverflowCheck ( ICmpInst I)

Fold (-1 u/ x) u< y ((x * y) ?/ x) != y to @llvm.

?mul.with.overflow(x, y) plus extraction of overflow bit Note that the comparison is commutative, while inverted (u>=, ==) predicate will mean that we are looking for the opposite answer.

Definition at line 3850 of file InstCombineCompares.cpp.

References Builder, F, llvm::Intrinsic::getDeclaration(), llvm::Instruction::getOpcode(), I, llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_c_ICmp(), llvm::PatternMatch::m_c_Mul(), llvm::PatternMatch::m_CombineAnd(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_IDiv(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_UDiv(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::Mul, X, and Y.

◆ foldOpIntoPhi()

Instruction * InstCombinerImpl::foldOpIntoPhi ( Instruction I,
PHINode PN 
)

◆ FoldOpIntoSelect()

Instruction * InstCombinerImpl::FoldOpIntoSelect ( Instruction Op,
SelectInst SI 
)

Given an instruction with a select as one operand and a constant as the other operand, try to fold the binary operator into the select arguments.

This also works for Cast instructions, which obviously do not have a second operand.

Definition at line 1016 of file InstructionCombining.cpp.

References B, Builder, llvm::SelectInst::Create(), foldOperationIntoSelectOperand(), llvm::ConstantExpr::getCompare(), llvm::VectorType::getElementCount(), llvm::CmpInst::ICMP_EQ, llvm::PatternMatch::m_APIntAllowUndef(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::match(), and SI.

Referenced by foldCtpop(), and foldCttzCtlz().

◆ foldPHIArgBinOpIntoPHI()

Instruction * InstCombinerImpl::foldPHIArgBinOpIntoPHI ( PHINode PN)

◆ foldPHIArgExtractValueInstructionIntoPHI()

Instruction * InstCombinerImpl::foldPHIArgExtractValueInstructionIntoPHI ( PHINode PN)

If we have something like phi [extractvalue(a,0), extractvalue(b,0)], turn this into a phi[a,b] and a single extractvalue.

Definition at line 368 of file InstCombinePHI.cpp.

References llvm::PHINode::blocks(), llvm::ExtractValueInst::Create(), llvm::PHINode::Create(), llvm::PHINode::getIncomingValue(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), i, I, llvm::PHINode::incoming_values(), and llvm::zip().

◆ foldPHIArgGEPIntoPHI()

Instruction * InstCombinerImpl::foldPHIArgGEPIntoPHI ( PHINode PN)

◆ foldPHIArgInsertValueInstructionIntoPHI()

Instruction * InstCombinerImpl::foldPHIArgInsertValueInstructionIntoPHI ( PHINode PN)

If we have something like phi [insertvalue(a,b,0), insertvalue(c,d,0)], turn this into a phi[a,c] and phi[b,d] and a single insertvalue.

Definition at line 328 of file InstCombinePHI.cpp.

References llvm::PHINode::blocks(), llvm::InsertValueInst::Create(), llvm::PHINode::Create(), llvm::PHINode::getIncomingValue(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), i, I, llvm::PHINode::incoming_values(), and llvm::zip().

◆ foldPHIArgIntToPtrToPHI()

Instruction * InstCombinerImpl::foldPHIArgIntToPtrToPHI ( PHINode PN)

◆ foldPHIArgLoadIntoPHI()

Instruction * InstCombinerImpl::foldPHIArgLoadIntoPHI ( PHINode PN)

◆ foldPHIArgOpIntoPHI()

Instruction * InstCombinerImpl::foldPHIArgOpIntoPHI ( PHINode PN)

Try to rotate an operation below a PHI node, using PHI nodes for its operands.

If all operands to a PHI node are the same "unary" operator and they all are only used by the PHI, PHI together their inputs, and do the operation once, to the result of the PHI.

Definition at line 846 of file InstCombinePHI.cpp.

References llvm::PHINode::addIncoming(), llvm::BinaryOperator::Create(), llvm::CastInst::Create(), llvm::CmpInst::Create(), llvm::PHINode::Create(), llvm::numbers::e, llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), llvm::CmpInst::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::CmpInst::getPredicate(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), i, I, and llvm::Type::isIntegerTy().

◆ foldPHIArgZextsIntoPHI()

Instruction * InstCombinerImpl::foldPHIArgZextsIntoPHI ( PHINode Phi)

TODO: This function could handle other cast types, but then it might require special-casing a cast from the 'i1' type.

See the comment in FoldPHIArgOpIntoPHI() about pessimizing illegal integer types.

Definition at line 772 of file InstCombinePHI.cpp.

References llvm::PHINode::addIncoming(), llvm::PHINode::Create(), llvm::CastInst::CreateZExtOrBitCast(), llvm::PHINode::getIncomingBlock(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), llvm::Instruction::getParent(), llvm::BasicBlock::getTerminator(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::ConstantExpr::getZExt(), i, and llvm::PHINode::incoming_values().

◆ foldSelectExtConst()

Instruction* llvm::InstCombinerImpl::foldSelectExtConst ( SelectInst Sel)

◆ foldSelectInstWithICmp()

Instruction* llvm::InstCombinerImpl::foldSelectInstWithICmp ( SelectInst SI,
ICmpInst ICI 
)

◆ foldSelectIntoOp()

Instruction * InstCombinerImpl::foldSelectIntoOp ( SelectInst SI,
Value TrueVal,
Value FalseVal 
)

◆ foldSelectOpOp()

Instruction * InstCombinerImpl::foldSelectOpOp ( SelectInst SI,
Instruction TI,
Instruction FI 
)

◆ foldSelectValueEquivalence()

Instruction* llvm::InstCombinerImpl::foldSelectValueEquivalence ( SelectInst SI,
ICmpInst ICI 
)

◆ FoldShiftByConstant()

Instruction * InstCombinerImpl::FoldShiftByConstant ( Value Op0,
Constant Op1,
BinaryOperator I 
)

◆ foldSignBitTest()

Instruction * InstCombinerImpl::foldSignBitTest ( ICmpInst I)

◆ foldSPFofSPF()

Instruction* llvm::InstCombinerImpl::foldSPFofSPF ( Instruction Inner,
SelectPatternFlavor  SPF1,
Value A,
Value B,
Instruction Outer,
SelectPatternFlavor  SPF2,
Value C 
)

◆ foldVariableSignZeroExtensionOfVariableHighBitExtract()

Instruction * InstCombinerImpl::foldVariableSignZeroExtensionOfVariableHighBitExtract ( BinaryOperator OldAShr)

◆ foldVectorBinop()

Instruction * InstCombinerImpl::foldVectorBinop ( BinaryOperator Inst)

◆ foldVectorSelect()

Instruction* llvm::InstCombinerImpl::foldVectorSelect ( SelectInst Sel)

◆ freezeDominatedUses()

bool InstCombinerImpl::freezeDominatedUses ( FreezeInst FI)

Definition at line 3606 of file InstructionCombining.cpp.

References llvm::User::getOperand().

◆ InsertNewInstBefore()

Instruction* llvm::InstCombinerImpl::InsertNewInstBefore ( Instruction New,
Instruction Old 
)
inline

Inserts an instruction New before instruction Old.

Also adds the new instruction to the worklist and returns New so that it is suitable for use as the return from the visitation patterns.

Definition at line 378 of file InstCombineInternal.h.

References assert(), BB, llvm::ilist_node_impl< OptionsT >::getIterator(), and llvm::Instruction::getParent().

Referenced by foldSelectZeroOrMul(), and simplifyAllocaArraySize().

◆ InsertNewInstWith()

Instruction* llvm::InstCombinerImpl::InsertNewInstWith ( Instruction New,
Instruction Old 
)
inline

Same as InsertNewInstBefore, but also sets the debug loc.

Definition at line 388 of file InstCombineInternal.h.

References llvm::Instruction::getDebugLoc().

Referenced by replaceExtractElements().

◆ insertRangeTest()

Value * InstCombinerImpl::insertRangeTest ( Value V,
const APInt Lo,
const APInt Hi,
bool  isSigned,
bool  Inside 
)

Emit a computation of: (V >= Lo && V < Hi) if Inside is true, otherwise (V < Lo || V >= Hi).

This method expects that Lo < Hi. IsSigned indicates whether to treat V, Lo, and Hi as signed or not.

Definition at line 120 of file InstCombineAndOrXor.cpp.

References assert(), Builder, llvm::ConstantInt::get(), llvm::Value::getName(), llvm::ICmpInst::getSignedPredicate(), llvm::Value::getType(), llvm::MipsISD::Hi, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_ULT, and llvm::MipsISD::Lo.

◆ isKnownToBeAPowerOfTwo()

bool llvm::InstCombinerImpl::isKnownToBeAPowerOfTwo ( const Value V,
bool  OrZero = false,
unsigned  Depth = 0,
const Instruction CxtI = nullptr 
)
inline

Definition at line 474 of file InstCombineInternal.h.

References llvm::Depth, DL, and llvm::isKnownToBeAPowerOfTwo().

Referenced by simplifyValueKnownNonZero().

◆ MaskedValueIsZero()

bool llvm::InstCombinerImpl::MaskedValueIsZero ( const Value V,
const APInt Mask,
unsigned  Depth = 0,
const Instruction CxtI = nullptr 
) const
inline

◆ matchBSwapOrBitReverse()

Instruction * InstCombinerImpl::matchBSwapOrBitReverse ( Instruction I,
bool  MatchBSwaps,
bool  MatchBitReversals 
)

Given an initial instruction, check to see if it is the root of a bswap/bitreverse idiom.

If so, return the equivalent bswap/bitreverse intrinsic.

Definition at line 2104 of file InstCombineAndOrXor.cpp.

References I, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::recognizeBSwapOrBitReverseIdiom(), and llvm::Instruction::removeFromParent().

◆ matchThreeWayIntCompare()

bool InstCombinerImpl::matchThreeWayIntCompare ( SelectInst SI,
Value *&  LHS,
Value *&  RHS,
ConstantInt *&  Less,
ConstantInt *&  Equal,
ConstantInt *&  Greater 
)

Match a select chain which produces one of three values based on whether the LHS is less than, equal to, or greater than RHS respectively.

Return true if we matched a three way compare idiom. The LHS, RHS, Less, Equal and Greater values are saved in the matching process and returned to the caller.

Definition at line 2755 of file InstCombineCompares.cpp.

References assert(), llvm::object::Equal, llvm::InstCombiner::getFlippedStrictnessPredicateAndConstant(), llvm::CmpInst::getSwappedPredicate(), llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::ICmpInst::isEquality(), llvm::CodeGenOpt::Less, llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), SI, and std::swap().

◆ mergeStoreIntoSuccessor()

bool InstCombinerImpl::mergeStoreIntoSuccessor ( StoreInst SI)

◆ OptimizePointerDifference()

Value * InstCombinerImpl::OptimizePointerDifference ( Value LHS,
Value RHS,
Type Ty,
bool  IsNUW 
)

Optimize pointer differences into the same array into a size.

Consider: &A[10] - &A[0]: we should compile this to "10". LHS/RHS are the pointer operands to the ptrtoint instructions for the LHS/RHS of the subtract.

Definition at line 1667 of file InstCombineAddSub.cpp.

References Builder, llvm::GEPOperator::countNonConstantIndices(), llvm::EmitGEPOffset(), llvm::Value::hasOneUse(), I, llvm::GEPOperator::isInBounds(), Offset, and std::swap().

◆ PHIArgMergedDebugLoc()

void InstCombinerImpl::PHIArgMergedDebugLoc ( Instruction Inst,
PHINode PN 
)

Helper function for FoldPHIArgXIntoPHI() to set debug location for the folded operation.

The PHI arguments will be folded into a single operation with a PHI node as input.

The debug location of the single operation will be the merged locations of the original PHI node arguments.

Definition at line 42 of file InstCombinePHI.cpp.

References llvm::Instruction::applyMergedLocation(), assert(), llvm::Instruction::getDebugLoc(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), i, I, and llvm::Instruction::setDebugLoc().

◆ PromoteCastOfAllocation()

Instruction * InstCombinerImpl::PromoteCastOfAllocation ( BitCastInst CI,
AllocaInst AI 
)

◆ pushFreezeToPreventPoisonFromPropagating()

Value * InstCombinerImpl::pushFreezeToPreventPoisonFromPropagating ( FreezeInst FI)

◆ reassociateShiftAmtsOfTwoSameDirectionShifts()

Value * InstCombinerImpl::reassociateShiftAmtsOfTwoSameDirectionShifts ( BinaryOperator Sh0,
const SimplifyQuery SQ,
bool  AnalyzeForSignBitExtraction = false 
)

◆ replacedSelectWithOperand()

bool InstCombinerImpl::replacedSelectWithOperand ( SelectInst SI,
const ICmpInst Icmp,
const unsigned  SIOpd 
)

Try to replace select with select operand SIOpd in SI-ICmp sequence.

True when a select result is replaced by one of its operands in select-icmp sequence.

This will eventually result in the elimination of the select.

Parameters
SISelect instruction
IcmpCompare instruction
SIOpdOperand that replaces the select

Notes:

  • The replacement is global and requires dominator information
  • The caller is responsible for the actual replacement

Example:

entry: %4 = select i1 %3, C* %0, C* null %5 = icmp eq C* %4, null br i1 %5, label %9, label %7 ... ; <label>:7 ; preds = entry %8 = getelementptr inbounds C* %4, i64 0, i32 0 ...

can be transformed to

%5 = icmp eq C* %0, null %6 = select i1 %3, i1 %5, i1 true br i1 %6, label %9, label %7 ... ; <label>:7 ; preds = entry %8 = getelementptr inbounds C* %0, i64 0, i32 0 // replace by %0!

Similar when the first operand of the select is a constant or/and the compare is for not equal rather than equal.

NOTE: The function is only called when the select and compare constants are equal, the optimization can work only for EQ predicates. This is not a major restriction since a NE compare should be 'normalized' to an equal compare, which usually happens in the combiner and test case select-cmp-br.ll checks for it.

Definition at line 5195 of file InstCombineCompares.cpp.

References assert(), llvm::CmpInst::getPredicate(), llvm::BasicBlock::getSinglePredecessor(), llvm::CmpInst::ICMP_EQ, isChainSelectCmpBranch(), and SI.

◆ replaceInstUsesWith()

Instruction* llvm::InstCombinerImpl::replaceInstUsesWith ( Instruction I,
Value V 
)
inline

A combiner-aware RAUW-like routine.

This method is to be used when an instruction is found to be dead, replaceable with another preexisting expression. Here we add all uses of I to the worklist, replace all uses of I with the new value, then return I, so that the inst combiner will know that I was modified.

Definition at line 399 of file InstCombineInternal.h.

References llvm::dbgs(), llvm::UndefValue::get(), I, and LLVM_DEBUG.

Referenced by foldCtpop(), foldCttzCtlz(), foldSelectZeroOrMul(), processUGT_ADDCST_ADD(), processUMulZExtIdiom(), removeBitcastsFromLoadStoreOnMinMax(), replaceExtractElements(), simplifyAllocaArraySize(), and unpackLoadToAggregate().

◆ replaceOperand()

Instruction* llvm::InstCombinerImpl::replaceOperand ( Instruction I,
unsigned  OpNum,
Value V 
)
inline

◆ replaceUse()

void llvm::InstCombinerImpl::replaceUse ( Use U,
Value NewValue 
)
inline

Replace use and add the previously used value to the worklist.

Definition at line 427 of file InstCombineInternal.h.

◆ run()

bool InstCombinerImpl::run ( )

◆ SimplifyAddWithRemainder()

Value * InstCombinerImpl::SimplifyAddWithRemainder ( BinaryOperator I)

Tries to simplify add operations using the definition of remainder.

The definition of remainder is X % C = X - (X / C ) * C. The add expression X % C0 + (( X / C0 ) % C1) * C0 can be simplified to X % (C0 * C1)

Definition at line 1073 of file InstCombineAddSub.cpp.

References Builder, C1, llvm::ConstantInt::get(), I, MatchDiv(), MatchMul(), MatchRem(), MulWillOverflow(), and X.

◆ SimplifyAnyMemSet()

Instruction * InstCombinerImpl::SimplifyAnyMemSet ( AnyMemSetInst MI)

◆ SimplifyAnyMemTransfer()

Instruction * InstCombinerImpl::SimplifyAnyMemTransfer ( AnyMemTransferInst MI)

◆ SimplifyAssociativeOrCommutative()

bool InstCombinerImpl::SimplifyAssociativeOrCommutative ( BinaryOperator I)

Performs a few simplifications for operators which are associative or commutative.

This performs a few simplifications for operators that are associative or commutative:

Commutative operators:

  1. Order operands such that they are listed from right (least complex) to left (most complex). This puts constants before unary operators before binary operators.

Associative operators:

  1. Transform: "(A op B) op C" ==> "A op (B op C)" if "B op C" simplifies.
  2. Transform: "A op (B op C)" ==> "(A op B) op C" if "A op B" simplifies.

Associative and commutative operators:

  1. Transform: "(A op B) op C" ==> "(C op A) op B" if "C op A" simplifies.
  2. Transform: "A op (B op C)" ==> "B op (C op A)" if "C op A" simplifies.
  3. Transform: "(A op C1) op (B op C2)" ==> "(A op B) op (C1 op C2)" if C1 and C2 are constants.

Definition at line 403 of file InstructionCombining.cpp.

References llvm::MCID::Add, B, C1, ClearSubclassDataAfterReassociation(), llvm::BinaryOperator::Create(), llvm::BinaryOperator::CreateNUW(), llvm::ConstantExpr::get(), llvm::Instruction::getFastMathFlags(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), hasNoSignedWrap(), hasNoUnsignedWrap(), I, llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), maintainNoSignedWrap(), llvm::PatternMatch::match(), llvm::Instruction::setFastMathFlags(), simplifyAssocCastAssoc(), llvm::SimplifyBinOp(), and llvm::Value::takeName().

◆ SimplifyDemandedBits()

bool InstCombinerImpl::SimplifyDemandedBits ( Instruction I,
unsigned  OpNo,
const APInt DemandedMask,
KnownBits Known,
unsigned  Depth = 0 
)
overridevirtual

This form of SimplifyDemandedBits simplifies the specified instruction operand if possible, updating it in place.

It returns true if it made any change and false otherwise.

Implements llvm::InstCombiner.

Definition at line 71 of file InstCombineSimplifyDemanded.cpp.

References llvm::Depth, llvm::Use::get(), I, and llvm::salvageDebugInfo().

◆ SimplifyDemandedInstructionBits()

bool InstCombinerImpl::SimplifyDemandedInstructionBits ( Instruction Inst)

Tries to simplify operands to an integer instruction based on its demanded bits.

Inst is an integer instruction that SimplifyDemandedBits knows about.

See if the instruction has any properties that allow us to simplify its operands.

Definition at line 55 of file InstCombineSimplifyDemanded.cpp.

References llvm::BitWidth, llvm::APInt::getAllOnes(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().

◆ SimplifyDemandedUseBits()

Value * InstCombinerImpl::SimplifyDemandedUseBits ( Value V,
APInt  DemandedMask,
KnownBits Known,
unsigned  Depth,
Instruction CxtI 
)

Attempts to replace V with a simpler value based on the demanded bits.

This function attempts to replace V with a simpler value based on the demanded bits.

When this function is called, it is known that only the bits set in DemandedMask of the result of V are ever used downstream. Consequently, depending on the mask and V, it may be possible to replace V with a constant or one of its operands. In such cases, this function does the replacement and returns true. In all other cases, it returns false after analyzing the expression and setting KnownOne and known to be one in the expression. Known.Zero contains all the bits that are known to be zero in the expression. These are provided to potentially allow the caller (which might recursively be SimplifyDemandedBits itself) to simplify the expression. Known.One and Known.Zero always follow the invariant that: Known.One & Known.Zero == 0. That is, a bit can't be both 1 and 0. Note that the bits in Known.One and Known.Zero may only be accurate for those bits set in DemandedMask. Note also that the bitwidth of V, DemandedMask, Known.Zero and Known.One must all be the same.

This returns null if it did not change anything and it permits no simplification. This returns V itself if it did some simplification of V's operands based on the information about what bits are demanded. This returns some other non-null value if it found out that V is equal to another value in the context where the specified bits are demanded, but not for all users.

If the high-bits of an ADD/SUB are not demanded, then we do not care about the high bits of the operands.

Definition at line 108 of file InstCombineSimplifyDemanded.cpp.

References llvm::abs(), llvm::APInt::abs(), llvm::MCID::Add, llvm::And, assert(), llvm::BitWidth, Builder, llvm::MCID::Call, llvm::KnownBits::commonBits(), llvm::KnownBits::computeForAddSub(), llvm::computeKnownBits(), llvm::ComputeNumSignBits(), llvm::APInt::countLeadingZeros(), llvm::KnownBits::countMinLeadingZeros(), llvm::APInt::countTrailingZeros(), llvm::CallInst::Create(), llvm::ISD::CTLZ, llvm::Depth, llvm::SelectPatternResult::Flavor, llvm::ConstantInt::get(), llvm::UndefValue::get(), llvm::APInt::getActiveBits(), llvm::APInt::getAllOnes(), llvm::Constant::getAllOnesValue(), llvm::KnownBits::getBitWidth(), llvm::APInt::getBitWidth(), llvm::Intrinsic::getDeclaration(), llvm::APInt::getHighBitsSet(), llvm::Constant::getIntegerValue(), llvm::APInt::getLimitedValue(), llvm::APInt::getLowBitsSet(), llvm::Type::getScalarSizeInBits(), llvm::APInt::getSignMask(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::Optional< T >::getValue(), llvm::KnownBits::hasConflict(), llvm::OverflowingBinaryOperator::hasNoSignedWrap(), llvm::OverflowingBinaryOperator::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), llvm::Optional< T >::hasValue(), I, llvm::APInt::intersects(), llvm::Type::isIntOrIntVectorTy(), llvm::ConstantInt::isMinusOne(), llvm::KnownBits::isNonNegative(), llvm::APInt::isOne(), llvm::APInt::isSignBitSet(), llvm::APInt::isSignMask(), llvm::APInt::isSubsetOf(), llvm::APInt::isZero(), LLVM_FALLTHROUGH, llvm::APInt::lshr(), llvm::APInt::lshrInPlace(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::KnownBits::makeNonNegative(), llvm::PatternMatch::match(), llvm::matchSelectPattern(), llvm::MaxAnalysisRecursionDepth, llvm::min(), llvm::KnownBits::One, llvm::Or, RA, llvm::KnownBits::resetAll(), llvm::MCID::Select, llvm::APInt::setAllBits(), llvm::APInt::setBit(), llvm::Instruction::setHasNoSignedWrap(), llvm::Instruction::setHasNoUnsignedWrap(), llvm::APInt::setHighBits(), llvm::Instruction::setIsExact(), llvm::APInt::setLowBits(), llvm::APInt::setSignBit(), llvm::KnownBits::sext(), llvm::APInt::shl(), ShrinkDemandedConstant(), llvm::SPF_UMAX, llvm::SPF_UMIN, llvm::SPF_UNKNOWN, llvm::Value::takeName(), llvm::APInt::trunc(), llvm::APInt::ult(), llvm::APIntOps::umax(), llvm::APIntOps::umin(), llvm::APInt::urem(), X, llvm::Xor, Y, llvm::KnownBits::Zero, llvm::KnownBits::zextOrTrunc(), and llvm::APInt::zextOrTrunc().

◆ SimplifyDemandedVectorElts()

Value * InstCombinerImpl::SimplifyDemandedVectorElts ( Value V,
APInt  DemandedElts,
APInt UndefElts,
unsigned  Depth = 0,
bool  AllowMultipleUsers = false 
)
overridevirtual

The specified value produces a vector with any number of elements.

This method analyzes which elements of the operand are undef or poison and returns that information in UndefElts.

DemandedElts contains the set of elements that are actually used by the caller, and by default (AllowMultipleUsers equals false) the value is simplified only if it has a single caller. If AllowMultipleUsers is set to true, DemandedElts refers to the union of sets of elements that are used by all callers.

If the information about demanded elements can be used to simplify the operation, the operation is simplified, then the resultant value is returned. This returns null if no change was made.

Implements llvm::InstCombiner.

Definition at line 1120 of file InstCombineSimplifyDemanded.cpp.

References llvm::all_of(), assert(), llvm::MCID::Call, llvm::APInt::clearAllBits(), llvm::APInt::clearBit(), llvm::APInt::countPopulation(), llvm::InsertElementInst::Create(), llvm::Depth, llvm::Instruction::dropPoisonGeneratingFlags(), E, GEP, llvm::gep_type_begin(), llvm::gep_type_end(), llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::PoisonValue::get(), llvm::Constant::getAggregateElement(), llvm::APInt::getAllOnes(), llvm::SelectInst::getCondition(), llvm::Type::getInt32Ty(), llvm::IntrinsicInst::getIntrinsicID(), llvm::Value::getName(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Optional< T >::getValue(), llvm::ConstantInt::getZExtValue(), llvm::Value::hasOneUse(), llvm::Optional< T >::hasValue(), i, I, llvm::APInt::isAllOnes(), llvm::Constant::isAllOnesValue(), llvm::Instruction::isIntDivRem(), llvm::Constant::isNullValue(), llvm::Instruction::isShift(), llvm::Type::isVectorTy(), llvm::APInt::isZero(), llvm_unreachable, llvm::APInt::lshr(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_ExtractElt(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::MCID::Select, llvm::APInt::setBit(), llvm::RegState::Undef, llvm::UndefMaskElem, and llvm::APInt::zextOrTrunc().

◆ simplifyDivRemOfSelectWithZeroOp()

bool InstCombinerImpl::simplifyDivRemOfSelectWithZeroOp ( BinaryOperator I)

Fold a divide or remainder with a select instruction divisor when one of the select operands is zero.

In that case, we can use the other select operand because div/rem by zero is undefined.

Definition at line 644 of file InstCombineMulDivRem.cpp.

References llvm::ConstantInt::getFalse(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::Value::hasOneUse(), I, llvm::isGuaranteedToTransferExecutionToSuccessor(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), and SI.

◆ SimplifyMultipleUseDemandedBits()

Value * InstCombinerImpl::SimplifyMultipleUseDemandedBits ( Instruction I,
const APInt DemandedMask,
KnownBits Known,
unsigned  Depth,
Instruction CxtI 
)

Helper routine of SimplifyDemandedUseBits.

It computes KnownZero/KnownOne bits. It also tries to handle simplifications that can be done based on DemandedMask, but without modifying the Instruction.

It computes Known bits. It also tries to handle simplifications that can be done based on DemandedMask, but without modifying the Instruction.

Definition at line 899 of file InstCombineSimplifyDemanded.cpp.

References llvm::BitWidth, llvm::computeKnownBits(), llvm::Depth, llvm::APInt::getBitWidth(), llvm::Constant::getIntegerValue(), llvm::APInt::getLowBitsSet(), llvm::APInt::getZExtValue(), I, llvm::APInt::isSubsetOf(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::KnownBits::One, llvm::APInt::ult(), X, and llvm::KnownBits::Zero.

◆ simplifyRangeCheck()

Value * InstCombinerImpl::simplifyRangeCheck ( ICmpInst Cmp0,
ICmpInst Cmp1,
bool  Inverted 
)

Try to fold a signed range checked with lower bound 0 to an unsigned icmp.

Example: (icmp sge x, 0) & (icmp slt x, n) --> icmp ult x, n If Inverted is true then the check is for the inverted range, e.g. (icmp slt x, 0) | (icmp sgt x, n) --> icmp ugt x, n

Definition at line 688 of file InstCombineAndOrXor.cpp.

References Builder, llvm::computeKnownBits(), llvm::CmpInst::getInversePredicate(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::CmpInst::getSwappedPredicate(), llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::ConstantInt::isMinusOne(), llvm::KnownBits::isNonNegative(), and llvm::ConstantInt::isZero().

◆ SimplifySelectsFeedingBinaryOp()

Value * InstCombinerImpl::SimplifySelectsFeedingBinaryOp ( BinaryOperator I,
Value LHS,
Value RHS 
)

◆ simplifyShrShlDemandedBits()

Value * InstCombinerImpl::simplifyShrShlDemandedBits ( Instruction Shr,
const APInt ShrOp1,
Instruction Shl,
const APInt ShlOp1,
const APInt DemandedMask,
KnownBits Known 
)

Helper routine of SimplifyDemandedUseBits.

It tries to simplify demanded bit for "r1 = shr x, c1; r2 = shl r1, c2" instruction sequence.

It tries to simplify "E1 = (X lsr C1) << C2", where the C1 and C2 are constant, into "E2 = X << (C2 - C1)" or "E2 = X >> (C1 - C2)", depending on the sign of "C2-C1".

Suppose E1 and E2 are generally different in bits S={bm, bm+1, ..., bn}, without considering the specific value X is holding. This transformation is legal iff one of following conditions is hold: 1) All the bit in S are 0, in this case E1 == E2. 2) We don't care those bits in S, per the input DemandedMask. 3) Combination of 1) and 2). Some bits in S are 0, and we don't care the rest bits.

Currently we only test condition 2).

As with SimplifyDemandedUseBits, it returns NULL if the simplification was not successful.

Definition at line 1045 of file InstCombineSimplifyDemanded.cpp.

References llvm::APInt::ashr(), llvm::BitWidth, llvm::APInt::clearAllBits(), llvm::ConstantInt::get(), llvm::APInt::getAllOnes(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::APInt::getZExtValue(), llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), llvm::APInt::lshr(), llvm::KnownBits::One, llvm::APInt::setLowBits(), llvm::APInt::uge(), and llvm::KnownBits::Zero.

◆ SimplifyUsingDistributiveLaws()

Value * InstCombinerImpl::SimplifyUsingDistributiveLaws ( BinaryOperator I)

Tries to simplify binary operations which some other binary operation distributes over.

This tries to simplify binary operations which some other binary operation distributes over either by factorizing out common terms (eg "(A*B)+(A*C)" -> "A*(B+C)") or expanding out if this results in simplifications (eg: "A & (B | C) -> (A&B) | (A&C)" if this is a win).

It does this by either by factorizing out common terms (eg "(A*B)+(A*C)" -> "A*(B+C)") or expanding out if this results in simplifications (eg: "A & (B | C) -> (A&B) | (A&C)" if this is a win). Returns the simplified value, or null if it didn't simplify.

Returns the simplified value, or null if it didn't simplify.

Definition at line 737 of file InstructionCombining.cpp.

References B, Builder, D, llvm::ConstantExpr::getBinOpIdentity(), getBinOpsForFactorization(), getIdentityValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), I, leftDistributesOverRight(), rightDistributesOverLeft(), and llvm::SimplifyBinOp().

◆ sinkNotIntoOtherHandOfAndOrOr()

bool InstCombinerImpl::sinkNotIntoOtherHandOfAndOrOr ( BinaryOperator I)

◆ SliceUpIllegalIntegerPHI()

Instruction * InstCombinerImpl::SliceUpIllegalIntegerPHI ( PHINode FirstPhi)

This is an integer PHI and we know that it has an illegal type: see if it is only used by trunc or trunc(lshr) operations.

If so, we split the PHI into the various pieces being extracted. This sort of thing is introduced when SROA promotes an aggregate to large integer values.

TODO: The user of the trunc may be an bitcast to float/double/vector or an inttoptr. We should produce new PHIs in the right type.

Definition at line 1077 of file InstCombinePHI.cpp.

References llvm::PHINode::addIncoming(), llvm::array_pod_sort(), assert(), Builder, llvm::SmallVectorImpl< T >::clear(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::PHINode::Create(), llvm::dbgs(), llvm::numbers::e, llvm::find(), llvm::ConstantInt::get(), llvm::PoisonValue::get(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::Type::getScalarSizeInBits(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::Value::hasOneUse(), i, llvm::SmallPtrSetImpl< PtrType >::insert(), LLVM_DEBUG, Offset, Shift, llvm::Instruction::user_back(), and llvm::Value::users().

◆ tryFactorization()

Value * InstCombinerImpl::tryFactorization ( BinaryOperator I,
Instruction::BinaryOps  InnerOpcode,
Value A,
Value B,
Value C,
Value D 
)

◆ visitAdd()

Instruction * InstCombinerImpl::visitAdd ( BinaryOperator I)

◆ visitAddrSpaceCast()

Instruction * InstCombinerImpl::visitAddrSpaceCast ( AddrSpaceCastInst CI)

◆ visitAllocaInst()

Instruction * InstCombinerImpl::visitAllocaInst ( AllocaInst AI)

◆ visitAllocSite()

Instruction * InstCombinerImpl::visitAllocSite ( Instruction FI)

◆ visitAnd()

Instruction * InstCombinerImpl::visitAnd ( BinaryOperator I)

◆ visitAShr()

Instruction * InstCombinerImpl::visitAShr ( BinaryOperator I)

◆ visitAtomicRMWInst()

Instruction * InstCombinerImpl::visitAtomicRMWInst ( AtomicRMWInst SI)

◆ visitBitCast()

Instruction * InstCombinerImpl::visitBitCast ( BitCastInst CI)

◆ visitBranchInst()

Instruction * InstCombinerImpl::visitBranchInst ( BranchInst BI)

◆ visitCallBrInst()

Instruction * InstCombinerImpl::visitCallBrInst ( CallBrInst CBI)

Definition at line 2377 of file InstCombineCalls.cpp.

◆ visitCallInst()

Instruction * InstCombinerImpl::visitCallInst ( CallInst CI)

CallInst simplification.

This mostly only handles folding of intrinsic instructions. For normal calls, it allows visitCallBase to do the heavy lifting.

This will remove the boolean Condition from the assume given as argument and remove the assume if it becomes useless. always returns nullptr for use as a return values.

Note: this doesn't preserve the offset information but merges offset and alignment. TODO: we can generate a GEP instead of merging the alignment with the offset.

Canonicalize Knowledge in operand bundles.

Definition at line 897 of file InstCombineCalls.cpp.

References llvm::abs(), llvm::SmallBitVector::all(), llvm::AlwaysOverflowsHigh, llvm::AlwaysOverflowsLow, llvm::Instruction::andIRFlags(), Arg, llvm::RetainedKnowledge::ArgValue, assert(), llvm::RetainedKnowledge::AttrKind, B, llvm::BitWidth, llvm::buildAssumeFromKnowledge(), Builder, llvm::CallBase::bundle_op_info_begin(), C1, canonicalizeConstantArg0ToArg1(), ceil, llvm::computeKnownBits(), Cond, llvm::Constant::containsConstantExpression(), llvm::Instruction::copyFastMathFlags(), llvm::Instruction::copyIRFlags(), llvm::CastInst::Create(), llvm::CallInst::Create(), llvm::SelectInst::Create(), llvm::BinaryOperator::CreateFDivFMF(), llvm::BinaryOperator::CreateFMulFMF(), llvm::CastInst::CreateIntegerCast(), llvm::BinaryOperator::CreateNeg(), llvm::BinaryOperator::CreateNot(), llvm::BinaryOperator::CreateNSW(), llvm::BinaryOperator::CreateNSWNeg(), llvm::BinaryOperator::CreateNUW(), llvm::UnaryOperator::CreateWithCopiedFlags(), llvm::BinaryOperator::CreateWithCopiedFlags(), llvm::Data, DL, llvm::Function::doesNotThrow(), llvm::CallBase::doesNotThrow(), llvm::Value::dropDroppableUse(), llvm::EnableKnowledgeRetention, factorizeMinMaxTree(), llvm::FAdd, floor, foldClampRangeOfTwo(), foldCtpop(), foldCttzCtlz(), llvm::ConstantInt::get(), llvm::ConstantFP::get(), llvm::ConstantAggregateZero::get(), llvm::MDNode::get(), llvm::APInt::getAllOnes(), llvm::Constant::getAllOnesValue(), llvm::CallBase::getArgOperand(), llvm::ConstantInt::getBool(), llvm::CallBase::getCalledFunction(), llvm::CallBase::getCalledOperand(), llvm::Value::getContext(), llvm::Intrinsic::getDeclaration(), llvm::Instruction::getFastMathFlags(), llvm::Instruction::getFunction(), llvm::CallBase::getFunctionType(), llvm::ConstantExpr::getICmp(), llvm::Type::getInt64Ty(), llvm::ConstantExpr::getIntegerCast(), llvm::IntrinsicInst::getIntrinsicID(), llvm::getInverseMinMaxIntrinsic(), llvm::getKnowledgeFromBundle(), getKnownSign(), llvm::APInt::getLowBitsSet(), llvm::APSInt::getMaxValue(), llvm::APSInt::getMinValue(), llvm::Instruction::getModule(), llvm::ConstantExpr::getMul(), llvm::Value::getName(), llvm::ConstantExpr::getNeg(), llvm::Instruction::getNextNonDebugInstruction(), llvm::Constant::getNullValue(), llvm::CallBase::getNumOperandBundles(), llvm::Instruction::getOpcode(), getOpcode(), llvm::CallBase::getOperandBundlesAsDefs(), llvm::User::getOperandUse(), llvm::Instruction::getParent(), llvm::Type::getScalarSizeInBits(), llvm::ConstantExpr::getSExt(), llvm::ConstantExpr::getSub(), llvm::BasicBlock::getTerminator(), llvm::ConstantInt::getTrue(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::ConstantExpr::getURem(), llvm::Optional< T >::getValue(), llvm::ConstantExpr::getZExt(), GuardWideningWindow, llvm::Instruction::hasAllowReassoc(), llvm::Function::hasFnAttribute(), llvm::Value::hasOneUse(), llvm::CallBase::hasOperandBundles(), llvm::Optional< T >::hasValue(), i, I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_UGT, llvm::KnownBits::isAllOnes(), llvm::isAssumeWithEmptyBundle(), llvm::IntrinsicInst::isCommutative(), llvm::Instruction::isFast(), llvm::isFreeCall(), llvm::isKnownNegation(), llvm::APInt::isNonNegative(), llvm::Type::isPointerTy(), llvm::isPowerOf2_32(), llvm::isPowerOf2_64(), llvm::isSafeToSpeculativelyExecute(), llvm::isSplatValue(), llvm::isValidAssumeForContext(), LLVM_FALLTHROUGH, llvm_unreachable, llvm::SPII::Load, llvm::Log2_32_Ceil(), llvm::lowerObjectSizeCall(), M, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APFloat(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_BSwap(), llvm::PatternMatch::m_Cmp(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_FAbs(), llvm::PatternMatch::m_FNeg(), llvm::PatternMatch::m_FPExt(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_LogicalAnd(), llvm::PatternMatch::m_LogicalOr(), llvm::PatternMatch::m_Neg(), llvm::PatternMatch::m_NegZeroFP(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_NSWAdd(), llvm::PatternMatch::m_NSWNeg(), llvm::PatternMatch::m_NUWAdd(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_PosZeroFP(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shuffle(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_SRem(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_UnOp(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::m_ZeroInt(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::m_ZExtOrSExtOrSelf(), llvm::CmpInst::makeCmpResultType(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), maximum, llvm::maximum(), llvm::maxnum(), llvm::MayOverflow, memcpy(), MI, llvm::MinAlign(), minimum, llvm::minimum(), llvm::minnum(), Mod, moveAddAfterMinMax(), llvm::Instruction::moveBefore(), llvm::Mul, llvm::NeverOverflows, llvm::None, llvm::FastMathFlags::noSignedZeros(), Offset, llvm::User::op_begin(), llvm::ISD::OR, Other, powi(), removeTriviallyEmptyRange(), round(), llvm::APInt::sadd_ov(), llvm::Use::set(), llvm::SmallBitVector::set(), llvm::CallBase::setCalledFunction(), llvm::CallBase::setDoesNotThrow(), llvm::Instruction::setMetadata(), SI, llvm::SignBitMustBeZero(), llvm::SimplifyCall(), llvm::SimplifyFMAFMul(), llvm::SimplifyFMulInst(), simplifyInvariantGroupIntrinsic(), simplifyNeonTbl1(), llvm::simplifyRetainedKnowledge(), llvm::APIntOps::smax(), llvm::APIntOps::smin(), llvm::X86AS::SS, std::swap(), llvm::SmallBitVector::test(), trunc, llvm::APInt::uadd_sat(), llvm::APIntOps::umax(), llvm::APIntOps::umin(), llvm::UndefMaskElem, llvm::Value::use_empty(), llvm::RetainedKnowledge::WasOn, X, and Y.

◆ visitExtractElementInst()

Instruction * InstCombinerImpl::visitExtractElementInst ( ExtractElementInst EI)

◆ visitExtractValueInst()

Instruction * InstCombinerImpl::visitExtractValueInst ( ExtractValueInst EV)

◆ visitFAdd()

Instruction * InstCombinerImpl::visitFAdd ( BinaryOperator I)

◆ visitFCmpInst()

Instruction * InstCombinerImpl::visitFCmpInst ( FCmpInst I)

◆ visitFDiv()

Instruction * InstCombinerImpl::visitFDiv ( BinaryOperator I)

◆ visitFenceInst()

Instruction * InstCombinerImpl::visitFenceInst ( FenceInst FI)

◆ visitFMul()

Instruction * InstCombinerImpl::visitFMul ( BinaryOperator I)

◆ visitFNeg()

Instruction * InstCombinerImpl::visitFNeg ( UnaryOperator I)

◆ visitFPExt()

Instruction * InstCombinerImpl::visitFPExt ( CastInst CI)

◆ visitFPToSI()

Instruction * InstCombinerImpl::visitFPToSI ( FPToSIInst FI)

Definition at line 2003 of file InstCombineCasts.cpp.

References I.

◆ visitFPToUI()

Instruction * InstCombinerImpl::visitFPToUI ( FPToUIInst FI)

Definition at line 1996 of file InstCombineCasts.cpp.

References I.

◆ visitFPTrunc()

Instruction * InstCombinerImpl::visitFPTrunc ( FPTruncInst CI)

◆ visitFree()

Instruction * InstCombinerImpl::visitFree ( CallInst FI)

◆ visitFreeze()

Instruction * InstCombinerImpl::visitFreeze ( FreezeInst I)

◆ visitFRem()

Instruction * InstCombinerImpl::visitFRem ( BinaryOperator I)

Definition at line 1614 of file InstCombineMulDivRem.cpp.

References I, llvm::SimplifyFRemInst(), and X.

◆ visitFSub()

Instruction * InstCombinerImpl::visitFSub ( BinaryOperator I)

◆ visitGetElementPtrInst()

Instruction * InstCombinerImpl::visitGetElementPtrInst ( GetElementPtrInst GEP)

Definition at line 1869 of file InstructionCombining.cpp.

References llvm::PHINode::addIncoming(), llvm::SmallVectorImpl< T >::append(), assert(), llvm::BitWidth, Builder, llvm::GetElementPtrInst::Create(), llvm::GetElementPtrInst::CreateInBounds(), llvm::CastInst::CreatePointerBitCastOrAddrSpaceCast(), DL, llvm::drop_begin(), E, F, foldSelectGEP(), GEP, llvm::gep_type_begin(), llvm::gep_type_end(), llvm::VectorType::get(), llvm::PointerType::getAddressSpace(), llvm::APInt::getAllOnes(), llvm::Type::getArrayElementType(), llvm::Type::getArrayNumElements(), llvm::PointerType::getElementType(), llvm::generic_gep_type_iterator< ItTy >::getIndexedType(), llvm::Constant::getNullValue(), llvm::Type::getPointerAddressSpace(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::GetElementPtrInst::getTypeAtIndex(), llvm::getUnderlyingObject(), I, llvm::isAllocationFn(), llvm::Type::isArrayTy(), isMergedGEPInBounds(), llvm::APInt::isNonNegative(), llvm::Type::isSized(), llvm::generic_gep_type_iterator< ItTy >::isStruct(), llvm::Type::isStructTy(), llvm::Type::isVectorTy(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_SDiv(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::makeArrayRef(), llvm::PatternMatch::match(), Offset, llvm::GetElementPtrInst::setIsInBounds(), shouldMergeGEPs(), llvm::SimplifyAddInst(), llvm::SimplifyGEPInst(), llvm::Value::stripAndAccumulateInBoundsConstantOffsets(), llvm::Value::stripPointerCasts(), llvm::Value::takeName(), llvm::APInt::ule(), X, and Y.

◆ visitICmpInst()

Instruction * InstCombinerImpl::visitICmpInst ( ICmpInst I)

Orders the operands of the compare so that they are listed from most complex to least complex. This puts constants before unary operators, before binary operators.

Definition at line 5806 of file InstCombineCompares.cpp.

References llvm::MCID::Add, assert(), B, Builder, canonicalizeCmpWithConstant(), canonicalizeICmpBool(), Cond, llvm::CmpInst::Create(), llvm::ExtractValueInst::Create(), llvm::SelectPatternResult::Flavor, foldICmpInvariantGroup(), foldICmpOfUAddOv(), foldICmpWithDominatingICmp(), foldICmpWithHighBitMask(), foldICmpWithMinMax(), foldVectorCmp(), GEP, llvm::ConstantInt::get(), llvm::Constant::getAllOnesValue(), llvm::Constant::getNullValue(), llvm::Instruction::getOpcode(), llvm::Value::getType(), llvm::getUnderlyingObject(), llvm::SimplifyQuery::getWithInstruction(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::Type::isIntOrIntVectorTy(), llvm::isKnownToBeAPowerOfTwo(), llvm::Type::isPointerTy(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_UAddWithOverflow(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::matchSelectPattern(), processUMulZExtIdiom(), SI, llvm::SimplifyICmpInst(), llvm::SPF_UNKNOWN, std::swap(), swapMayExposeCSEOpportunities(), and X.

◆ visitInsertElementInst()

Instruction * InstCombinerImpl::visitInsertElementInst ( InsertElementInst IE)

◆ visitInsertValueInst()

Instruction * InstCombinerImpl::visitInsertValueInst ( InsertValueInst I)

Try to find redundant insertvalue instructions, like the following ones: %0 = insertvalue { i8, i32 } undef, i8 x, 0 %1 = insertvalue { i8, i32 } %0, i8 y, 0 Here the second instruction inserts values at the same indices, as the first one, making the first one redundant.

It should be transformed to: %0 = insertvalue { i8, i32 } undef, i8 y, 0

Definition at line 1083 of file InstCombineVectorOps.cpp.

References llvm::Depth, llvm::User::getOperand(), llvm::Value::hasOneUse(), I, and llvm::Value::user_back().

◆ visitInstruction()

Instruction* llvm::InstCombinerImpl::visitInstruction ( Instruction I)
inline

Specify what to return for unhandled instructions.

Definition at line 177 of file InstCombineInternal.h.

◆ visitIntToPtr()

Instruction * InstCombinerImpl::visitIntToPtr ( IntToPtrInst CI)

◆ visitInvokeInst()

Instruction * InstCombinerImpl::visitInvokeInst ( InvokeInst II)

Definition at line 2372 of file InstCombineCalls.cpp.

◆ visitLandingPadInst()

Instruction * InstCombinerImpl::visitLandingPadInst ( LandingPadInst LI)

◆ visitLoadInst()

Instruction * InstCombinerImpl::visitLoadInst ( LoadInst LI)

◆ visitLShr()

Instruction * InstCombinerImpl::visitLShr ( BinaryOperator I)

◆ visitMul()

Instruction * InstCombinerImpl::visitMul ( BinaryOperator I)

i1 mul -> i1 and.

Definition at line 147 of file InstCombineMulDivRem.cpp.

References llvm::abs(), llvm::And, llvm::BitWidth, Builder, C1, llvm::CastInst::Create(), llvm::SelectInst::Create(), CreateAdd(), CreateMul(), llvm::BinaryOperator::CreateNeg(), llvm::MipsISD::Ext, llvm::SelectPatternResult::Flavor, foldMulSelectToNegate(), llvm::ConstantInt::get(), llvm::APInt::getBitWidth(), llvm::ConstantInt::getBool(), llvm::ConstantExpr::getExactLogBase2(), llvm::ConstantExpr::getNeg(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::ConstantExpr::getShl(), llvm::Value::hasOneUse(), I, llvm::Instruction::isExact(), llvm::Constant::isNotMinSignedValue(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_c_Mul(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_Neg(), llvm::PatternMatch::m_NegatedPower2(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_SpecificIntAllowUndef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::matchSelectPattern(), llvm::Mul, llvm::Negator::Negate(), llvm::Instruction::setHasNoSignedWrap(), llvm::Instruction::setHasNoUnsignedWrap(), llvm::SimplifyMulInst(), llvm::SPF_ABS, llvm::SPF_NABS, llvm::Value::takeName(), X, and Y.

◆ visitOr()

Instruction * InstCombinerImpl::visitOr ( BinaryOperator I)

◆ visitPHINode()

Instruction * InstCombinerImpl::visitPHINode ( PHINode PN)

◆ visitPtrToInt()

Instruction * InstCombinerImpl::visitPtrToInt ( PtrToIntInst CI)

◆ visitReturnInst()

Instruction * InstCombinerImpl::visitReturnInst ( ReturnInst RI)

◆ visitSDiv()

Instruction * InstCombinerImpl::visitSDiv ( BinaryOperator I)

◆ visitSelectInst()

Instruction* llvm::InstCombinerImpl::visitSelectInst ( SelectInst SI)

◆ visitSExt()

Instruction * InstCombinerImpl::visitSExt ( SExtInst CI)

◆ visitShl()

Instruction * InstCombinerImpl::visitShl ( BinaryOperator I)

◆ visitShuffleVectorInst()

Instruction * InstCombinerImpl::visitShuffleVectorInst ( ShuffleVectorInst SVI)

Definition at line 2418 of file InstCombineVectorOps.cpp.

References assert(), Builder, canEvaluateShuffled(), canonicalizeInsertSplat(), llvm::SmallVectorImpl< T >::clear(), llvm::ShuffleVectorInst::commute(), llvm::CastInst::Create(), llvm::createUnaryMask(), DL, E, llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::end(), evaluateInDifferentElementOrder(), llvm::MipsISD::Ext, llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find(), foldIdentityExtractShuffle(), foldIdentityPaddedShuffles(), foldSelectShuffle(), foldShuffleWithInsert(), foldTruncShuffle(), llvm::ConstantInt::get(), llvm::FixedVectorType::get(), llvm::UndefValue::get(), llvm::APInt::getAllOnes(), llvm::Value::getContext(), llvm::Type::getInt32Ty(), llvm::Value::getName(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::ShuffleVectorInst::getShuffleMask(), llvm::Value::getType(), llvm::ShuffleVectorInst::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::Value::hasOneUse(), i, I, Int32Ty, isShuffleExtractingFromLHS(), isSplat(), llvm::VectorType::isValidElementType(), llvm::PatternMatch::m_BitCast(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), llvm::narrowShuffleMaskElts(), narrowVectorSelect(), llvm::SimplifyShuffleVectorInst(), llvm::Value::users(), llvm::widenShuffleMaskElts(), X, and Y.

◆ visitSIToFP()

Instruction * InstCombinerImpl::visitSIToFP ( CastInst CI)

Definition at line 2014 of file InstCombineCasts.cpp.

◆ visitSRem()

Instruction * InstCombinerImpl::visitSRem ( BinaryOperator I)

◆ visitStoreInst()

Instruction * InstCombinerImpl::visitStoreInst ( StoreInst SI)

◆ visitSub()

Instruction * InstCombinerImpl::visitSub ( BinaryOperator I)

Definition at line 1742 of file InstCombineAddSub.cpp.

References llvm::InstCombiner::AddOne(), assert(), B, llvm::BitWidth, Builder, llvm::computeKnownBits(), Cond, llvm::Instruction::copyMetadata(), llvm::APInt::countTrailingZeros(), llvm::SelectInst::Create(), CreateAdd(), llvm::BinaryOperator::CreateNeg(), llvm::BinaryOperator::CreateNot(), llvm::MipsISD::Ext, factorizeMathWithShlOps(), llvm::tgtok::FalseVal, llvm::SelectPatternResult::Flavor, llvm::ConstantInt::get(), llvm::Constant::getAllOnesValue(), llvm::APInt::getHighBitsSet(), llvm::Constant::getNullValue(), llvm::Type::getScalarSizeInBits(), llvm::ConstantExpr::getSub(), llvm::Value::getType(), llvm::Value::hasNUsesOrMore(), I, llvm::APInt::isMask(), llvm::SelectPatternResult::isMinOrMax(), isZero(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_MaxOrMin(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_c_Xor(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_Neg(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::PatternMatch::m_ZeroInt(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::matchSelectPattern(), llvm::Negator::Negate(), llvm::none_of(), llvm::MCID::Select, llvm::Instruction::setHasNoSignedWrap(), SI, llvm::SimplifySubInst(), llvm::InstCombiner::SubOne(), std::swap(), llvm::tgtok::TrueVal, llvm::APIntOps::umin(), X, Y, and llvm::KnownBits::Zero.

◆ visitSwitchInst()

Instruction * InstCombinerImpl::visitSwitchInst ( SwitchInst SI)

◆ visitTrunc()

Instruction * InstCombinerImpl::visitTrunc ( TruncInst CI)

Definition at line 745 of file InstCombineCasts.cpp.

References llvm::And, assert(), B, Builder, canEvaluateTruncated(), llvm::BinaryOperator::Create(), llvm::ExtractElementInst::Create(), CreateAdd(), llvm::CastInst::CreateIntegerCast(), llvm::CastInst::CreateTruncOrBitCast(), llvm::dbgs(), DL, foldVecTruncToExtElt(), llvm::ConstantInt::get(), llvm::VectorType::get(), llvm::Function::getFnAttribute(), llvm::Instruction::getFunction(), llvm::ConstantExpr::getIntegerCast(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::ConstantExpr::getOr(), llvm::Type::getScalarSizeInBits(), llvm::ConstantExpr::getShl(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::ConstantExpr::getUMin(), llvm::Attribute::getVScaleRangeArgs(), llvm::ConstantInt::getZExtValue(), llvm::Function::hasFnAttribute(), I, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::Type::isIntegerTy(), llvm::Type::isVectorTy(), LLVM_DEBUG, llvm::Log2_32(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_ExtractElt(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_SpecificInt_ICMP(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_VScale(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::matchSelectPattern(), llvm::max(), llvm::Constant::mergeUndefsWith(), Shift, shrinkInsertElt(), shrinkSplatShuffle(), llvm::SPF_UNKNOWN, Threshold, and X.

◆ visitUDiv()

Instruction * InstCombinerImpl::visitUDiv ( BinaryOperator I)

◆ visitUIToFP()

Instruction * InstCombinerImpl::visitUIToFP ( CastInst CI)

Definition at line 2010 of file InstCombineCasts.cpp.

◆ visitUnconditionalBranchInst()

Instruction * InstCombinerImpl::visitUnconditionalBranchInst ( BranchInst BI)

Definition at line 2941 of file InstructionCombining.cpp.

References assert(), llvm::BranchInst::isUnconditional(), and SI.

◆ visitUnreachableInst()

Instruction * InstCombinerImpl::visitUnreachableInst ( UnreachableInst I)

◆ visitURem()

Instruction * InstCombinerImpl::visitURem ( BinaryOperator I)

◆ visitVAEndInst()

Instruction * InstCombinerImpl::visitVAEndInst ( VAEndInst I)

Definition at line 704 of file InstCombineCalls.cpp.

References I, and removeTriviallyEmptyRange().

◆ visitXor()

Instruction * InstCombinerImpl::visitXor ( BinaryOperator I)

◆ visitZExt()

Instruction * InstCombinerImpl::visitZExt ( ZExtInst CI)

The documentation for this class was generated from the following files: