LLVM API Documentation

Public Types | Public Member Functions | Public Attributes | Static Public Attributes
llvm::InstCombiner Class Reference

InstCombiner - The -instcombine pass. More...

#include <InstCombine.h>

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

List of all members.

Public Types

typedef IRBuilder< true,
TargetFolder,
InstCombineIRInserter
BuilderTy

Public Member Functions

 InstCombiner ()
bool runOnFunction (Function &F) override
bool DoOneIteration (Function &F, unsigned ItNum)
void getAnalysisUsage (AnalysisUsage &AU) const override
AssumptionTrackergetAssumptionTracker () const
const DataLayoutgetDataLayout () const
DominatorTreegetDominatorTree () const
TargetLibraryInfogetTargetLibraryInfo () const
InstructionvisitAdd (BinaryOperator &I)
InstructionvisitFAdd (BinaryOperator &I)
ValueOptimizePointerDifference (Value *LHS, Value *RHS, Type *Ty)
InstructionvisitSub (BinaryOperator &I)
InstructionvisitFSub (BinaryOperator &I)
InstructionvisitMul (BinaryOperator &I)
ValuefoldFMulConst (Instruction *FMulOrDiv, Constant *C, Instruction *InsertBefore)
InstructionvisitFMul (BinaryOperator &I)
InstructionvisitURem (BinaryOperator &I)
InstructionvisitSRem (BinaryOperator &I)
InstructionvisitFRem (BinaryOperator &I)
bool SimplifyDivRemOfSelect (BinaryOperator &I)
InstructioncommonRemTransforms (BinaryOperator &I)
InstructioncommonIRemTransforms (BinaryOperator &I)
 Common integer remainder transforms.
InstructioncommonDivTransforms (BinaryOperator &I)
InstructioncommonIDivTransforms (BinaryOperator &I)
 Common integer divide transforms.
InstructionvisitUDiv (BinaryOperator &I)
InstructionvisitSDiv (BinaryOperator &I)
InstructionvisitFDiv (BinaryOperator &I)
ValueFoldAndOfICmps (ICmpInst *LHS, ICmpInst *RHS)
 FoldAndOfICmps - Fold (icmp)&(icmp) if possible.
ValueFoldAndOfFCmps (FCmpInst *LHS, FCmpInst *RHS)
InstructionvisitAnd (BinaryOperator &I)
ValueFoldOrOfICmps (ICmpInst *LHS, ICmpInst *RHS, Instruction *CxtI)
 FoldOrOfICmps - Fold (icmp)|(icmp) if possible.
ValueFoldOrOfFCmps (FCmpInst *LHS, FCmpInst *RHS)
InstructionFoldOrWithConstants (BinaryOperator &I, Value *Op, Value *A, Value *B, Value *C)
InstructionFoldXorWithConstants (BinaryOperator &I, Value *Op, Value *A, Value *B, Value *C)
 This helper function folds:
InstructionvisitOr (BinaryOperator &I)
InstructionvisitXor (BinaryOperator &I)
InstructionvisitShl (BinaryOperator &I)
InstructionvisitAShr (BinaryOperator &I)
InstructionvisitLShr (BinaryOperator &I)
InstructioncommonShiftTransforms (BinaryOperator &I)
InstructionFoldFCmp_IntToFP_Cst (FCmpInst &I, Instruction *LHSI, Constant *RHSC)
InstructionFoldCmpLoadFromIndexedGlobal (GetElementPtrInst *GEP, GlobalVariable *GV, CmpInst &ICI, ConstantInt *AndCst=nullptr)
InstructionvisitFCmpInst (FCmpInst &I)
InstructionvisitICmpInst (ICmpInst &I)
InstructionvisitICmpInstWithCastAndCast (ICmpInst &ICI)
InstructionvisitICmpInstWithInstAndIntCst (ICmpInst &ICI, Instruction *LHS, ConstantInt *RHS)
InstructionFoldICmpDivCst (ICmpInst &ICI, BinaryOperator *DivI, ConstantInt *DivRHS)
InstructionFoldICmpShrCst (ICmpInst &ICI, BinaryOperator *DivI, ConstantInt *DivRHS)
 FoldICmpShrCst - Handle "icmp(([al]shr X, cst1), cst2)".
InstructionFoldICmpCstShrCst (ICmpInst &I, Value *Op, Value *A, ConstantInt *CI1, ConstantInt *CI2)
InstructionFoldICmpAddOpCst (Instruction &ICI, Value *X, ConstantInt *CI, ICmpInst::Predicate Pred)
 FoldICmpAddOpCst - Fold "icmp pred (X+CI), X".
InstructionFoldGEPICmp (GEPOperator *GEPLHS, Value *RHS, ICmpInst::Predicate Cond, Instruction &I)
InstructionFoldShiftByConstant (Value *Op0, Constant *Op1, BinaryOperator &I)
InstructioncommonCastTransforms (CastInst &CI)
 Implement the transforms common to all CastInst visitors.
InstructioncommonPointerCastTransforms (CastInst &CI)
 Implement the transforms for cast of pointer (bitcast/ptrtoint)
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)
InstructionFoldSelectOpOp (SelectInst &SI, Instruction *TI, Instruction *FI)
InstructionFoldSelectIntoOp (SelectInst &SI, Value *, Value *)
InstructionFoldSPFofSPF (Instruction *Inner, SelectPatternFlavor SPF1, Value *A, Value *B, Instruction &Outer, SelectPatternFlavor SPF2, Value *C)
InstructionvisitSelectInst (SelectInst &SI)
InstructionvisitSelectInstWithICmp (SelectInst &SI, ICmpInst *ICI)
InstructionvisitCallInst (CallInst &CI)
InstructionvisitInvokeInst (InvokeInst &II)
InstructionSliceUpIllegalIntegerPHI (PHINode &PN)
InstructionvisitPHINode (PHINode &PN)
InstructionvisitGetElementPtrInst (GetElementPtrInst &GEP)
InstructionvisitAllocaInst (AllocaInst &AI)
InstructionvisitAllocSite (Instruction &FI)
InstructionvisitFree (CallInst &FI)
InstructionvisitLoadInst (LoadInst &LI)
InstructionvisitStoreInst (StoreInst &SI)
InstructionvisitBranchInst (BranchInst &BI)
InstructionvisitSwitchInst (SwitchInst &SI)
InstructionvisitReturnInst (ReturnInst &RI)
InstructionvisitInsertValueInst (InsertValueInst &IV)
InstructionvisitInsertElementInst (InsertElementInst &IE)
InstructionvisitExtractElementInst (ExtractElementInst &EI)
InstructionvisitShuffleVectorInst (ShuffleVectorInst &SVI)
InstructionvisitExtractValueInst (ExtractValueInst &EV)
InstructionvisitLandingPadInst (LandingPadInst &LI)
InstructionvisitInstruction (Instruction &I)
InstructionInsertNewInstBefore (Instruction *New, Instruction &Old)
InstructionInsertNewInstWith (Instruction *New, Instruction &Old)
InstructionReplaceInstUsesWith (Instruction &I, Value *V)
InstructionEraseInstFromFunction (Instruction &I)
void computeKnownBits (Value *V, APInt &KnownZero, APInt &KnownOne, unsigned Depth=0, Instruction *CxtI=nullptr) const
bool MaskedValueIsZero (Value *V, const APInt &Mask, unsigned Depth=0, Instruction *CxtI=nullptr) const
unsigned ComputeNumSignBits (Value *Op, unsigned Depth=0, Instruction *CxtI=nullptr) const

Public Attributes

InstCombineWorklist Worklist
 Worklist - All of the instructions that need to be simplified.
BuilderTyBuilder

Static Public Attributes

static char ID = 0

Detailed Description

InstCombiner - The -instcombine pass.

Definition at line 95 of file InstCombine.h.


Member Typedef Documentation

Builder - This is an IRBuilder that automatically inserts new instructions into the worklist when they are created.

Definition at line 112 of file InstCombine.h.


Constructor & Destructor Documentation


Member Function Documentation

Common integer remainder transforms.

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.

Definition at line 1243 of file InstCombineMulDivRem.cpp.

References llvm::User::getOperand(), I, llvm::AArch64CC::NV, llvm::User::setOperand(), and simplifyValueKnownNonZero().

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

Definition at line 1436 of file InstCombineCasts.cpp.

References llvm::dyn_cast(), llvm::User::getOperand(), llvm::APInt::getSExtValue(), llvm::Value::getType(), llvm::User::setOperand(), and llvm::Value::takeName().

void llvm::InstCombiner::computeKnownBits ( Value V,
APInt KnownZero,
APInt KnownOne,
unsigned  Depth = 0,
Instruction CxtI = nullptr 
) const [inline]

Definition at line 340 of file InstCombine.h.

References llvm::computeKnownBits().

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

Definition at line 351 of file InstCombine.h.

References llvm::ComputeNumSignBits().

Referenced by ProcessUGT_ADDCST_ADD().

FoldAndOfFCmps - Optimize (fcmp)&(fcmp). NOTE: Unlike the rest of instcombine, this returns a Value which should already be inserted into the function.

Definition at line 1027 of file InstCombineAndOrXor.cpp.

References llvm::CmpInst::FCMP_FALSE, llvm::CmpInst::FCMP_ORD, llvm::CmpInst::FCMP_TRUE, llvm::ConstantInt::get(), getFCmpCode(), getFCmpValue(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::PPC::getSwappedPredicate(), llvm::Value::getType(), llvm::CmpInst::makeCmpResultType(), and std::swap().

FoldCmpLoadFromIndexedGlobal - Called 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 220 of file InstCombineCompares.cpp.

References llvm::CallingConv::C, llvm::ConstantFoldCompareInstOperands(), llvm::dyn_cast(), llvm::SmallVectorBase::empty(), llvm::ConstantInt::get(), llvm::Constant::getAggregateElement(), llvm::ConstantExpr::getAnd(), llvm::Type::getArrayElementType(), llvm::Type::getArrayNumElements(), llvm::Value::getContext(), llvm::ConstantExpr::getExtractValue(), llvm::GlobalVariable::getInitializer(), llvm::Type::getInt32Ty(), llvm::Type::getIntegerBitWidth(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::Type::getPrimitiveSizeInBits(), llvm::Intrinsic::getType(), llvm::Value::getType(), llvm::GetElementPtrInst::getType(), llvm::ConstantInt::getZExtValue(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::GetElementPtrInst::isInBounds(), isZero(), and llvm::SmallVectorTemplateBase< T, isPodLike >::push_back().

Value * InstCombiner::foldFMulConst ( Instruction FMulOrDiv,
Constant C,
Instruction InsertBefore 
)

foldFMulConst() is a helper routine of InstCombiner::visitFMul(). The input FMulOrDiv is a FMul/FDiv with one and only one operand being a constant (i.e. isFMulOrFDivWithConstant(FMulOrDiv) == true). This function is to simplify "FMulOrDiv * C" and returns the resulting expression. Note that this function could return NULL in case the constants cannot be folded into a normal floating-point.

Definition at line 405 of file InstCombineMulDivRem.cpp.

References llvm::dyn_cast(), F(), llvm::ConstantExpr::getFDiv(), llvm::ConstantExpr::getFMul(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Value::hasOneUse(), isFMulOrFDivWithConstant(), and isNormalFp().

Instruction * InstCombiner::FoldICmpCstShrCst ( ICmpInst I,
Value Op,
Value A,
ConstantInt CI1,
ConstantInt CI2 
)

FoldOrOfFCmps - Optimize (fcmp)|(fcmp). NOTE: Unlike the rest of instcombine, this returns a Value which should already be inserted into the function.

Definition at line 1911 of file InstCombineAndOrXor.cpp.

References llvm::CmpInst::FCMP_FALSE, llvm::CmpInst::FCMP_TRUE, llvm::CmpInst::FCMP_UNO, llvm::ConstantInt::get(), getFCmpCode(), getFCmpValue(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::PPC::getSwappedPredicate(), llvm::Value::getType(), llvm::CmpInst::makeCmpResultType(), and std::swap().

Value * InstCombiner::FoldOrOfICmps ( ICmpInst LHS,
ICmpInst RHS,
Instruction CxtI 
)

FoldOrWithConstants - This helper function folds:

((A | B) & C1) | (B & C2)

into:

(A & C1) | B

when the XOR of the two constants is "all ones" (-1).

Definition at line 1977 of file InstCombineAndOrXor.cpp.

References llvm::CallingConv::C, llvm::dyn_cast(), llvm::ConstantInt::getValue(), llvm::APInt::isAllOnesValue(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and llvm::APIntOps::Xor().

Instruction * InstCombiner::FoldSelectIntoOp ( SelectInst SI,
Value TrueVal,
Value FalseVal 
)
Instruction * InstCombiner::FoldSPFofSPF ( Instruction Inner,
SelectPatternFlavor  SPF1,
Value A,
Value B,
Instruction Outer,
SelectPatternFlavor  SPF2,
Value C 
)

This helper function folds:

((A | B) & C1) ^ (B & C2)

into:

(A & C1) ^ B

when the XOR of the two constants is "all ones" (-1).

Definition at line 2006 of file InstCombineAndOrXor.cpp.

References llvm::CallingConv::C, llvm::dyn_cast(), llvm::ConstantInt::getValue(), llvm::APInt::isAllOnesValue(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and llvm::APIntOps::Xor().

Combine redundant false void InstCombiner::getAnalysisUsage ( AnalysisUsage ) const [override, virtual]

getAnalysisUsage - This function should be overriden by passes that need analysis information to do their job. If a pass specifies that it uses a particular analysis result to this function, it can then use the getAnalysis<AnalysisType>() function, below.

Reimplemented from llvm::Pass.

Definition at line 96 of file InstructionCombining.cpp.

Definition at line 128 of file InstCombine.h.

Referenced by simplifyValueKnownNonZero().

Definition at line 132 of file InstCombine.h.

Referenced by simplifyValueKnownNonZero().

Definition at line 134 of file InstCombine.h.

Referenced by GetShiftedValue().

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

Definition at line 346 of file InstCombine.h.

References llvm::MaskedValueIsZero().

Value * InstCombiner::OptimizePointerDifference ( Value LHS,
Value RHS,
Type Ty 
)

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 1459 of file InstCombineAddSub.cpp.

References llvm::EmitGEPOffset().

bool InstCombiner::runOnFunction ( Function F) [override, virtual]

runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.

Builder - This is an IRBuilder that automatically inserts new instructions into the worklist when they are created.

Implements llvm::FunctionPass.

Definition at line 2929 of file InstructionCombining.cpp.

References llvm::AttributeSet::FunctionIndex, llvm::Function::getAttributes(), llvm::Function::getContext(), llvm::DataLayoutPass::getDataLayout(), llvm::DominatorTreeWrapperPass::getDomTree(), llvm::AttributeSet::hasAttribute(), llvm::LowerDbgDeclare(), and llvm::Attribute::MinSize.

SimplifyDivRemOfSelect - Try to fold a divide or remainder of a select instruction.

Definition at line 631 of file InstCombineMulDivRem.cpp.

References llvm::BasicBlock::begin(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::Value::hasOneUse(), I, llvm::User::setOperand(), llvm::AArch64DB::ST, and llvm::Value::use_empty().

SliceUpIllegalIntegerPHI - 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 618 of file InstCombinePHI.cpp.

References llvm::PHINode::addIncoming(), llvm::array_pod_sort(), llvm::SmallVectorTemplateCommon< T >::begin(), Builder, llvm::SmallPtrSetImpl< PtrType >::count(), llvm::PHINode::Create(), llvm::IRBuilder< preserveNames, T, Inserter >::CreateLShr(), llvm::IRBuilder< preserveNames, T, Inserter >::CreateTrunc(), llvm::dbgs(), DEBUG, llvm::dyn_cast(), llvm::SmallVectorBase::empty(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::ConstantInt::get(), llvm::UndefValue::get(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::Value::hasOneUse(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::LShr, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), ReplaceInstUsesWith(), llvm::IRBuilderBase::SetInsertPoint(), llvm::SmallVectorTemplateCommon< T >::size(), llvm::RegState::Undef, llvm::Instruction::user_back(), and llvm::Value::users().

Referenced by visitPHINode().

visitCallInst - CallInst simplification. This mostly only handles folding of intrinsic instructions. For normal calls, it allows visitCallSite to do the heavy lifting.

Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.

Definition at line 203 of file InstCombineCalls.cpp.

References llvm::ARM_PROC::A, llvm::CallingConv::C, llvm::computeKnownBits(), llvm::CastInst::Create(), llvm::SelectInst::Create(), llvm::InsertValueInst::Create(), llvm::CastInst::CreateIntegerCast(), llvm::APFloat::divide(), llvm::Function::doesNotThrow(), llvm::CallInst::doesNotThrow(), llvm::dyn_cast(), F(), llvm::ConstantInt::get(), llvm::ConstantFP::get(), llvm::ConstantAggregateZero::get(), llvm::ConstantStruct::get(), llvm::ConstantVector::get(), llvm::ConstantDataVector::get(), llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), llvm::CallInst::getArgOperand(), llvm::APInt::getBitsSet(), getBitWidth(), llvm::IntegerType::getBitWidth(), llvm::Value::getContext(), llvm::Intrinsic::getDeclaration(), llvm::ConstantInt::getFalse(), llvm::APInt::getHighBitsSet(), llvm::Type::getInt32Ty(), llvm::ConstantExpr::getIntegerCast(), llvm::IntrinsicInst::getIntrinsicID(), llvm::getKnownAlignment(), llvm::APInt::getLowBitsSet(), llvm::ConstantExpr::getMul(), llvm::Constant::getNullValue(), llvm::getObjectSize(), llvm::getOrEnforceKnownAlignment(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::Type::getPrimitiveSizeInBits(), llvm::APFloat::getSemantics(), llvm::BasicBlock::getTerminator(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::PointerType::getUnqual(), llvm::ConstantInt::getZExtValue(), I, llvm::isFreeCall(), IT(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_BSwap(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::makeArrayRef(), llvm::PatternMatch::match(), llvm::LibFunc::memcpy, llvm::LibFunc::memset, llvm::APFloat::opOK, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::APFloat::rmNearestTiesToEven, llvm::CallInst::setArgOperand(), llvm::CallInst::setCalledFunction(), llvm::CallInst::setDoesNotThrow(), llvm::Sched::Source, llvm::AArch64DB::ST, std::swap(), llvm::Value::takeName(), llvm::APInt::umul_ov(), llvm::RegState::Undef, llvm::NVPTX::PTXLdStInstCode::V2, and llvm::X.

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.

Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.

Definition at line 3608 of file InstCombineCompares.cpp.

References llvm::Call, llvm::APFloat::clearSign(), llvm::APFloat::cmpLessThan, llvm::APFloat::compare(), llvm::APFloat::convert(), llvm::dyn_cast(), F(), llvm::LibFunc::fabs, llvm::LibFunc::fabsf, llvm::LibFunc::fabsl, 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_UGT, llvm::CmpInst::FCMP_ULT, llvm::CmpInst::FCMP_UNE, llvm::CmpInst::FCMP_UNO, llvm::FPExt, llvm::ConstantFP::get(), llvm::CallInst::getArgOperand(), llvm::CallInst::getCalledFunction(), llvm::getComplexity(), llvm::ConstantExpr::getFNeg(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::CmpInst::getPredicate(), llvm::APFloat::getSmallestNormalized(), llvm::CastInst::getSrcTy(), llvm::CmpInst::getSwappedPredicate(), llvm::Value::getType(), I, llvm::APFloat::IEEEdouble, llvm::APFloat::IEEEhalf, llvm::APFloat::IEEEquad, llvm::APFloat::IEEEsingle, llvm::Type::isDoubleTy(), llvm::Type::isFloatTy(), llvm::Type::isFP128Ty(), llvm::Type::isHalfTy(), llvm::Type::isPPC_FP128Ty(), llvm::Type::isX86_FP80Ty(), llvm::APFloat::isZero(), llvm_unreachable, llvm::SPII::Load, llvm::PatternMatch::m_FNeg(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::AArch64CC::NV, llvm::TargetOpcode::PHI, llvm::APFloat::PPCDoubleDouble, llvm::APFloat::rmNearestTiesToEven, llvm::User::setOperand(), llvm::CmpInst::setPredicate(), llvm::SimplifyFCmpInst(), llvm::SIToFP, llvm::FCmpInst::swapOperands(), llvm::X, llvm::APFloat::x87DoubleExtended, and Y.

Definition at line 1359 of file InstCombineCasts.cpp.

Definition at line 1385 of file InstCombineMulDivRem.cpp.

References llvm::User::getOperand(), I, and llvm::SimplifyFRemInst().

See if we can simplify: X = bitcast A* to B* Y = gep X, <...constant indices...> into a gep of the original struct. This is important for SROA and alias analysis of unions. If "A" is also a bitcast, wait for A/X to be merged.

Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.

Definition at line 1319 of file InstructionCombining.cpp.

References llvm::GetElementPtrInst::accumulateConstantOffset(), llvm::PHINode::addIncoming(), llvm::SmallVectorImpl< T >::append(), llvm::CallingConv::C, llvm::Instruction::clone(), llvm::CastInst::Create(), llvm::GetElementPtrInst::Create(), llvm::GetElementPtrInst::CreateInBounds(), llvm::CastInst::CreatePointerBitCastOrAddrSpaceCast(), llvm::dyn_cast(), llvm::SmallVectorBase::empty(), F(), llvm::gep_type_begin(), llvm::gep_type_end(), llvm::PointerType::getAddressSpace(), llvm::GetElementPtrInst::getAddressSpace(), llvm::Type::getArrayElementType(), llvm::SequentialType::getElementType(), llvm::BasicBlock::getFirstNonPHI(), llvm::PHINode::getIncomingBlock(), llvm::BasicBlock::getInstList(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::GetElementPtrInst::getNumIndices(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::Type::getPointerAddressSpace(), llvm::GetElementPtrInst::getPointerAddressSpace(), llvm::Type::getPointerElementType(), llvm::GetElementPtrInst::getPointerOperandType(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::APInt::getSExtValue(), llvm::Value::getType(), llvm::GetElementPtrInst::getType(), I, llvm::GetElementPtrInst::idx_begin(), llvm::GetElementPtrInst::idx_end(), llvm::iplist< NodeTy, Traits >::insert(), llvm::IntToPtr, llvm::isAllocationFn(), llvm::Type::isArrayTy(), llvm::GetElementPtrInst::isInBounds(), llvm::Type::isSized(), llvm::Type::isStructTy(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Neg(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_SDiv(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::User::op_begin(), llvm::User::op_end(), llvm::User::operands(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::User::setOperand(), shouldMergeGEPs(), llvm::SimplifyGEPInst(), llvm::Value::stripPointerCasts(), llvm::Value::takeName(), and Y.

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.

Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.

Definition at line 2432 of file InstCombineCompares.cpp.

References llvm::ARM_PROC::A, llvm::APInt::abs(), llvm::CallingConv::C, ComputeSignedMinMaxValuesFromKnownBits(), ComputeUnsignedMinMaxValuesFromKnownBits(), llvm::APInt::countTrailingZeros(), llvm::CmpInst::Create(), llvm::SelectInst::Create(), llvm::BinaryOperator::CreateNot(), DemandedBitsLHSMask(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::Constant::getAllOnesValue(), llvm::APInt::getAllOnesValue(), llvm::ConstantExpr::getBitCast(), getBitWidth(), llvm::ConstantInt::getBitWidth(), llvm::APInt::getBitWidth(), llvm::getComplexity(), llvm::Value::getContext(), llvm::ConstantInt::getFalse(), llvm::ConstantExpr::getICmp(), llvm::CmpInst::getInversePredicate(), llvm::ConstantInt::getLimitedValue(), llvm::APInt::getLowBitsSet(), llvm::Value::getName(), llvm::ConstantExpr::getNeg(), llvm::ConstantExpr::getNot(), llvm::Constant::getNullValue(), llvm::APInt::getOneBitSet(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::User::getOperandUse(), llvm::Instruction::getParent(), llvm::CmpInst::getPredicate(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::ICmpInst::getSignedPredicate(), llvm::CmpInst::getSwappedPredicate(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::ICmpInst::getUnsignedPredicate(), llvm::ConstantInt::getValue(), llvm::BinaryOperator::hasNoSignedWrap(), llvm::BinaryOperator::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::IntToPtr, llvm::ICmpInst::isEquality(), llvm::BinaryOperator::isExact(), llvm::Type::isIntegerTy(), llvm::Type::isIntOrIntVectorTy(), llvm::isKnownToBeAPowerOfTwo(), llvm::APInt::isNegative(), llvm::Type::isPointerTy(), llvm::APInt::isPowerOf2(), isSignBitCheck(), llvm::CmpInst::isSigned(), llvm::CmpInst::isUnsigned(), llvm_unreachable, llvm::SPII::Load, llvm::APInt::logBase2(), llvm::LShr, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_Neg(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), NC, llvm::APIntOps::Not(), llvm::AArch64CC::NV, llvm::TargetOpcode::PHI, ProcessUAddIdiom(), ProcessUGT_ADDCST_ADD(), ProcessUMulZExtIdiom(), llvm::MCID::Select, llvm::User::setOperand(), llvm::SimplifyICmpInst(), llvm::APInt::sle(), llvm::APInt::slt(), std::swap(), swapMayExposeCSEOpportunities(), llvm::ICmpInst::swapOperands(), llvm::APInt::uge(), llvm::APInt::ule(), llvm::APInt::ult(), llvm::Value::user_begin(), llvm::X, llvm::APIntOps::Xor(), Y, and llvm::APInt::zext().

visitICmpInstWithInstAndIntCst - Handle "icmp (instr, intcst)".

Definition at line 1123 of file InstCombineCompares.cpp.

References llvm::AddOne(), llvm::APIntOps::And(), llvm::APInt::byteSwap(), llvm::CallingConv::C, llvm::computeKnownBits(), llvm::APInt::countTrailingZeros(), llvm::dyn_cast(), llvm::IntegerType::get(), llvm::ConstantInt::get(), llvm::ConstantExpr::get(), llvm::APInt::getActiveBits(), llvm::ConstantExpr::getAnd(), llvm::ConstantExpr::getAShr(), getBitWidth(), llvm::IntegerType::getBitWidth(), llvm::ConstantInt::getBitWidth(), llvm::APInt::getBitWidth(), llvm::Value::getContext(), llvm::APInt::getHighBitsSet(), llvm::ConstantInt::getLimitedValue(), llvm::APInt::getLowBitsSet(), llvm::ConstantRange::getLower(), llvm::ConstantExpr::getLShr(), llvm::Value::getName(), llvm::ConstantExpr::getNeg(), llvm::ConstantExpr::getNot(), llvm::Constant::getNullValue(), llvm::ConstantExpr::getNUWShl(), llvm::APInt::getOneBitSet(), llvm::Instruction::getOpcode(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::ConstantExpr::getOr(), llvm::CmpInst::getPredicate(), llvm::Type::getPrimitiveSizeInBits(), llvm::ConstantExpr::getShl(), llvm::ICmpInst::getSignedPredicate(), llvm::ConstantExpr::getSub(), llvm::PPC::getSwappedPredicate(), llvm::CmpInst::getSwappedPredicate(), llvm::ConstantExpr::getTrunc(), llvm::ConstantInt::getType(), llvm::Value::getType(), llvm::ICmpInst::getUnsignedPredicate(), llvm::ConstantRange::getUpper(), llvm::ConstantInt::getValue(), llvm::ConstantExpr::getXor(), llvm::ConstantExpr::getZExt(), llvm::ConstantInt::getZExtValue(), llvm::Value::hasOneUse(), 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::APInt::isAllOnesValue(), llvm::Instruction::isArithmeticShift(), llvm::ICmpInst::isEquality(), llvm::BinaryOperator::isExact(), isHighOnes(), llvm::APInt::isMinValue(), llvm::ConstantInt::isNegative(), llvm::APInt::isNonNegative(), llvm::Constant::isNullValue(), llvm::APInt::isPowerOf2(), llvm::Instruction::isShift(), llvm::APInt::isSignBit(), isSignBitCheck(), llvm::CmpInst::isSigned(), isSignTest(), llvm::CmpInst::isUnsigned(), llvm::ConstantInt::isZero(), LI, llvm::APInt::logBase2(), llvm::LShr, llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::ICmpInst::makeConstantRange(), llvm::PatternMatch::match(), llvm::APIntOps::Or(), P, llvm::User::setOperand(), llvm::APInt::sgt(), llvm::SubOne(), llvm::Value::takeName(), llvm::Trunc, llvm::ConstantInt::uge(), llvm::X, llvm::APIntOps::Xor(), Y, and llvm::APInt::zext().

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

Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.

Definition at line 500 of file InstCombineVectorOps.cpp.

References llvm::dyn_cast(), llvm::InsertValueInst::getIndices(), llvm::User::getOperand(), llvm::Value::hasOneUse(), I, and llvm::Value::user_back().

Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.

Definition at line 244 of file InstCombine.h.

Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.

Definition at line 1028 of file InstCombineCalls.cpp.

Definition at line 1407 of file InstCombineCasts.cpp.

Definition at line 1403 of file InstCombineCasts.cpp.


Member Data Documentation

char InstCombiner::ID = 0 [static]

Definition at line 115 of file InstCombine.h.

Worklist - All of the instructions that need to be simplified.

Definition at line 108 of file InstCombine.h.

Referenced by AddReachableCodeToWorklist(), GetShiftedValue(), ProcessUMulZExtIdiom(), and visitStoreInst().


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