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 ()
virtual bool runOnFunction (Function &F)
bool DoOneIteration (Function &F, unsigned ItNum)
virtual void getAnalysisUsage (AnalysisUsage &AU) const
DataLayoutgetDataLayout () 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, ConstantFP *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)
 FoldOrOfICmps - Fold (icmp)|(icmp) if possible.
ValueFoldOrOfFCmps (FCmpInst *LHS, FCmpInst *RHS)
InstructionFoldOrWithConstants (BinaryOperator &I, Value *Op, Value *A, Value *B, Value *C)
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=0)
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)".
InstructionFoldICmpAddOpCst (ICmpInst &ICI, Value *X, ConstantInt *CI, ICmpInst::Predicate Pred, Value *TheAdd)
 FoldICmpAddOpCst - Fold "icmp pred (X+CI), X".
InstructionFoldGEPICmp (GEPOperator *GEPLHS, Value *RHS, ICmpInst::Predicate Cond, Instruction &I)
InstructionFoldShiftByConstant (Value *Op0, ConstantInt *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)
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)
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 ComputeMaskedBits (Value *V, APInt &KnownZero, APInt &KnownOne, unsigned Depth=0) const
bool MaskedValueIsZero (Value *V, const APInt &Mask, unsigned Depth=0) const
unsigned ComputeNumSignBits (Value *Op, unsigned Depth=0) 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 72 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 86 of file InstCombine.h.


Constructor & Destructor Documentation

llvm::InstCombiner::InstCombiner ( ) [inline]

Member Function Documentation

Instruction * InstCombiner::commonCastTransforms ( CastInst CI)
Instruction* llvm::InstCombiner::commonDivTransforms ( BinaryOperator I)
Instruction * InstCombiner::commonIDivTransforms ( BinaryOperator I)
Instruction * InstCombiner::commonIRemTransforms ( BinaryOperator I)

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 989 of file InstCombineMulDivRem.cpp.

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

Instruction * InstCombiner::commonPointerCastTransforms ( CastInst CI)

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

Definition at line 1358 of file InstCombineCasts.cpp.

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

Instruction* llvm::InstCombiner::commonRemTransforms ( BinaryOperator I)
Instruction * InstCombiner::commonShiftTransforms ( BinaryOperator I)
void llvm::InstCombiner::ComputeMaskedBits ( Value V,
APInt KnownZero,
APInt KnownOne,
unsigned  Depth = 0 
) const [inline]

Definition at line 301 of file InstCombine.h.

References llvm::ComputeMaskedBits().

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

Definition at line 310 of file InstCombine.h.

References llvm::ComputeNumSignBits().

Referenced by ProcessUGT_ADDCST_ADD().

bool InstCombiner::DoOneIteration ( Function F,
unsigned  ItNum 
)
Instruction* llvm::InstCombiner::EraseInstFromFunction ( Instruction I) [inline]
Value * InstCombiner::FoldAndOfFCmps ( FCmpInst LHS,
FCmpInst RHS 
)
Value * InstCombiner::FoldAndOfICmps ( ICmpInst LHS,
ICmpInst RHS 
)
Instruction * InstCombiner::FoldCmpLoadFromIndexedGlobal ( GetElementPtrInst GEP,
GlobalVariable GV,
CmpInst ICI,
ConstantInt AndCst = 0 
)

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 227 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::ConstantInt::getFalse(), llvm::GlobalVariable::getInitializer(), llvm::Type::getInt32Ty(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::Type::getPrimitiveSizeInBits(), llvm::ConstantInt::getTrue(), getType(), llvm::Value::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().

Instruction * InstCombiner::FoldFCmp_IntToFP_Cst ( FCmpInst I,
Instruction LHSI,
Constant RHSC 
)

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

Definition at line 2830 of file InstCombineCompares.cpp.

References llvm::APFloat::cmpGreaterThan, llvm::APFloat::cmpLessThan, llvm::APFloat::convertFromAPInt(), 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::APFloat::fcZero, llvm::Value::getContext(), llvm::ConstantInt::getFalse(), llvm::Type::getFPMantissaWidth(), llvm::ConstantExpr::getFPToSI(), llvm::ConstantExpr::getFPToUI(), llvm::APInt::getMaxValue(), llvm::APInt::getMinValue(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::Type::getScalarSizeInBits(), llvm::APFloat::getSemantics(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), llvm::ConstantExpr::getSIToFP(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::ConstantExpr::getUIToFP(), 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::APFloat::isNaN(), llvm::APFloat::isNegative(), llvm::APFloat::isZero(), llvm_unreachable, and llvm::APFloat::rmNearestTiesToEven.

Value * InstCombiner::foldFMulConst ( Instruction FMulOrDiv,
ConstantFP 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 325 of file InstCombineMulDivRem.cpp.

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

Instruction * InstCombiner::FoldGEPICmp ( GEPOperator GEPLHS,
Value RHS,
ICmpInst::Predicate  Cond,
Instruction I 
)
Instruction * InstCombiner::FoldICmpAddOpCst ( ICmpInst ICI,
Value X,
ConstantInt CI,
ICmpInst::Predicate  Pred,
Value TheAdd 
)
Instruction * InstCombiner::FoldICmpDivCst ( ICmpInst ICI,
BinaryOperator DivI,
ConstantInt DivRHS 
)
Instruction * InstCombiner::FoldICmpShrCst ( ICmpInst ICI,
BinaryOperator DivI,
ConstantInt DivRHS 
)
Value * InstCombiner::FoldOrOfFCmps ( FCmpInst LHS,
FCmpInst RHS 
)
Value * InstCombiner::FoldOrOfICmps ( ICmpInst LHS,
ICmpInst RHS 
)
Instruction * InstCombiner::FoldOrWithConstants ( BinaryOperator I,
Value Op,
Value A,
Value B,
Value C 
)

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 1736 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::FoldSelectOpOp ( SelectInst SI,
Instruction TI,
Instruction FI 
)
Instruction * InstCombiner::FoldShiftByConstant ( Value Op0,
ConstantInt Op1,
BinaryOperator I 
)
Instruction * InstCombiner::FoldSPFofSPF ( Instruction Inner,
SelectPatternFlavor  SPF1,
Value A,
Value B,
Instruction Outer,
SelectPatternFlavor  SPF2,
Value C 
)

FoldSPFofSPF - We have an SPF (e.g. a min or max) of an SPF of the form: SPF2(SPF1(A, B), C)

Definition at line 632 of file InstCombineSelect.cpp.

References llvm::SPF_SMAX, llvm::SPF_SMIN, llvm::SPF_UMAX, and llvm::SPF_UMIN.

Combine redundant false void InstCombiner::getAnalysisUsage ( AnalysisUsage ) const [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 90 of file InstructionCombining.cpp.

DataLayout* llvm::InstCombiner::getDataLayout ( ) const [inline]
TargetLibraryInfo* llvm::InstCombiner::getTargetLibraryInfo ( ) const [inline]

Definition at line 104 of file InstCombine.h.

Referenced by GetShiftedValue().

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

Definition at line 242 of file InstCombine.h.

References llvm::BasicBlock::getInstList(), and llvm::Instruction::getParent().

Referenced by visitAllocaInst().

Instruction* llvm::InstCombiner::InsertNewInstWith ( Instruction New,
Instruction Old 
) [inline]
bool llvm::InstCombiner::MaskedValueIsZero ( Value V,
const APInt Mask,
unsigned  Depth = 0 
) const [inline]

Definition at line 306 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 1278 of file InstCombineAddSub.cpp.

References llvm::EmitGEPOffset().

Instruction* llvm::InstCombiner::ReplaceInstUsesWith ( Instruction I,
Value V 
) [inline]
bool InstCombiner::runOnFunction ( Function F) [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 2474 of file InstructionCombining.cpp.

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

bool InstCombiner::SimplifyDivRemOfSelect ( BinaryOperator I)
Instruction * InstCombiner::SliceUpIllegalIntegerPHI ( PHINode FirstPhi)

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

References llvm::PHINode::addIncoming(), llvm::array_pod_sort(), llvm::SmallVectorTemplateCommon< T >::begin(), Builder, llvm::SmallPtrSet< PtrType, SmallSize >::count(), llvm::PHINode::Create(), llvm::IRBuilder< preserveNames, T, Inserter >::CreateLShr(), llvm::IRBuilder< preserveNames, T, Inserter >::CreateTrunc(), DEBUG, llvm::dyn_cast(), llvm::SmallVectorBase::empty(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::errs(), 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::SmallPtrSet< PtrType, SmallSize >::insert(), llvm::LShr, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), ReplaceInstUsesWith(), llvm::IRBuilderBase::SetInsertPoint(), llvm::SmallVectorTemplateCommon< T >::size(), llvm::RegState::Undef, llvm::Instruction::use_back(), llvm::Value::use_begin(), and llvm::Value::use_end().

Referenced by visitPHINode().

Instruction * InstCombiner::visitAdd ( BinaryOperator I)
Instruction * InstCombiner::visitAllocaInst ( AllocaInst AI)
Instruction * InstCombiner::visitAllocSite ( Instruction FI)
Instruction * InstCombiner::visitAnd ( BinaryOperator I)
Instruction * InstCombiner::visitAShr ( BinaryOperator I)
Instruction * InstCombiner::visitBitCast ( BitCastInst CI)
Instruction * InstCombiner::visitBranchInst ( BranchInst BI)
Instruction * InstCombiner::visitCallInst ( CallInst CI)

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

Definition at line 201 of file InstCombineCalls.cpp.

References llvm::CallingConv::C, llvm::ComputeMaskedBits(), llvm::APInt::countLeadingZeros(), llvm::APInt::countTrailingZeros(), llvm::CastInst::Create(), llvm::InsertValueInst::Create(), llvm::CastInst::CreateSExtOrBitCast(), llvm::CastInst::CreateZExtOrBitCast(), llvm::Function::doesNotThrow(), llvm::CallInst::doesNotThrow(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantFP::get(), llvm::ConstantAggregateZero::get(), llvm::ConstantStruct::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), llvm::CallInst::getArgOperand(), llvm::APInt::getBitsSet(), getBitWidth(), llvm::IntegerType::getBitWidth(), llvm::Value::getContext(), llvm::Intrinsic::getDeclaration(), llvm::SequentialType::getElementType(), llvm::ConstantInt::getFalse(), llvm::APInt::getHighBitsSet(), llvm::Type::getInt32Ty(), llvm::Type::getIntegerBitWidth(), llvm::IntrinsicInst::getIntrinsicID(), llvm::getKnownAlignment(), llvm::MemIntrinsic::getLength(), llvm::APInt::getLowBitsSet(), llvm::Constant::getNullValue(), llvm::CallInst::getNumArgOperands(), llvm::VectorType::getNumElements(), llvm::getObjectSize(), llvm::getOrEnforceKnownAlignment(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::Type::getPrimitiveSizeInBits(), llvm::BasicBlock::getTerminator(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::PointerType::getUnqual(), llvm::ConstantInt::getZExtValue(), I, llvm::isFreeCall(), llvm::MemIntrinsic::isVolatile(), llvm::PatternMatch::m_BSwap(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::LibFunc::memcpy, llvm::LibFunc::memset, llvm::CallInst::setArgOperand(), llvm::CallInst::setCalledFunction(), llvm::CallInst::setDoesNotThrow(), llvm::APInt::sext(), llvm::A64DB::ST, llvm::swap(), llvm::Value::takeName(), llvm::APInt::umul_ov(), llvm::X, and llvm::APInt::zext().

Instruction * InstCombiner::visitExtractElementInst ( ExtractElementInst EI)
Instruction * InstCombiner::visitExtractValueInst ( ExtractValueInst EV)
Instruction * InstCombiner::visitFAdd ( BinaryOperator I)
Instruction * InstCombiner::visitFCmpInst ( FCmpInst 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 3031 of file InstCombineCompares.cpp.

References llvm::CallingConv::C, llvm::Call, llvm::APFloat::clearSign(), llvm::APFloat::cmpLessThan, llvm::APFloat::compare(), llvm::APFloat::convert(), llvm::SelectInst::Create(), 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::ConstantExpr::getCompare(), 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::A64CC::NV, llvm::PHI, llvm::APFloat::PPCDoubleDouble, llvm::APFloat::rmNearestTiesToEven, llvm::Select, llvm::User::setOperand(), llvm::CmpInst::setPredicate(), llvm::SimplifyFCmpInst(), llvm::SIToFP, llvm::FCmpInst::swapOperands(), llvm::X, llvm::APFloat::x87DoubleExtended, and Y.

Instruction * InstCombiner::visitFDiv ( BinaryOperator I)
Instruction * InstCombiner::visitFMul ( BinaryOperator I)
Instruction * InstCombiner::visitFPExt ( CastInst CI)

Definition at line 1285 of file InstCombineCasts.cpp.

Instruction * InstCombiner::visitFPToSI ( FPToSIInst FI)
Instruction * InstCombiner::visitFPToUI ( FPToUIInst FI)
Instruction * InstCombiner::visitFPTrunc ( FPTruncInst CI)
Instruction * InstCombiner::visitFree ( CallInst FI)
Instruction * InstCombiner::visitFRem ( BinaryOperator I)

Definition at line 1117 of file InstCombineMulDivRem.cpp.

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

Instruction * InstCombiner::visitFSub ( BinaryOperator I)
Instruction * InstCombiner::visitGetElementPtrInst ( GetElementPtrInst GEP)
Instruction * InstCombiner::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 1918 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::APInt::getBitWidth(), llvm::getComplexity(), llvm::Value::getContext(), llvm::ConstantInt::getFalse(), llvm::ConstantExpr::getICmp(), llvm::CmpInst::getInversePredicate(), llvm::APInt::getLowBitsSet(), llvm::Value::getName(), llvm::ConstantExpr::getNot(), llvm::Constant::getNullValue(), 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::ICmp, 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_ConstantInt(), llvm::PatternMatch::m_LShr(), 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_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::A64CC::NV, llvm::PHI, ProcessUAddIdiom(), ProcessUGT_ADDCST_ADD(), llvm::Select, llvm::User::setOperand(), llvm::SimplifyICmpInst(), llvm::APInt::sle(), llvm::APInt::slt(), llvm::swap(), llvm::ICmpInst::swapOperands(), llvm::APInt::uge(), llvm::APInt::ule(), llvm::APInt::ult(), llvm::Value::use_begin(), llvm::X, llvm::APIntOps::Xor(), Y, and llvm::APInt::zext().

Instruction * InstCombiner::visitICmpInstWithCastAndCast ( ICmpInst ICI)
Instruction * InstCombiner::visitICmpInstWithInstAndIntCst ( ICmpInst ICI,
Instruction LHSI,
ConstantInt RHS 
)

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

Definition at line 1054 of file InstCombineCompares.cpp.

References AddOne(), llvm::APIntOps::And(), llvm::APInt::byteSwap(), llvm::CallingConv::C, llvm::ComputeMaskedBits(), 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::ConstantInt::getFalse(), llvm::APInt::getHighBitsSet(), llvm::Type::getInt1Ty(), 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::APInt::getOneBitSet(), llvm::Instruction::getOpcode(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::Type::getPrimitiveSizeInBits(), llvm::ConstantExpr::getShl(), llvm::ICmpInst::getSignedPredicate(), llvm::ConstantExpr::getSub(), llvm::PPC::getSwappedPredicate(), llvm::CmpInst::getSwappedPredicate(), llvm::ConstantInt::getTrue(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::ConstantInt::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_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::Instruction::isArithmeticShift(), llvm::ICmpInst::isEquality(), llvm::BinaryOperator::isExact(), isHighOnes(), llvm::Instruction::isLogicalShift(), 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::ConstantInt::isZero(), LI, llvm::LShr, llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_Value(), llvm::ICmpInst::makeConstantRange(), llvm::PatternMatch::match(), llvm::APIntOps::Or(), P, llvm::User::setOperand(), llvm::APInt::sgt(), SubOne(), llvm::Value::takeName(), llvm::Trunc, llvm::ConstantInt::uge(), llvm::X, llvm::APIntOps::Xor(), and llvm::APInt::zext().

Instruction * InstCombiner::visitInsertElementInst ( InsertElementInst IE)
Instruction* llvm::InstCombiner::visitInstruction ( Instruction I) [inline]

Definition at line 209 of file InstCombine.h.

Instruction * InstCombiner::visitIntToPtr ( IntToPtrInst CI)
Instruction * InstCombiner::visitInvokeInst ( InvokeInst II)

Definition at line 757 of file InstCombineCalls.cpp.

Instruction * InstCombiner::visitLandingPadInst ( LandingPadInst LI)
Instruction * InstCombiner::visitLoadInst ( LoadInst LI)
Instruction * InstCombiner::visitLShr ( BinaryOperator I)
Instruction * InstCombiner::visitMul ( BinaryOperator I)
Instruction * InstCombiner::visitOr ( BinaryOperator I)
Instruction * InstCombiner::visitPHINode ( PHINode PN)
Instruction * InstCombiner::visitPtrToInt ( PtrToIntInst CI)
Instruction * InstCombiner::visitSDiv ( BinaryOperator I)
Instruction * InstCombiner::visitSelectInst ( SelectInst SI)
Instruction * InstCombiner::visitSelectInstWithICmp ( SelectInst SI,
ICmpInst ICI 
)
Instruction * InstCombiner::visitSExt ( SExtInst CI)
Instruction * InstCombiner::visitShl ( BinaryOperator I)
Instruction * InstCombiner::visitShuffleVectorInst ( ShuffleVectorInst SVI)
Instruction * InstCombiner::visitSIToFP ( CastInst CI)

Definition at line 1333 of file InstCombineCasts.cpp.

Instruction * InstCombiner::visitSRem ( BinaryOperator I)
Instruction * InstCombiner::visitStoreInst ( StoreInst SI)
Instruction * InstCombiner::visitSub ( BinaryOperator I)
Instruction * InstCombiner::visitSwitchInst ( SwitchInst SI)
Instruction * InstCombiner::visitTrunc ( TruncInst CI)
Instruction * InstCombiner::visitUDiv ( BinaryOperator I)
Instruction * InstCombiner::visitUIToFP ( CastInst CI)

Definition at line 1329 of file InstCombineCasts.cpp.

Instruction * InstCombiner::visitURem ( BinaryOperator I)
Instruction * InstCombiner::visitXor ( BinaryOperator I)
Instruction * InstCombiner::visitZExt ( ZExtInst CI)

Member Data Documentation

char InstCombiner::ID = 0 [static]

Definition at line 89 of file InstCombine.h.

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

Definition at line 82 of file InstCombine.h.

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


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