LLVM 17.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
llvm::InstCombiner Class Referenceabstract

The core instruction combiner logic. More...

#include "llvm/Transforms/InstCombine/InstCombiner.h"

Inheritance diagram for llvm::InstCombiner:
Inheritance graph
[legend]

Public Types

using BuilderTy = IRBuilder< TargetFolder, IRBuilderCallbackInserter >
 An IRBuilder that automatically inserts new instructions into the worklist.
 

Public Member Functions

 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 ()=default
 
void addToWorklist (Instruction *I)
 
AssumptionCachegetAssumptionCache () const
 
TargetLibraryInfogetTargetLibraryInfo () const
 
DominatorTreegetDominatorTree () const
 
const DataLayoutgetDataLayout () const
 
const SimplifyQuerygetSimplifyQuery () const
 
OptimizationRemarkEmittergetOptimizationRemarkEmitter () const
 
BlockFrequencyInfogetBlockFrequencyInfo () const
 
ProfileSummaryInfogetProfileSummaryInfo () const
 
LoopInfogetLoopInfo () const
 
std::optional< Instruction * > targetInstCombineIntrinsic (IntrinsicInst &II)
 
std::optional< Value * > targetSimplifyDemandedUseBitsIntrinsic (IntrinsicInst &II, APInt DemandedMask, KnownBits &Known, bool &KnownBitsComputed)
 
std::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.
 
InstructionInsertNewInstWith (Instruction *New, Instruction &Old)
 Same as InsertNewInstBefore, but also sets the debug loc.
 
InstructionreplaceInstUsesWith (Instruction &I, Value *V)
 A combiner-aware RAUW-like routine.
 
InstructionreplaceOperand (Instruction &I, unsigned OpNum, Value *V)
 Replace operand of instruction and add old operand to the worklist.
 
void replaceUse (Use &U, Value *NewValue)
 Replace use and add the previously used value to the worklist.
 
virtual InstructioneraseInstFromFunction (Instruction &I)=0
 Combiner aware instruction erasure.
 
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
 
unsigned ComputeMaxSignificantBits (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
 
virtual bool SimplifyDemandedBits (Instruction *I, unsigned OpNo, const APInt &DemandedMask, KnownBits &Known, unsigned Depth=0)=0
 
virtual ValueSimplifyDemandedVectorElts (Value *V, APInt DemandedElts, APInt &UndefElts, unsigned Depth=0, bool AllowMultipleUsers=false)=0
 
bool isValidAddrSpaceCast (unsigned FromAS, unsigned ToAS) const
 

Static Public Member Functions

static ValuepeekThroughBitcast (Value *V, bool OneUseOnly=false)
 Return the source operand of a potentially bitcasted value while optionally checking if it has one use.
 
static unsigned getComplexity (Value *V)
 Assign a complexity or rank value to LLVM Values.
 
static bool isCanonicalPredicate (CmpInst::Predicate Pred)
 Predicate canonicalization reduces the number of patterns that need to be matched by other transforms.
 
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.
 
static ConstantAddOne (Constant *C)
 Add one to a Constant.
 
static ConstantSubOne (Constant *C)
 Subtract one from a Constant.
 
static std::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).
 
static bool canFreelyInvertAllUsersOf (Instruction *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.
 
static ConstantgetSafeVectorConstantForBinop (BinaryOperator::BinaryOps Opcode, Constant *In, bool IsRHSConstant)
 Some binary operators require special handling to avoid poison and undefined behavior.
 

Public Attributes

uint64_t MaxArraySizeForCombine = 0
 Maximum size of array considered when transforming.
 
BuilderTyBuilder
 

Protected Attributes

InstructionWorklistWorklist
 A worklist of the instructions that need to be simplified.
 
const bool MinimizeSize
 
AAResultsAA
 
AssumptionCacheAC
 
TargetLibraryInfoTLI
 
DominatorTreeDT
 
const DataLayoutDL
 
const SimplifyQuery SQ
 
OptimizationRemarkEmitterORE
 
BlockFrequencyInfoBFI
 
ProfileSummaryInfoPSI
 
LoopInfoLI
 
bool MadeIRChange = false
 

Detailed Description

The core instruction combiner logic.

This class provides both the logic to recursively visit instructions and combine them.

Definition at line 45 of file InstCombiner.h.

Member Typedef Documentation

◆ BuilderTy

An IRBuilder that automatically inserts new instructions into the worklist.

Definition at line 57 of file InstCombiner.h.

Constructor & Destructor Documentation

◆ InstCombiner()

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 
)
inline

Definition at line 86 of file InstCombiner.h.

References Builder.

◆ ~InstCombiner()

virtual llvm::InstCombiner::~InstCombiner ( )
virtualdefault

Member Function Documentation

◆ AddOne()

static Constant * llvm::InstCombiner::AddOne ( Constant C)
inlinestatic

◆ addToWorklist()

void llvm::InstCombiner::addToWorklist ( Instruction I)
inline

◆ canFreelyInvertAllUsersOf()

static bool llvm::InstCombiner::canFreelyInvertAllUsersOf ( Instruction V,
Value IgnoredUser 
)
inlinestatic

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.

NOTE: for Instructions only!

See also: isFreeToInvert()

Definition at line 279 of file InstCombiner.h.

References assert(), I, llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().

Referenced by llvm::InstCombinerImpl::canonicalizeICmpPredicate(), llvm::InstCombinerImpl::sinkNotIntoLogicalOp(), and llvm::InstCombinerImpl::sinkNotIntoOtherHandOfLogicalOp().

◆ computeKnownBits() [1/2]

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

◆ computeKnownBits() [2/2]

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

Definition at line 466 of file InstCombiner.h.

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

◆ ComputeMaxSignificantBits()

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

Definition at line 487 of file InstCombiner.h.

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

Referenced by processUGT_ADDCST_ADD().

◆ ComputeNumSignBits()

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

◆ computeOverflowForSignedAdd()

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

Definition at line 509 of file InstCombiner.h.

References llvm::computeOverflowForSignedAdd(), DL, LHS, and RHS.

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

◆ computeOverflowForSignedMul()

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

Definition at line 498 of file InstCombiner.h.

References llvm::computeOverflowForSignedMul(), DL, LHS, and RHS.

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

◆ computeOverflowForSignedSub()

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

Definition at line 520 of file InstCombiner.h.

References llvm::computeOverflowForSignedSub(), DL, LHS, and RHS.

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

◆ computeOverflowForUnsignedAdd()

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

Definition at line 503 of file InstCombiner.h.

References llvm::computeOverflowForUnsignedAdd(), DL, LHS, and RHS.

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

◆ computeOverflowForUnsignedMul()

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

Definition at line 492 of file InstCombiner.h.

References llvm::computeOverflowForUnsignedMul(), DL, LHS, and RHS.

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

◆ computeOverflowForUnsignedSub()

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

Definition at line 514 of file InstCombiner.h.

References llvm::computeOverflowForUnsignedSub(), DL, LHS, and RHS.

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

◆ eraseInstFromFunction()

virtual Instruction * llvm::InstCombiner::eraseInstFromFunction ( Instruction I)
pure virtual

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.

Implemented in llvm::InstCombinerImpl.

Referenced by handlePotentiallyDeadBlock(), llvm::GCNTTIImpl::instCombineIntrinsic(), llvm::ARMTTIImpl::instCombineIntrinsic(), instCombineST1ScatterIndex(), instCombineSVEST1(), modifyIntrinsicCall(), and simplifyX86MaskedStore().

◆ getAssumptionCache()

AssumptionCache & llvm::InstCombiner::getAssumptionCache ( ) const
inline

◆ getBlockFrequencyInfo()

BlockFrequencyInfo * llvm::InstCombiner::getBlockFrequencyInfo ( ) const
inline

Definition at line 377 of file InstCombiner.h.

◆ getComplexity()

static unsigned llvm::InstCombiner::getComplexity ( Value V)
inlinestatic

Assign a complexity or rank value to LLVM Values.

This is used to reduce the amount of pattern matching needed for compares and commutative instructions. For example, if we have: icmp ugt X, Constant or xor (add X, Constant), cast Z

We do not have to consider the commuted variants of these patterns because canonicalization based on complexity guarantees the above ordering.

This routine maps IR values to various complexity ranks: 0 -> undef 1 -> Constants 2 -> Other non-instructions 3 -> Arguments 4 -> Cast and (f)neg/not instructions 5 -> Other instructions

Definition at line 127 of file InstCombiner.h.

References llvm::PatternMatch::m_FNeg(), llvm::PatternMatch::m_Neg(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().

Referenced by llvm::InstCombinerImpl::SimplifyAssociativeOrCommutative(), llvm::InstCombinerImpl::visitFCmpInst(), and llvm::InstCombinerImpl::visitICmpInst().

◆ getDataLayout()

const DataLayout & llvm::InstCombiner::getDataLayout ( ) const
inline

◆ getDominatorTree()

DominatorTree & llvm::InstCombiner::getDominatorTree ( ) const
inline

◆ getFlippedStrictnessPredicateAndConstant()

std::optional< std::pair< CmpInst::Predicate, Constant * > > InstCombiner::getFlippedStrictnessPredicateAndConstant ( CmpInst::Predicate  Pred,
Constant C 
)
static

◆ getLoopInfo()

LoopInfo * llvm::InstCombiner::getLoopInfo ( ) const
inline

Definition at line 379 of file InstCombiner.h.

◆ getOptimizationRemarkEmitter()

OptimizationRemarkEmitter & llvm::InstCombiner::getOptimizationRemarkEmitter ( ) const
inline

Definition at line 374 of file InstCombiner.h.

Referenced by llvm::GCNTTIImpl::canSimplifyLegacyMulToMul().

◆ getProfileSummaryInfo()

ProfileSummaryInfo * llvm::InstCombiner::getProfileSummaryInfo ( ) const
inline

Definition at line 378 of file InstCombiner.h.

◆ getSafeVectorConstantForBinop()

static Constant * llvm::InstCombiner::getSafeVectorConstantForBinop ( BinaryOperator::BinaryOps  Opcode,
Constant In,
bool  IsRHSConstant 
)
inlinestatic

Some binary operators require special handling to avoid poison and undefined behavior.

If a constant vector has undef elements, replace those undefs with identity constants if possible because those are always safe to execute. If no identity constant exists, replace undef with some other safe constant.

Definition at line 315 of file InstCombiner.h.

References assert(), llvm::CallingConv::C, llvm::ConstantVector::get(), llvm::ConstantFP::get(), llvm::ConstantInt::get(), llvm::ConstantExpr::getBinOpIdentity(), llvm::Constant::getNullValue(), and llvm_unreachable.

Referenced by llvm::InstCombinerImpl::foldSelectShuffle(), foldSelectShuffleWith1Binop(), and llvm::InstCombinerImpl::foldVectorBinop().

◆ getSimplifyQuery()

const SimplifyQuery & llvm::InstCombiner::getSimplifyQuery ( ) const
inline

◆ getTargetLibraryInfo()

TargetLibraryInfo & llvm::InstCombiner::getTargetLibraryInfo ( ) const
inline

Definition at line 370 of file InstCombiner.h.

Referenced by llvm::GCNTTIImpl::canSimplifyLegacyMulToMul().

◆ InsertNewInstBefore()

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

◆ InsertNewInstWith()

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

◆ isCanonicalPredicate()

static bool llvm::InstCombiner::isCanonicalPredicate ( CmpInst::Predicate  Pred)
inlinestatic

Predicate canonicalization reduces the number of patterns that need to be matched by other transforms.

For example, we may swap the operands of a conditional branch or select to create a compare with a canonical (inverted) predicate which is then more likely to be matched with other values.

Definition at line 145 of file InstCombiner.h.

References llvm::CmpInst::FCMP_OGE, llvm::CmpInst::FCMP_OLE, llvm::CmpInst::FCMP_ONE, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_UGE, and llvm::CmpInst::ICMP_ULE.

Referenced by canonicalizeCmpWithConstant(), llvm::InstCombinerImpl::canonicalizeICmpPredicate(), and llvm::InstCombinerImpl::visitBranchInst().

◆ isFreeToInvert()

static bool llvm::InstCombiner::isFreeToInvert ( Value V,
bool  WillInvertAllUses 
)
inlinestatic

◆ isKnownToBeAPowerOfTwo()

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

◆ isSignBitCheck()

static bool llvm::InstCombiner::isSignBitCheck ( ICmpInst::Predicate  Pred,
const APInt RHS,
bool TrueIfSigned 
)
inlinestatic

◆ isValidAddrSpaceCast()

bool InstCombiner::isValidAddrSpaceCast ( unsigned  FromAS,
unsigned  ToAS 
) const

◆ MaskedValueIsZero()

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

◆ peekThroughBitcast()

static Value * llvm::InstCombiner::peekThroughBitcast ( Value V,
bool  OneUseOnly = false 
)
inlinestatic

Return the source operand of a potentially bitcasted value while optionally checking if it has one use.

If there is no bitcast or the one use check is not met, return the input value itself.

Definition at line 101 of file InstCombiner.h.

Referenced by llvm::X86TTIImpl::instCombineIntrinsic(), and isMinMaxWithLoads().

◆ replaceInstUsesWith()

Instruction * llvm::InstCombiner::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 418 of file InstCombiner.h.

References llvm::dbgs(), llvm::PoisonValue::get(), I, LLVM_DEBUG, and llvm::InstructionWorklist::pushUsersToWorkList().

Referenced by llvm::InstCombinerImpl::commonCastTransforms(), llvm::InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse(), llvm::InstCombinerImpl::foldAllocaCmp(), llvm::InstCombinerImpl::foldCmpLoadFromIndexedGlobal(), foldCtpop(), foldCttzCtlz(), llvm::InstCombinerImpl::foldFCmpIntToFPConst(), llvm::InstCombinerImpl::foldFreezeIntoRecurrence(), llvm::InstCombinerImpl::foldGEPICmp(), llvm::InstCombinerImpl::foldICmpAndConstant(), llvm::InstCombinerImpl::foldICmpAndShift(), llvm::InstCombinerImpl::foldICmpBinOp(), llvm::InstCombinerImpl::foldICmpDivConstant(), llvm::InstCombinerImpl::foldICmpEquality(), llvm::InstCombinerImpl::foldICmpSelectConstant(), llvm::InstCombinerImpl::foldICmpShlConstConst(), llvm::InstCombinerImpl::foldICmpShrConstConst(), llvm::InstCombinerImpl::foldICmpUsingBoolRange(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), llvm::InstCombinerImpl::foldICmpWithConstant(), llvm::InstCombinerImpl::foldICmpWithDominatingICmp(), llvm::InstCombinerImpl::foldIntegerTypedPHI(), llvm::InstCombinerImpl::foldItoFPtoI(), llvm::InstCombinerImpl::foldMultiplicationOverflowCheck(), llvm::InstCombinerImpl::foldOpIntoPhi(), llvm::InstCombinerImpl::foldSelectShuffle(), foldSelectZeroOrMul(), llvm::InstCombinerImpl::FoldShiftByConstant(), llvm::InstCombinerImpl::foldVariableSignZeroExtensionOfVariableHighBitExtract(), handlePotentiallyDeadBlock(), instCombineConvertFromSVBool(), llvm::GCNTTIImpl::instCombineIntrinsic(), llvm::ARMTTIImpl::instCombineIntrinsic(), llvm::X86TTIImpl::instCombineIntrinsic(), instCombineLD1GatherIndex(), instCombineMaxMinNM(), instCombineRDFFR(), instCombineSVECmpNE(), instCombineSVECntElts(), instCombineSVECondLast(), instCombineSVEDup(), instCombineSVEDupqLane(), instCombineSVEDupX(), instCombineSVELast(), instCombineSVELD1(), instCombineSVEPTest(), instCombineSVESDIV(), instCombineSVESel(), instCombineSVESrshl(), instCombineSVETBL(), instCombineSVEUnpack(), instCombineSVEVectorBinOp(), instCombineSVEVectorFuseMulAddSub(), instCombineSVEVectorMul(), instCombineSVEZip(), modifyIntrinsicCall(), processPhiNode(), processUGT_ADDCST_ADD(), processUMulZExtIdiom(), removeBitcastsFromLoadStoreOnMinMax(), replaceExtractElements(), simplifyAllocaArraySize(), llvm::InstCombinerImpl::SimplifyDemandedInstructionBits(), simplifyIRemMulShl(), simplifyX86MaskedLoad(), llvm::InstCombinerImpl::sinkNotIntoLogicalOp(), llvm::InstCombinerImpl::sinkNotIntoOtherHandOfLogicalOp(), llvm::InstCombinerImpl::SliceUpIllegalIntegerPHI(), tryCombineFromSVBoolBinOp(), unpackLoadToAggregate(), llvm::InstCombinerImpl::visitAdd(), llvm::InstCombinerImpl::visitAllocaInst(), llvm::InstCombinerImpl::visitAllocSite(), llvm::InstCombinerImpl::visitAnd(), llvm::InstCombinerImpl::visitAShr(), llvm::InstCombinerImpl::visitBitCast(), llvm::InstCombinerImpl::visitCallInst(), llvm::InstCombinerImpl::visitExtractElementInst(), llvm::InstCombinerImpl::visitExtractValueInst(), llvm::InstCombinerImpl::visitFAdd(), llvm::InstCombinerImpl::visitFCmpInst(), llvm::InstCombinerImpl::visitFDiv(), llvm::InstCombinerImpl::visitFMul(), llvm::InstCombinerImpl::visitFNeg(), llvm::InstCombinerImpl::visitFPTrunc(), llvm::InstCombinerImpl::visitFree(), llvm::InstCombinerImpl::visitFreeze(), llvm::InstCombinerImpl::visitFRem(), llvm::InstCombinerImpl::visitFSub(), llvm::InstCombinerImpl::visitGEPOfGEP(), llvm::InstCombinerImpl::visitGetElementPtrInst(), llvm::InstCombinerImpl::visitICmpInst(), llvm::InstCombinerImpl::visitInsertElementInst(), llvm::InstCombinerImpl::visitInsertValueInst(), llvm::InstCombinerImpl::visitLoadInst(), llvm::InstCombinerImpl::visitLShr(), llvm::InstCombinerImpl::visitMul(), llvm::InstCombinerImpl::visitOr(), llvm::InstCombinerImpl::visitPHINode(), llvm::InstCombinerImpl::visitPtrToInt(), llvm::InstCombinerImpl::visitSDiv(), llvm::InstCombinerImpl::visitSExt(), llvm::InstCombinerImpl::visitShl(), llvm::InstCombinerImpl::visitShuffleVectorInst(), llvm::InstCombinerImpl::visitSRem(), llvm::InstCombinerImpl::visitSub(), llvm::InstCombinerImpl::visitTrunc(), llvm::InstCombinerImpl::visitUDiv(), llvm::InstCombinerImpl::visitUnreachableInst(), llvm::InstCombinerImpl::visitURem(), llvm::InstCombinerImpl::visitXor(), and llvm::InstCombinerImpl::visitZExt().

◆ replaceOperand()

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

Replace operand of instruction and add old operand to the worklist.

Definition at line 442 of file InstCombiner.h.

References llvm::InstructionWorklist::addValue(), and I.

Referenced by llvm::InstCombinerImpl::commonIDivTransforms(), llvm::InstCombinerImpl::commonIRemTransforms(), llvm::InstCombinerImpl::commonPointerCastTransforms(), llvm::InstCombinerImpl::commonShiftTransforms(), foldCtpop(), foldCttzCtlz(), foldFabsWithFcmpZero(), llvm::InstCombinerImpl::foldICmpAndConstConst(), llvm::InstCombinerImpl::foldICmpAndShift(), llvm::InstCombinerImpl::foldICmpXorConstant(), foldSelectBinOpIdentity(), foldSelectZeroOrMul(), foldShuffleWithInsert(), llvm::GCNTTIImpl::instCombineIntrinsic(), llvm::ARMTTIImpl::instCombineIntrinsic(), llvm::X86TTIImpl::instCombineIntrinsic(), simplifyAllocaArraySize(), simplifyAssocCastAssoc(), llvm::InstCombinerImpl::SimplifyAssociativeOrCommutative(), llvm::InstCombinerImpl::SimplifyDemandedVectorElts(), llvm::InstCombinerImpl::simplifyDivRemOfSelectWithZeroOp(), simplifyValueKnownNonZero(), llvm::InstCombinerImpl::visitAdd(), llvm::InstCombinerImpl::visitAllocaInst(), llvm::InstCombinerImpl::visitAtomicRMWInst(), llvm::InstCombinerImpl::visitBranchInst(), llvm::InstCombinerImpl::visitCallInst(), llvm::InstCombinerImpl::visitExtractElementInst(), llvm::InstCombinerImpl::visitFCmpInst(), llvm::InstCombinerImpl::visitFDiv(), llvm::InstCombinerImpl::visitGEPOfGEP(), llvm::InstCombinerImpl::visitGetElementPtrInst(), llvm::InstCombinerImpl::visitInsertElementInst(), llvm::InstCombinerImpl::visitLoadInst(), llvm::InstCombinerImpl::visitPHINode(), llvm::InstCombinerImpl::visitReturnInst(), llvm::InstCombinerImpl::visitSRem(), llvm::InstCombinerImpl::visitStoreInst(), and llvm::InstCombinerImpl::visitSwitchInst().

◆ replaceUse()

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

◆ shouldAvoidAbsorbingNotIntoSelect()

static bool llvm::InstCombiner::shouldAvoidAbsorbingNotIntoSelect ( const SelectInst SI)
inlinestatic

◆ SimplifyDemandedBits()

virtual bool llvm::InstCombiner::SimplifyDemandedBits ( Instruction I,
unsigned  OpNo,
const APInt DemandedMask,
KnownBits Known,
unsigned  Depth = 0 
)
pure virtual

◆ SimplifyDemandedVectorElts()

virtual Value * llvm::InstCombiner::SimplifyDemandedVectorElts ( Value V,
APInt  DemandedElts,
APInt UndefElts,
unsigned  Depth = 0,
bool  AllowMultipleUsers = false 
)
pure virtual

◆ SubOne()

static Constant * llvm::InstCombiner::SubOne ( Constant C)
inlinestatic

◆ targetInstCombineIntrinsic()

std::optional< Instruction * > InstCombiner::targetInstCombineIntrinsic ( IntrinsicInst II)

◆ targetSimplifyDemandedUseBitsIntrinsic()

std::optional< Value * > InstCombiner::targetSimplifyDemandedUseBitsIntrinsic ( IntrinsicInst II,
APInt  DemandedMask,
KnownBits Known,
bool KnownBitsComputed 
)

◆ targetSimplifyDemandedVectorEltsIntrinsic()

std::optional< Value * > InstCombiner::targetSimplifyDemandedVectorEltsIntrinsic ( IntrinsicInst II,
APInt  DemandedElts,
APInt UndefElts,
APInt UndefElts2,
APInt UndefElts3,
std::function< void(Instruction *, unsigned, APInt, APInt &)>  SimplifyAndSetOp 
)

Member Data Documentation

◆ AA

AAResults* llvm::InstCombiner::AA
protected

◆ AC

AssumptionCache& llvm::InstCombiner::AC
protected

◆ BFI

BlockFrequencyInfo* llvm::InstCombiner::BFI
protected

Definition at line 76 of file InstCombiner.h.

◆ Builder

BuilderTy& llvm::InstCombiner::Builder

Definition at line 58 of file InstCombiner.h.

Referenced by canonicalizeBitCastExtElt(), llvm::InstCombinerImpl::canonicalizeCondSignextOfHighBitExtractToSignextHighBitExtract(), llvm::InstCombinerImpl::combineLoadToNewType(), combineStoreToNewValue(), llvm::InstCombinerImpl::commonCastTransforms(), llvm::InstCombinerImpl::commonIDivTransforms(), llvm::InstCombinerImpl::commonShiftTransforms(), llvm::InstCombinerImpl::foldAddWithConstant(), llvm::InstCombinerImpl::foldBinopWithPhiOperands(), llvm::InstCombinerImpl::foldCmpLoadFromIndexedGlobal(), foldCtpop(), foldCttzCtlz(), llvm::InstCombinerImpl::foldFCmpIntToFPConst(), llvm::InstCombinerImpl::foldFreezeIntoRecurrence(), llvm::InstCombinerImpl::foldGEPICmp(), llvm::InstCombinerImpl::foldICmpAddConstant(), llvm::InstCombinerImpl::foldICmpAndConstant(), llvm::InstCombinerImpl::foldICmpAndConstConst(), llvm::InstCombinerImpl::foldICmpAndShift(), llvm::InstCombinerImpl::foldICmpBinOp(), llvm::InstCombinerImpl::foldICmpBinOpEqualityWithConstant(), llvm::InstCombinerImpl::foldICmpBitCast(), llvm::InstCombinerImpl::foldICmpDivConstant(), llvm::InstCombinerImpl::foldICmpEqIntrinsicWithConstant(), llvm::InstCombinerImpl::foldICmpEquality(), llvm::InstCombinerImpl::foldICmpIntrinsicWithConstant(), llvm::InstCombinerImpl::foldICmpOrConstant(), llvm::InstCombinerImpl::foldICmpSelectConstant(), llvm::InstCombinerImpl::foldICmpShlConstant(), llvm::InstCombinerImpl::foldICmpShrConstant(), llvm::InstCombinerImpl::foldICmpSRemConstant(), llvm::InstCombinerImpl::foldICmpSubConstant(), llvm::InstCombinerImpl::foldICmpTruncConstant(), llvm::InstCombinerImpl::foldICmpUsingBoolRange(), llvm::InstCombinerImpl::foldICmpWithCastOp(), llvm::InstCombinerImpl::foldICmpWithConstant(), llvm::InstCombinerImpl::foldICmpWithDominatingICmp(), llvm::InstCombinerImpl::foldICmpWithTrunc(), llvm::InstCombinerImpl::foldICmpWithZextOrSext(), llvm::InstCombinerImpl::foldICmpXorShiftConst(), llvm::InstCombinerImpl::foldIRemByPowerOfTwoToBitTest(), llvm::InstCombinerImpl::foldMultiplicationOverflowCheck(), llvm::InstCombinerImpl::foldSelectICmp(), llvm::InstCombinerImpl::foldSelectIntoOp(), llvm::InstCombinerImpl::foldSelectOpOp(), llvm::InstCombinerImpl::foldSelectShuffle(), llvm::InstCombinerImpl::FoldShiftByConstant(), llvm::InstCombinerImpl::foldUsingDistributiveLaws(), llvm::InstCombinerImpl::foldVariableSignZeroExtensionOfVariableHighBitExtract(), llvm::InstCombinerImpl::foldVectorBinop(), foldVecTruncToExtElt(), getShiftedValue(), llvm::InstCombinerImpl::insertRangeTest(), llvm::GCNTTIImpl::instCombineIntrinsic(), llvm::ARMTTIImpl::instCombineIntrinsic(), llvm::PPCTTIImpl::instCombineIntrinsic(), llvm::X86TTIImpl::instCombineIntrinsic(), instCombineLD1GatherIndex(), instCombineRDFFR(), instCombineST1ScatterIndex(), instCombineSVECmpNE(), instCombineSVECntElts(), instCombineSVECondLast(), instCombineSVEDupqLane(), instCombineSVEDupX(), instCombineSVELast(), instCombineSVELD1(), instCombineSVEPTest(), instCombineSVESDIV(), instCombineSVESel(), instCombineSVESrshl(), instCombineSVEST1(), instCombineSVETBL(), instCombineSVEUnpack(), instCombineSVEVectorBinOp(), instCombineSVEVectorFuseMulAddSub(), llvm::InstCombinerImpl::mergeStoreIntoSuccessor(), modifyIntrinsicCall(), llvm::Negator::Negate(), optimizeIntegerToVectorInsertions(), llvm::InstCombinerImpl::OptimizePointerDifference(), optimizeVectorResizeWithIntegerBitCasts(), processPhiNode(), processUGT_ADDCST_ADD(), processUMulZExtIdiom(), llvm::InstCombinerImpl::pushFreezeToPreventPoisonFromPropagating(), llvm::InstCombinerImpl::reassociateShiftAmtsOfTwoSameDirectionShifts(), removeBitcastsFromLoadStoreOnMinMax(), llvm::InstCombinerImpl::run(), llvm::InstCombinerImpl::SimplifyAddWithRemainder(), simplifyAllocaArraySize(), simplifyAMDGCNMemoryIntrinsicDemanded(), llvm::InstCombinerImpl::SimplifyAnyMemSet(), llvm::InstCombinerImpl::SimplifyAnyMemTransfer(), llvm::InstCombinerImpl::simplifyBinOpSplats(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(), simplifyInvariantGroupIntrinsic(), llvm::InstCombinerImpl::simplifyRangeCheck(), llvm::InstCombinerImpl::SimplifySelectsFeedingBinaryOp(), simplifyUsingControlFlow(), simplifyValueKnownNonZero(), simplifyX86MaskedLoad(), simplifyX86MaskedStore(), llvm::InstCombinerImpl::sinkNotIntoLogicalOp(), llvm::InstCombinerImpl::sinkNotIntoOtherHandOfLogicalOp(), llvm::InstCombinerImpl::SliceUpIllegalIntegerPHI(), tryCombineFromSVBoolBinOp(), llvm::InstCombinerImpl::tryFactorizationFolds(), unpackLoadToAggregate(), unpackStoreToAggregate(), llvm::InstCombinerImpl::visitAdd(), llvm::InstCombinerImpl::visitAllocaInst(), llvm::InstCombinerImpl::visitAnd(), llvm::InstCombinerImpl::visitAShr(), llvm::InstCombinerImpl::visitBitCast(), llvm::InstCombinerImpl::visitBranchInst(), llvm::InstCombinerImpl::visitCallInst(), llvm::InstCombinerImpl::visitExtractElementInst(), llvm::InstCombinerImpl::visitExtractValueInst(), llvm::InstCombinerImpl::visitFAdd(), llvm::InstCombinerImpl::visitFCmpInst(), llvm::InstCombinerImpl::visitFDiv(), llvm::InstCombinerImpl::visitFMul(), llvm::InstCombinerImpl::visitFNeg(), llvm::InstCombinerImpl::visitFPTrunc(), llvm::InstCombinerImpl::visitFSub(), llvm::InstCombinerImpl::visitGEPOfGEP(), llvm::InstCombinerImpl::visitGetElementPtrInst(), llvm::InstCombinerImpl::visitICmpInst(), llvm::InstCombinerImpl::visitInsertElementInst(), llvm::InstCombinerImpl::visitIntToPtr(), llvm::InstCombinerImpl::visitLoadInst(), llvm::InstCombinerImpl::visitLShr(), llvm::InstCombinerImpl::visitMul(), llvm::InstCombinerImpl::visitOr(), llvm::InstCombinerImpl::visitPtrToInt(), llvm::InstCombinerImpl::visitSDiv(), llvm::InstCombinerImpl::visitSExt(), llvm::InstCombinerImpl::visitShl(), llvm::InstCombinerImpl::visitShuffleVectorInst(), llvm::InstCombinerImpl::visitSRem(), llvm::InstCombinerImpl::visitSub(), llvm::InstCombinerImpl::visitSwitchInst(), llvm::InstCombinerImpl::visitTrunc(), llvm::InstCombinerImpl::visitUDiv(), llvm::InstCombinerImpl::visitURem(), llvm::InstCombinerImpl::visitXor(), and llvm::InstCombinerImpl::visitZExt().

◆ DL

const DataLayout& llvm::InstCombiner::DL
protected

Definition at line 73 of file InstCombiner.h.

Referenced by llvm::InstCombinerImpl::commonCastTransforms(), llvm::InstCombinerImpl::EvaluateInDifferentType(), llvm::InstCombinerImpl::foldAddWithConstant(), llvm::InstCombinerImpl::foldBinopWithPhiOperands(), llvm::InstCombinerImpl::foldCmpLoadFromIndexedGlobal(), llvm::InstCombinerImpl::foldGEPICmp(), llvm::InstCombinerImpl::foldICmpAddConstant(), llvm::InstCombinerImpl::foldICmpInstWithConstantNotInt(), llvm::InstCombinerImpl::foldICmpShlConstant(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), llvm::InstCombinerImpl::foldICmpWithCastOp(), llvm::InstCombinerImpl::foldICmpWithZero(), llvm::InstCombinerImpl::foldICmpWithZextOrSext(), llvm::InstCombinerImpl::foldIntegerTypedPHI(), llvm::InstCombinerImpl::foldSelectICmp(), llvm::InstCombinerImpl::foldSelectShuffle(), llvm::InstCombinerImpl::FoldShiftByConstant(), llvm::InstCombinerImpl::foldVectorBinop(), llvm::InstCombinerImpl::mergeStoreIntoSuccessor(), llvm::InstCombinerImpl::SimplifyAnyMemSet(), llvm::InstCombinerImpl::SimplifyAnyMemTransfer(), llvm::InstCombinerImpl::SimplifyAssociativeOrCommutative(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::InstCombinerImpl::visitAdd(), llvm::InstCombinerImpl::visitAllocaInst(), llvm::InstCombinerImpl::visitAllocSite(), llvm::InstCombinerImpl::visitBitCast(), llvm::InstCombinerImpl::visitCallInst(), llvm::InstCombinerImpl::visitFAdd(), llvm::InstCombinerImpl::visitFCmpInst(), llvm::InstCombinerImpl::visitFMul(), llvm::InstCombinerImpl::visitFNeg(), llvm::InstCombinerImpl::visitFree(), llvm::InstCombinerImpl::visitFSub(), llvm::InstCombinerImpl::visitGEPOfGEP(), llvm::InstCombinerImpl::visitGetElementPtrInst(), llvm::InstCombinerImpl::visitICmpInst(), llvm::InstCombinerImpl::visitInsertElementInst(), llvm::InstCombinerImpl::visitIntToPtr(), llvm::InstCombinerImpl::visitLoadInst(), llvm::InstCombinerImpl::visitMul(), llvm::InstCombinerImpl::visitOr(), llvm::InstCombinerImpl::visitPHINode(), llvm::InstCombinerImpl::visitPtrToInt(), llvm::InstCombinerImpl::visitSDiv(), llvm::InstCombinerImpl::visitSExt(), llvm::InstCombinerImpl::visitShuffleVectorInst(), llvm::InstCombinerImpl::visitStoreInst(), and llvm::InstCombinerImpl::visitTrunc().

◆ DT

DominatorTree& llvm::InstCombiner::DT
protected

◆ LI

LoopInfo* llvm::InstCombiner::LI
protected

◆ MadeIRChange

bool llvm::InstCombiner::MadeIRChange = false
protected

Definition at line 83 of file InstCombiner.h.

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

◆ MaxArraySizeForCombine

uint64_t llvm::InstCombiner::MaxArraySizeForCombine = 0

Maximum size of array considered when transforming.

Definition at line 53 of file InstCombiner.h.

Referenced by combineInstructionsOverFunction(), llvm::InstCombinerImpl::foldCmpLoadFromIndexedGlobal(), unpackLoadToAggregate(), and unpackStoreToAggregate().

◆ MinimizeSize

const bool llvm::InstCombiner::MinimizeSize
protected

Definition at line 65 of file InstCombiner.h.

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

◆ ORE

OptimizationRemarkEmitter& llvm::InstCombiner::ORE
protected

Definition at line 75 of file InstCombiner.h.

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

◆ PSI

ProfileSummaryInfo* llvm::InstCombiner::PSI
protected

Definition at line 77 of file InstCombiner.h.

◆ SQ

const SimplifyQuery llvm::InstCombiner::SQ
protected

Definition at line 74 of file InstCombiner.h.

Referenced by llvm::InstCombinerImpl::commonShiftTransforms(), llvm::InstCombinerImpl::foldAddWithConstant(), llvm::InstCombinerImpl::foldICmpAddConstant(), llvm::InstCombinerImpl::foldICmpBinOp(), llvm::InstCombinerImpl::foldICmpWithZero(), llvm::InstCombinerImpl::foldOpIntoPhi(), llvm::InstCombinerImpl::foldSelectICmp(), llvm::InstCombinerImpl::foldSignBitTest(), llvm::InstCombinerImpl::foldUsingDistributiveLaws(), llvm::InstCombinerImpl::reassociateShiftAmtsOfTwoSameDirectionShifts(), llvm::InstCombinerImpl::SimplifyAssociativeOrCommutative(), llvm::InstCombinerImpl::SimplifySelectsFeedingBinaryOp(), llvm::InstCombinerImpl::tryFactorizationFolds(), llvm::InstCombinerImpl::visitAdd(), llvm::InstCombinerImpl::visitAnd(), llvm::InstCombinerImpl::visitAShr(), llvm::InstCombinerImpl::visitCallInst(), llvm::InstCombinerImpl::visitExtractElementInst(), llvm::InstCombinerImpl::visitExtractValueInst(), llvm::InstCombinerImpl::visitFAdd(), llvm::InstCombinerImpl::visitFCmpInst(), llvm::InstCombinerImpl::visitFDiv(), llvm::InstCombinerImpl::visitFMul(), llvm::InstCombinerImpl::visitFreeze(), llvm::InstCombinerImpl::visitFRem(), llvm::InstCombinerImpl::visitFSub(), llvm::InstCombinerImpl::visitGEPOfGEP(), llvm::InstCombinerImpl::visitGetElementPtrInst(), llvm::InstCombinerImpl::visitICmpInst(), llvm::InstCombinerImpl::visitInsertElementInst(), llvm::InstCombinerImpl::visitInsertValueInst(), llvm::InstCombinerImpl::visitLoadInst(), llvm::InstCombinerImpl::visitLShr(), llvm::InstCombinerImpl::visitMul(), llvm::InstCombinerImpl::visitOr(), llvm::InstCombinerImpl::visitPHINode(), llvm::InstCombinerImpl::visitSDiv(), llvm::InstCombinerImpl::visitShl(), llvm::InstCombinerImpl::visitShuffleVectorInst(), llvm::InstCombinerImpl::visitSRem(), llvm::InstCombinerImpl::visitSub(), llvm::InstCombinerImpl::visitUDiv(), llvm::InstCombinerImpl::visitURem(), and llvm::InstCombinerImpl::visitXor().

◆ TLI

TargetLibraryInfo& llvm::InstCombiner::TLI
protected

◆ Worklist

InstructionWorklist& llvm::InstCombiner::Worklist
protected

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