LLVM API Documentation
InstCombiner - The -instcombine pass. More...
#include <InstCombine.h>
InstCombiner - The -instcombine pass.
Definition at line 95 of file InstCombine.h.
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.
llvm::InstCombiner::InstCombiner | ( | ) | [inline] |
Definition at line 116 of file InstCombine.h.
References llvm::PassRegistry::getPassRegistry(), and llvm::initializeInstCombinerPass().
Implement the transforms common to all CastInst visitors.
Definition at line 294 of file InstCombineCasts.cpp.
References llvm::CastInst::Create(), llvm::CastInst::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), isEliminableCastPair(), llvm::Type::isIntegerTy(), and llvm::AArch64CC::NV.
Common integer divide transforms.
This function implements the transforms common to both integer division instructions (udiv and sdiv). It is called by the visitors to those integer division instructions.
Definition at line 704 of file InstCombineMulDivRem.cpp.
References llvm::BinaryOperator::Create(), llvm::SelectInst::Create(), llvm::ConstantInt::get(), llvm::APInt::getBitWidth(), llvm::APInt::getLimitedValue(), llvm::ConstantExpr::getMul(), llvm::Constant::getNullValue(), llvm::APInt::getOneBitSet(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), I, llvm::BinaryOperator::isExact(), llvm::Type::isIntegerTy(), IsMultiple(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_NSWMul(), llvm::PatternMatch::m_NSWShl(), llvm::PatternMatch::m_NUWMul(), llvm::PatternMatch::m_NUWShl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SRem(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_URem(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), MultiplyOverflows(), llvm::AArch64CC::NV, llvm::BinaryOperator::setHasNoSignedWrap(), llvm::BinaryOperator::setHasNoUnsignedWrap(), llvm::BinaryOperator::setIsExact(), llvm::User::setOperand(), simplifyValueKnownNonZero(), and llvm::X.
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().
Definition at line 24 of file InstCombineShifts.cpp.
References llvm::ARM_PROC::A, llvm::ConstantInt::get(), llvm::Value::getName(), llvm::User::getOperand(), llvm::Value::getType(), I, llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_SRem(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and llvm::User::setOperand().
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().
bool InstCombiner::DoOneIteration | ( | Function & | F, |
unsigned | ItNum | ||
) |
Definition at line 2739 of file InstructionCombining.cpp.
References AddReachableCodeToWorklist(), llvm::Function::begin(), llvm::ConstantFoldInstruction(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dbgs(), DEBUG, llvm::Function::end(), llvm::Instruction::eraseFromParent(), llvm::UndefValue::get(), llvm::Instruction::getDebugLoc(), llvm::BasicBlock::getFirstInsertionPt(), llvm::PHINode::getIncomingBlock(), llvm::BasicBlock::getInstList(), llvm::Value::getName(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::Value::getType(), llvm::Value::hasOneUse(), I, llvm::iplist< NodeTy, Traits >::insert(), llvm::isInstructionTriviallyDead(), llvm::DebugLoc::isUnknown(), llvm::User::operands(), llvm::Value::print(), llvm::Value::replaceAllUsesWith(), llvm::succ_begin(), llvm::succ_end(), TryToSinkInstruction(), llvm::Value::use_begin(), llvm::Value::use_empty(), and llvm::Value::user_begin().
Instruction* llvm::InstCombiner::EraseInstFromFunction | ( | Instruction & | I | ) | [inline] |
Definition at line 323 of file InstCombine.h.
References llvm::dbgs(), DEBUG, llvm::Instruction::eraseFromParent(), llvm::User::getNumOperands(), llvm::User::op_begin(), llvm::User::op_end(), and llvm::Value::use_empty().
Referenced by visitAllocaInst(), and visitStoreInst().
Value * InstCombiner::FoldAndOfFCmps | ( | FCmpInst * | LHS, |
FCmpInst * | RHS | ||
) |
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().
Value * InstCombiner::FoldAndOfICmps | ( | ICmpInst * | LHS, |
ICmpInst * | RHS | ||
) |
FoldAndOfICmps - Fold (icmp)&(icmp) if possible.
Definition at line 791 of file InstCombineAndOrXor.cpp.
References llvm::AddOne(), llvm::tgtok::Code, llvm::dyn_cast(), foldLogOpOfMaskedICmps(), llvm::ConstantInt::get(), llvm::IntegerType::getBitWidth(), llvm::Type::getContext(), llvm::getICmpCode(), llvm::APInt::getLowBitsSet(), llvm::Value::getName(), llvm::ConstantExpr::getNeg(), getNewICmpValue(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::ConstantInt::getType(), llvm::Value::getType(), llvm::ConstantInt::getValue(), 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_ULT, llvm::ConstantRange::intersectWith(), llvm::APInt::isAllOnesValue(), llvm::ConstantRange::isEmptySet(), llvm::ICmpInst::isEquality(), llvm::APInt::isPowerOf2(), llvm::CmpInst::isSigned(), llvm::ConstantInt::isZero(), llvm_unreachable, llvm::PatternMatch::m_And(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::CmpInst::makeCmpResultType(), llvm::ConstantRange::makeICmpRegion(), llvm::PatternMatch::match(), llvm::PredicatesFoldable(), llvm::APInt::sgt(), llvm::SubOne(), std::swap(), llvm::ICmpInst::swapOperands(), llvm::APInt::ugt(), and llvm::APInt::zext().
Instruction * InstCombiner::FoldCmpLoadFromIndexedGlobal | ( | GetElementPtrInst * | GEP, |
GlobalVariable * | GV, | ||
CmpInst & | ICI, | ||
ConstantInt * | AndCst = nullptr |
||
) |
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().
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 3407 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::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::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, |
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::FoldGEPICmp | ( | GEPOperator * | GEPLHS, |
Value * | RHS, | ||
ICmpInst::Predicate | Cond, | ||
Instruction & | I | ||
) |
FoldGEPICmp - Fold comparisons between a GEP instruction and something else. At this point we know that the GEP is on the LHS of the comparison.
Definition at line 604 of file InstCombineCompares.cpp.
References llvm::EmitGEPOffset(), EvaluateGEPOffsetExpression(), llvm::Constant::getNullValue(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::Type::getPrimitiveSizeInBits(), llvm::ICmpInst::getSignedPredicate(), llvm::PPC::getSwappedPredicate(), llvm::Value::getType(), llvm::GEPOperator::hasAllConstantIndices(), llvm::GEPOperator::hasAllZeroIndices(), llvm::Value::hasOneUse(), I, llvm::GEPOperator::isInBounds(), llvm::CmpInst::isSigned(), llvm::CmpInst::isTrueWhenEqual(), and llvm::Value::stripPointerCasts().
Instruction * InstCombiner::FoldICmpAddOpCst | ( | Instruction & | ICI, |
Value * | X, | ||
ConstantInt * | CI, | ||
ICmpInst::Predicate | Pred | ||
) |
FoldICmpAddOpCst - Fold "icmp pred (X+CI), X".
Definition at line 740 of file InstCombineCompares.cpp.
References llvm::CallingConv::C, llvm::ConstantInt::get(), llvm::Constant::getAllOnesValue(), llvm::Value::getContext(), llvm::ConstantExpr::getNeg(), llvm::Type::getPrimitiveSizeInBits(), llvm::APInt::getSignedMaxValue(), llvm::ConstantExpr::getSub(), llvm::ConstantInt::getType(), llvm::ConstantInt::getValue(), 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, and llvm::CmpInst::ICMP_ULT.
Instruction * InstCombiner::FoldICmpCstShrCst | ( | ICmpInst & | I, |
Value * | Op, | ||
Value * | A, | ||
ConstantInt * | CI1, | ||
ConstantInt * | CI2 | ||
) |
FoldICmpCstShrCst - Handle "(icmp eq/ne (ashr/lshr const2, A), const1)" -> (icmp eq/ne A, Log2(const2/const1)) -> (icmp eq/ne A, Log2(const2) - Log2(const1)).
Definition at line 1035 of file InstCombineCompares.cpp.
References llvm::APInt::ashr(), llvm::ConstantInt::get(), llvm::CmpInst::getInversePredicate(), llvm::Constant::getNullValue(), llvm::CmpInst::getPredicate(), llvm::Value::getType(), llvm::ConstantInt::getValue(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_UGT, llvm::APInt::isAllOnesValue(), llvm::ICmpInst::isEquality(), llvm::APInt::isNegative(), llvm::APInt::logBase2(), llvm::APIntOps::logBase2(), llvm::APInt::lshr(), llvm::APInt::slt(), and llvm::APInt::ugt().
Instruction * InstCombiner::FoldICmpDivCst | ( | ICmpInst & | ICI, |
BinaryOperator * | DivI, | ||
ConstantInt * | DivRHS | ||
) |
FoldICmpDivCst - Fold "icmp pred, ([su]div X, DivRHS), CmpRHS" where DivRHS and CmpRHS are both known to be integer constants.
If the division is known to be exact, then there is no remainder from the divide, so the covered range size is unit, otherwise it is the divisor.
Definition at line 789 of file InstCombineCompares.cpp.
References llvm::AddOne(), AddWithOverflow(), llvm::ConstantExpr::getMul(), llvm::ConstantExpr::getNeg(), getOne(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::ConstantExpr::getSDiv(), llvm::PPC::getSwappedPredicate(), llvm::ConstantExpr::getUDiv(), llvm::ConstantInt::getValue(), 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::Constant::isAllOnesValue(), llvm::ICmpInst::isEquality(), llvm::BinaryOperator::isExact(), llvm::ConstantInt::isNegative(), llvm::ConstantInt::isOne(), llvm::CmpInst::isSigned(), llvm::APInt::isStrictlyPositive(), llvm::ConstantInt::isZero(), llvm_unreachable, llvm::User::setOperand(), llvm::SubOne(), SubWithOverflow(), and llvm::X.
Instruction * InstCombiner::FoldICmpShrCst | ( | ICmpInst & | ICI, |
BinaryOperator * | DivI, | ||
ConstantInt * | DivRHS | ||
) |
FoldICmpShrCst - Handle "icmp(([al]shr X, cst1), cst2)".
Definition at line 946 of file InstCombineCompares.cpp.
References llvm::APIntOps::And(), llvm::APInt::ashr(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::APInt::getBitWidth(), llvm::APInt::getHighBitsSet(), llvm::ConstantInt::getLimitedValue(), llvm::Value::getName(), llvm::APInt::getOneBitSet(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::Value::getType(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_NE, llvm::ICmpInst::isEquality(), llvm::BinaryOperator::isExact(), llvm::CmpInst::isSigned(), llvm::LShr, llvm::APInt::lshr(), and llvm::User::setOperand().
Value * InstCombiner::FoldOrOfFCmps | ( | FCmpInst * | LHS, |
FCmpInst * | RHS | ||
) |
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 | ||
) |
FoldOrOfICmps - Fold (icmp)|(icmp) if possible.
Definition at line 1587 of file InstCombineAndOrXor.cpp.
References llvm::ARM_PROC::A, llvm::AddOne(), llvm::APIntOps::And(), llvm::tgtok::Code, llvm::dyn_cast(), foldLogOpOfMaskedICmps(), llvm::ConstantInt::get(), llvm::getICmpCode(), llvm::Value::getName(), llvm::ConstantExpr::getNeg(), getNewICmpValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::ConstantInt::getSigned(), llvm::ConstantExpr::getSub(), llvm::ConstantInt::getType(), llvm::ConstantInt::getValue(), 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_ULT, llvm::ICmpInst::isEquality(), llvm::isKnownToBeAPowerOfTwo(), llvm::APInt::isPowerOf2(), llvm::CmpInst::isSigned(), llvm::ConstantInt::isZero(), llvm_unreachable, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::PredicatesFoldable(), llvm::APInt::sgt(), llvm::SubOne(), std::swap(), llvm::ICmpInst::swapOperands(), llvm::APInt::ugt(), llvm::APInt::ule(), llvm::APInt::ult(), and llvm::APIntOps::Xor().
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 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 | ||
) |
FoldSelectIntoOp - Try fold the select into one of the operands to facilitate further optimization.
Definition at line 235 of file InstCombineSelect.cpp.
References llvm::CallingConv::C, llvm::BinaryOperator::Create(), llvm::SelectInst::getCondition(), llvm::BinaryOperator::getOpcode(), GetSelectFoldableConstant(), GetSelectFoldableOperands(), llvm::BinaryOperator::hasNoSignedWrap(), llvm::BinaryOperator::hasNoUnsignedWrap(), llvm::BinaryOperator::isExact(), isSelect01(), llvm::BinaryOperator::setIsExact(), and llvm::Value::takeName().
Instruction * InstCombiner::FoldSelectOpOp | ( | SelectInst & | SI, |
Instruction * | TI, | ||
Instruction * | FI | ||
) |
FoldSelectOpOp - Here we have (select c, TI, FI), and we know that TI and FI have the same opcode and only one use each. Try to simplify this.
Definition at line 148 of file InstCombineSelect.cpp.
References llvm::BinaryOperator::Create(), llvm::CastInst::Create(), llvm::SelectInst::getCondition(), llvm::Value::getName(), llvm::User::getNumOperands(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::Instruction::isCast(), llvm::Instruction::isCommutative(), llvm::Type::isVectorTy(), and llvm_unreachable.
Instruction * InstCombiner::FoldShiftByConstant | ( | Value * | Op0, |
Constant * | Op1, | ||
BinaryOperator & | I | ||
) |
Definition at line 318 of file InstCombineShifts.cpp.
References llvm::APIntOps::And(), llvm::tgtok::Bits, CanEvaluateShifted(), llvm::BinaryOperator::Create(), CreateMul(), llvm::dbgs(), DEBUG, llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantExpr::get(), llvm::Value::getContext(), llvm::APInt::getHighBitsSet(), llvm::ConstantInt::getLimitedValue(), llvm::APInt::getLowBitsSet(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), GetShiftedValue(), llvm::ConstantExpr::getShl(), llvm::ConstantVector::getSplat(), llvm::Value::getType(), llvm::ConstantExpr::getZExt(), llvm::ConstantInt::getZExtValue(), llvm::BinaryOperator::hasNoSignedWrap(), llvm::BinaryOperator::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), I, llvm::BinaryOperator::isExact(), llvm::Instruction::isLogicalShift(), llvm::Instruction::isShift(), llvm::LShr, llvm::APInt::lshr(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::AArch64CC::NV, llvm::APIntOps::Or(), llvm::BinaryOperator::setHasNoSignedWrap(), llvm::BinaryOperator::setHasNoUnsignedWrap(), llvm::BinaryOperator::setIsExact(), llvm::Value::takeName(), llvm::ConstantInt::uge(), llvm::NVPTX::PTXLdStInstCode::V2, llvm::X, and llvm::APIntOps::Xor().
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 693 of file InstCombineSelect.cpp.
References llvm::SelectInst::getCondition(), llvm::SelectInst::getFalseValue(), llvm::SelectInst::getTrueValue(), llvm::User::replaceUsesOfWith(), llvm::APInt::sge(), llvm::APInt::sgt(), llvm::APInt::sle(), llvm::APInt::slt(), llvm::SPF_ABS, llvm::SPF_NABS, llvm::SPF_SMAX, llvm::SPF_SMIN, llvm::SPF_UMAX, llvm::SPF_UMIN, llvm::APInt::uge(), llvm::APInt::ugt(), llvm::APInt::ule(), and llvm::APInt::ult().
Instruction * InstCombiner::FoldXorWithConstants | ( | BinaryOperator & | I, |
Value * | Op, | ||
Value * | A, | ||
Value * | B, | ||
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.
AssumptionTracker* llvm::InstCombiner::getAssumptionTracker | ( | ) | const [inline] |
Definition at line 128 of file InstCombine.h.
Referenced by simplifyValueKnownNonZero().
const DataLayout* llvm::InstCombiner::getDataLayout | ( | ) | const [inline] |
Definition at line 130 of file InstCombine.h.
Referenced by CollectInsertionElements(), EvaluateGEPOffsetExpression(), GetShiftedValue(), InstCombineLoadCast(), InstCombineStoreToCast(), OptimizeIntegerToVectorInsertions(), and OptimizeIntToFloatBitCast().
DominatorTree* llvm::InstCombiner::getDominatorTree | ( | ) | const [inline] |
Definition at line 132 of file InstCombine.h.
Referenced by simplifyValueKnownNonZero().
TargetLibraryInfo* llvm::InstCombiner::getTargetLibraryInfo | ( | ) | const [inline] |
Definition at line 134 of file InstCombine.h.
Referenced by GetShiftedValue().
Instruction* llvm::InstCombiner::InsertNewInstBefore | ( | Instruction * | New, |
Instruction & | Old | ||
) | [inline] |
Definition at line 281 of file InstCombine.h.
References llvm::BasicBlock::getInstList(), llvm::Instruction::getParent(), and llvm::iplist< NodeTy, Traits >::insert().
Referenced by visitAllocaInst().
Instruction* llvm::InstCombiner::InsertNewInstWith | ( | Instruction * | New, |
Instruction & | Old | ||
) | [inline] |
Definition at line 293 of file InstCombine.h.
References llvm::Instruction::getDebugLoc(), and llvm::Instruction::setDebugLoc().
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().
Instruction* llvm::InstCombiner::ReplaceInstUsesWith | ( | Instruction & | I, |
Value * | V | ||
) | [inline] |
Definition at line 304 of file InstCombine.h.
References llvm::dbgs(), DEBUG, llvm::UndefValue::get(), llvm::Value::getType(), I, and llvm::Value::replaceAllUsesWith().
Referenced by ProcessUAddIdiom(), ProcessUGT_ADDCST_ADD(), ProcessUMulZExtIdiom(), SliceUpIllegalIntegerPHI(), visitAllocaInst(), visitLoadInst(), and visitPHINode().
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().
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 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().
Definition at line 1072 of file InstCombineAddSub.cpp.
References llvm::ARM_PROC::A, llvm::AddOne(), checkForNegativeOperand(), llvm::computeKnownBits(), llvm::SelectInst::Create(), CreateAdd(), CreateNeg(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantExpr::getAdd(), llvm::IntegerType::getBitWidth(), llvm::SelectInst::getCondition(), llvm::SelectInst::getFalseValue(), llvm::APInt::getHighBitsSet(), llvm::Value::getName(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::ConstantExpr::getSExt(), llvm::SelectInst::getTrueValue(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::ConstantExpr::getXor(), llvm::BinaryOperator::hasNoSignedWrap(), llvm::BinaryOperator::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), I, llvm::Type::isIntegerTy(), llvm::APInt::isPowerOf2(), llvm::APInt::isSignBit(), IT(), llvm::APInt::logBase2(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::PatternMatch::m_Zero(), llvm::MaskedValueIsZero(), llvm::PatternMatch::match(), N, llvm::AArch64CC::NV, llvm::BinaryOperator::setHasNoSignedWrap(), llvm::BinaryOperator::setHasNoUnsignedWrap(), llvm::SimplifyAddInst(), llvm::SubOne(), and llvm::X.
Definition at line 1916 of file InstCombineCasts.cpp.
References llvm::VectorType::get(), llvm::PointerType::get(), llvm::PointerType::getAddressSpace(), llvm::SequentialType::getElementType(), llvm::User::getOperand(), llvm::Type::getScalarType(), and llvm::Value::getType().
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 165 of file InstCombineLoadStoreAlloca.cpp.
References Builder, llvm::CallingConv::C, llvm::IRBuilder< preserveNames, T, Inserter >::CreateAlloca(), llvm::GetElementPtrInst::CreateInBounds(), llvm::IRBuilder< preserveNames, T, Inserter >::CreateIntCast(), llvm::dbgs(), DEBUG, llvm::dyn_cast(), EraseInstFromFunction(), llvm::ConstantInt::get(), llvm::ArrayType::get(), llvm::AllocaInst::getAlignment(), llvm::AllocaInst::getAllocatedType(), llvm::AllocaInst::getArraySize(), llvm::Value::getContext(), llvm::Function::getEntryBlock(), llvm::BasicBlock::getFirstNonPHIOrDbg(), llvm::Type::getInt64Ty(), llvm::DataLayout::getIntPtrType(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::getOrEnforceKnownAlignment(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(), llvm::DataLayout::getPrefTypeAlignment(), llvm::AllocaInst::getType(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), InsertNewInstBefore(), llvm::AllocaInst::isArrayAllocation(), isOnlyCopiedFromConstantGlobal(), llvm::Type::isSized(), llvm::Instruction::moveBefore(), ReplaceInstUsesWith(), llvm::AllocaInst::setAlignment(), llvm::User::setOperand(), llvm::SmallVectorTemplateCommon< T, typename >::size(), and visitAllocSite().
Definition at line 1883 of file InstructionCombining.cpp.
References llvm::InvokeInst::Create(), F(), llvm::ConstantInt::get(), llvm::UndefValue::get(), llvm::Value::getContext(), llvm::Intrinsic::getDeclaration(), llvm::Type::getInt1Ty(), llvm::Value::getType(), isAllocSiteRemovable(), llvm::ConstantInt::isZero(), llvm::None, llvm::SmallVectorTemplateCommon< T >::size(), and Users.
Referenced by visitAllocaInst().
Definition at line 1104 of file InstCombineAndOrXor.cpp.
References llvm::ARM_PROC::A, llvm::APInt::countLeadingZeros(), llvm::BinaryOperator::Create(), llvm::CastInst::Create(), llvm::SelectInst::Create(), llvm::BinaryOperator::CreateNot(), llvm::dyn_cast(), dyn_castNotVal(), llvm::ConstantExpr::getAnd(), llvm::APInt::getBitWidth(), llvm::APInt::getLowBitsSet(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::Type::getScalarType(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::Value::hasOneUse(), I, llvm::Type::isIntegerTy(), llvm::Type::isIntOrIntVectorTy(), llvm::LShr, llvm::PatternMatch::m_And(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::PatternMatch::m_Zero(), llvm::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::AArch64CC::NV, llvm::APIntOps::Or(), llvm::SimplifyAndInst(), std::swap(), llvm::X, llvm::APIntOps::Xor(), and Y.
Definition at line 778 of file InstCombineShifts.cpp.
References llvm::APInt::getLowBitsSet(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::APInt::getSignBit(), llvm::Value::getType(), I, llvm::BinaryOperator::isExact(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::BinaryOperator::setIsExact(), llvm::SimplifyAShrInst(), and llvm::X.
Instruction * InstCombiner::visitBitCast | ( | BitCastInst & | CI | ) |
Definition at line 1788 of file InstCombineCasts.cpp.
References llvm::CastInst::Create(), llvm::InsertElementInst::Create(), llvm::GetElementPtrInst::CreateInBounds(), llvm::UndefValue::get(), llvm::Value::getContext(), llvm::SequentialType::getElementType(), llvm::Type::getInt32Ty(), llvm::Constant::getNullValue(), llvm::Type::getNumContainedTypes(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::Type::isDoubleTy(), llvm::Type::isFloatTy(), llvm::Type::isPointerTy(), llvm::Type::isVectorTy(), OptimizeIntegerToVectorInsertions(), OptimizeIntToFloatBitCast(), and OptimizeVectorResize().
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 2028 of file InstructionCombining.cpp.
References llvm::CmpInst::FCMP_OGE, llvm::CmpInst::FCMP_OLE, llvm::CmpInst::FCMP_ONE, llvm::BranchInst::getCondition(), llvm::CmpInst::getInversePredicate(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_ULE, llvm::PatternMatch::m_Br(), llvm::PatternMatch::m_FCmp(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::BranchInst::setCondition(), llvm::CmpInst::setPredicate(), llvm::BranchInst::swapSuccessors(), llvm::X, and Y.
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.
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.
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 179 of file InstCombineVectorOps.cpp.
References llvm::CallingConv::C, CheapToScalarize(), llvm::BinaryOperator::Create(), llvm::CastInst::Create(), llvm::SelectInst::Create(), llvm::ExtractElementInst::Create(), FindScalarElement(), llvm::ConstantInt::get(), llvm::UndefValue::get(), llvm::Value::getContext(), llvm::ExtractElementInst::getIndexOperand(), llvm::Type::getInt32Ty(), llvm::Value::getName(), llvm::VectorType::getNumElements(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::ExtractElementInst::getVectorOperandType(), llvm::Value::hasOneUse(), I, llvm::ARM_PROC::IE, llvm::Type::isVectorTy(), llvm::APInt::setBit(), and llvm::User::setOperand().
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 2100 of file InstructionCombining.cpp.
References llvm::ExtractValueInst::Create(), llvm::InsertValueInst::Create(), CreateAdd(), CreateMul(), llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), llvm::ExtractValueInst::getAggregateOperand(), llvm::ExtractValueInst::getIndices(), llvm::ConstantExpr::getNot(), llvm::ExtractValueInst::getNumIndices(), llvm::ExtractValueInst::hasIndices(), I, llvm::CmpInst::ICMP_UGT, llvm::ExtractValueInst::idx_begin(), llvm::ExtractValueInst::idx_end(), llvm::makeArrayRef(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), and llvm::ArrayRef< T >::slice().
Definition at line 1346 of file InstCombineAddSub.cpp.
References llvm::ARM_PROC::A, llvm::Instruction::copyFastMathFlags(), llvm::SelectInst::Create(), llvm::dyn_cast(), llvm::Instruction::getFastMathFlags(), llvm::ConstantExpr::getFPToSI(), llvm::User::getOperand(), llvm::ConstantExpr::getSIToFP(), llvm::Value::getType(), llvm::Instruction::hasNoSignedZeros(), llvm::Instruction::hasUnsafeAlgebra(), I, llvm::Constant::isNegativeZeroValue(), llvm::PatternMatch::m_AnyZero(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::AArch64CC::NV, and llvm::SimplifyFAddInst().
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 1110 of file InstCombineMulDivRem.cpp.
References llvm::CallingConv::C, CvtFDivConstToReciprocal(), llvm::Instruction::getDebugLoc(), llvm::Instruction::getFastMathFlags(), llvm::ConstantExpr::getFDiv(), llvm::ConstantExpr::getFMul(), llvm::User::getOperand(), llvm::Instruction::hasAllowReciprocal(), llvm::Value::hasOneUse(), llvm::Instruction::hasUnsafeAlgebra(), isNormalFp(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_FDiv(), llvm::PatternMatch::m_FMul(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::Instruction::setFastMathFlags(), llvm::SimplifyFDivInst(), T, llvm::X, and Y.
Definition at line 453 of file InstCombineMulDivRem.cpp.
References llvm::CallingConv::C, llvm::Instruction::copyFastMathFlags(), detectLog2OfHalf(), llvm::dyn_cast(), llvm::Instruction::getFastMathFlags(), llvm::ConstantExpr::getFMul(), llvm::ConstantFP::getNegativeZero(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Instruction::hasNoSignedZeros(), llvm::Value::hasOneUse(), llvm::Instruction::hasUnsafeAlgebra(), isFiniteNonZeroFp(), isFMulOrFDivWithConstant(), llvm::BinaryOperator::isFNeg(), isNormalFp(), llvm::PatternMatch::m_FMul(), llvm::PatternMatch::m_SpecificFP(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::AArch64CC::NV, llvm::CallInst::setArgOperand(), llvm::SimplifyFMulInst(), std::swap(), llvm::Value::takeName(), and Y.
Instruction * InstCombiner::visitFPExt | ( | CastInst & | CI | ) |
Definition at line 1359 of file InstCombineCasts.cpp.
Instruction * InstCombiner::visitFPToSI | ( | FPToSIInst & | FI | ) |
Definition at line 1383 of file InstCombineCasts.cpp.
References llvm::dyn_cast(), llvm::Type::getFPMantissaWidth(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().
Instruction * InstCombiner::visitFPToUI | ( | FPToUIInst & | FI | ) |
Definition at line 1363 of file InstCombineCasts.cpp.
References llvm::dyn_cast(), llvm::Type::getFPMantissaWidth(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().
Instruction * InstCombiner::visitFPTrunc | ( | FPTruncInst & | CI | ) |
Definition at line 1176 of file InstCombineCasts.cpp.
References llvm::Call, llvm::Instruction::copyFastMathFlags(), llvm::BinaryOperator::Create(), llvm::CallInst::Create(), llvm::SelectInst::Create(), llvm::BinaryOperator::CreateFNeg(), llvm::CastInst::CreateFPCast(), llvm::dyn_cast(), llvm::LibFunc::fabs, llvm::FPExt, llvm::UndefValue::get(), llvm::CallInst::getArgOperand(), llvm::Function::getAttributes(), llvm::CallInst::getCalledFunction(), llvm::Intrinsic::getDeclaration(), llvm::Type::getFPMantissaWidth(), llvm::IntrinsicInst::getIntrinsicID(), llvm::Function::getIntrinsicID(), llvm::Value::getName(), llvm::CallInst::getNumArgOperands(), llvm::BinaryOperator::getOpcode(), llvm::CastInst::getOpcode(), llvm::User::getOperand(), llvm::Module::getOrInsertFunction(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::Value::getType(), llvm::Value::hasOneUse(), I, llvm::Type::isDoubleTy(), llvm::Type::isFloatTy(), llvm::BinaryOperator::isFNeg(), LookThroughFPExtensions(), llvm::CallInst::setAttributes(), llvm::LibFunc::sqrt, and llvm::LibFunc::sqrtf.
Instruction * InstCombiner::visitFree | ( | CallInst & | FI | ) |
Definition at line 1979 of file InstructionCombining.cpp.
References llvm::UndefValue::get(), llvm::CallInst::getArgOperand(), llvm::Value::getContext(), llvm::Type::getInt1PtrTy(), llvm::ConstantInt::getTrue(), I, and tryToMoveFreeBeforeNullTest().
Definition at line 1385 of file InstCombineMulDivRem.cpp.
References llvm::User::getOperand(), I, and llvm::SimplifyFRemInst().
Definition at line 1695 of file InstCombineAddSub.cpp.
References llvm::Instruction::copyFastMathFlags(), llvm::Instruction::getFastMathFlags(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Instruction::hasUnsafeAlgebra(), llvm::AArch64CC::NV, and llvm::SimplifyFSubInst().
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().
visitICmpInstWithCastAndCast - Handle icmp (cast x to y), (cast/cst). We only handle extending casts so far.
Definition at line 1895 of file InstCombineCompares.cpp.
References llvm::BinaryOperator::CreateNot(), llvm::dyn_cast(), llvm::Constant::getAllOnesValue(), llvm::ConstantExpr::getCast(), llvm::Type::getIntegerBitWidth(), llvm::ConstantExpr::getIntToPtr(), llvm::Value::getName(), llvm::CastInst::getOpcode(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::ICmpInst::getUnsignedPredicate(), llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::ICmpInst::isEquality(), llvm::CmpInst::isSigned(), and llvm::SExt.
Instruction * InstCombiner::visitICmpInstWithInstAndIntCst | ( | ICmpInst & | ICI, |
Instruction * | LHSI, | ||
ConstantInt * | RHS | ||
) |
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().
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 528 of file InstCombineVectorOps.cpp.
References CollectShuffleElements(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::APInt::getAllOnesValue(), llvm::VectorType::getNumElements(), llvm::User::getOperand(), llvm::Value::getType(), llvm::InsertElementInst::getType(), llvm::Type::getVectorNumElements(), llvm::Value::hasOneUse(), llvm::ARM_PROC::IE, and llvm::Instruction::user_back().
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().
Instruction* llvm::InstCombiner::visitInstruction | ( | Instruction & | I | ) | [inline] |
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 244 of file InstCombine.h.
Definition at line 1411 of file InstCombineCasts.cpp.
References llvm::VectorType::get(), llvm::IntToPtrInst::getAddressSpace(), llvm::Value::getContext(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::Type::isVectorTy(), and P.
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 1028 of file InstCombineCalls.cpp.
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 2294 of file InstructionCombining.cpp.
References llvm::LandingPadInst::addClause(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::LandingPadInst::Create(), llvm::dyn_cast(), llvm::SmallVectorBase::empty(), llvm::SmallVectorImpl< T >::erase(), llvm::ArrayType::get(), llvm::ConstantArray::get(), llvm::LandingPadInst::getClause(), llvm::SequentialType::getElementType(), llvm::Constant::getNullValue(), llvm::LandingPadInst::getNumClauses(), llvm::ArrayType::getNumElements(), llvm::User::getOperand(), llvm::LandingPadInst::getPersonalityFn(), llvm::Intrinsic::getType(), llvm::Value::getType(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::LandingPadInst::isCatch(), isCatchAll(), llvm::LandingPadInst::isCleanup(), llvm::LandingPadInst::isFilter(), LI, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), RecognizePersonality(), llvm::SmallVectorImpl< T >::reserve(), llvm::LandingPadInst::setCleanup(), shorter_filter(), llvm::SmallVectorTemplateCommon< T >::size(), llvm::Constant::stripPointerCasts(), and llvm::Value::stripPointerCasts().
Instruction * InstCombiner::visitLoadInst | ( | LoadInst & | LI | ) |
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 361 of file InstCombineLoadStoreAlloca.cpp.
References Align(), Builder, llvm::CallingConv::C, llvm::WinEH::CE, llvm::SelectInst::Create(), llvm::IRBuilder< preserveNames, T, Inserter >::CreateLoad(), llvm::FindAvailableLoadedValue(), llvm::UndefValue::get(), llvm::DataLayout::getABITypeAlignment(), llvm::LoadInst::getAlignment(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::getOrEnforceKnownAlignment(), llvm::Instruction::getParent(), llvm::LoadInst::getPointerAddressSpace(), llvm::DataLayout::getPrefTypeAlignment(), llvm::Value::getType(), llvm::Value::hasOneUse(), InstCombineLoadCast(), llvm::isSafeToLoadUnconditionally(), llvm::LoadInst::isSimple(), LI, ReplaceInstUsesWith(), llvm::LoadInst::setAlignment(), llvm::User::setOperand(), and llvm::NVPTX::PTXLdStInstCode::V2.
Definition at line 734 of file InstCombineShifts.cpp.
References llvm::APInt::getLowBitsSet(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::ConstantInt::getSigned(), llvm::Value::getType(), I, llvm::BinaryOperator::isExact(), llvm::isPowerOf2_32(), llvm::Log2_32(), llvm::MaskedValueIsZero(), llvm::BinaryOperator::setIsExact(), and llvm::SimplifyLShrInst().
i1 mul -> i1 and.
Definition at line 139 of file InstCombineMulDivRem.cpp.
References llvm::APInt::abs(), CreateAdd(), CreateMul(), CreateNeg(), llvm::dyn_cast(), llvm::ConstantInt::get(), getLogBase2Vector(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarType(), llvm::ConstantExpr::getShl(), llvm::Value::getType(), llvm::BinaryOperator::hasNoSignedWrap(), llvm::BinaryOperator::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), llvm::Type::isIntegerTy(), llvm::APInt::isNegative(), llvm::APInt::isPowerOf2(), llvm::Type::isVectorTy(), llvm::APInt::logBase2(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::AArch64CC::NV, llvm::BinaryOperator::setHasNoSignedWrap(), llvm::BinaryOperator::setHasNoUnsignedWrap(), llvm::SimplifyMulInst(), llvm::Value::takeName(), llvm::X, and Y.
Definition at line 2029 of file InstCombineAndOrXor.cpp.
References llvm::ARM_PROC::A, llvm::CallingConv::C, llvm::CastInst::Create(), llvm::SelectInst::Create(), llvm::BinaryOperator::CreateNot(), llvm::dyn_cast(), dyn_castNotVal(), llvm::Value::getName(), llvm::CastInst::getOpcode(), llvm::User::getOperand(), llvm::ConstantExpr::getOr(), llvm::ConstantInt::getSigned(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::Value::hasOneUse(), I, llvm::Type::isIntegerTy(), llvm::Type::isIntOrIntVectorTy(), llvm::Type::isVectorTy(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_LogicalShift(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::MaskedValueIsZero(), llvm::PatternMatch::match(), MatchSelectFromAndOr(), llvm::APIntOps::Not(), llvm::AArch64CC::NV, llvm::APIntOps::Or(), llvm::MipsISD::Ret, llvm::SimplifyOrInst(), std::swap(), llvm::Value::takeName(), llvm::NVPTX::PTXLdStInstCode::V2, llvm::APIntOps::Xor(), and Y.
Instruction * InstCombiner::visitPHINode | ( | PHINode & | PN | ) |
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 790 of file InstCombinePHI.cpp.
References llvm::BasicBlock::begin(), DeadPHICycle(), llvm::UndefValue::get(), llvm::PHINode::getBasicBlockIndex(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), llvm::Instruction::getParent(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::Value::hasOneUse(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::Type::isIntegerTy(), llvm::DataLayout::isLegalInteger(), PHIsEqualValue(), ReplaceInstUsesWith(), llvm::PHINode::setIncomingBlock(), llvm::PHINode::setIncomingValue(), llvm::SimplifyInstruction(), SliceUpIllegalIntegerPHI(), and llvm::Instruction::user_back().
Definition at line 1495 of file InstCombineCasts.cpp.
References llvm::CastInst::CreateIntegerCast(), llvm::VectorType::get(), llvm::Value::getContext(), llvm::User::getOperand(), llvm::PtrToIntInst::getPointerAddressSpace(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::Type::isVectorTy(), and P.
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 2008 of file InstructionCombining.cpp.
References llvm::computeKnownBits(), llvm::Constant::getIntegerValue(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::Type::isIntegerTy(), and llvm::User::setOperand().
Definition at line 1017 of file InstCombineMulDivRem.cpp.
References CreateNeg(), llvm::ConstantInt::get(), llvm::Value::getName(), llvm::ConstantExpr::getNeg(), llvm::User::getOperand(), llvm::Type::getPrimitiveSizeInBits(), llvm::APInt::getSignBit(), llvm::Value::getType(), llvm::BinaryOperator::isExact(), llvm::Type::isIntegerTy(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::MaskedValueIsZero(), llvm::PatternMatch::match(), and llvm::SimplifySDivInst().
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 833 of file InstCombineSelect.cpp.
References llvm::CallingConv::C, CanSelectOperandBeMappingIntoPredBlock(), CreateAdd(), llvm::CmpInst::FCMP_OEQ, llvm::CmpInst::FCMP_UNE, foldSelectICmpAnd(), llvm::APInt::getAllOnesValue(), llvm::SelectInst::getCondition(), llvm::SelectInst::getFalseValue(), llvm::Instruction::getFastMathFlags(), llvm::Value::getName(), llvm::BinaryOperator::getNotArgument(), llvm::User::getOperand(), llvm::SelectInst::getTrueValue(), llvm::Value::getType(), llvm::ConstantFP::getValueAPF(), llvm::Type::isFPOrFPVectorTy(), llvm::Type::isIntegerTy(), llvm::BinaryOperator::isNot(), llvm::APFloat::isZero(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::match(), MatchSelectPattern(), llvm::AArch64CC::NV, llvm::Instruction::setFastMathFlags(), llvm::User::setOperand(), llvm::SimplifySelectInst(), and std::swap().
Instruction * InstCombiner::visitSelectInstWithICmp | ( | SelectInst & | SI, |
ICmpInst * | ICI | ||
) |
visitSelectInstWithICmp - Visit a SelectInst that has an ICmpInst as its first operand.
Definition at line 471 of file InstCombineSelect.cpp.
References llvm::APIntOps::And(), llvm::dyn_cast(), foldSelectICmpAndOr(), llvm::ConstantInt::get(), llvm::IntegerType::getBitWidth(), llvm::SelectInst::getFalseValue(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::Type::getScalarSizeInBits(), llvm::ConstantExpr::getSExt(), llvm::PPC::getSwappedPredicate(), llvm::SelectInst::getTrueValue(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::ConstantExpr::getZExt(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::CmpInst::isUnsigned(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::Instruction::moveBefore(), llvm::User::setOperand(), llvm::CmpInst::setPredicate(), SimplifyWithOpReplaced(), and std::swap().
Instruction * InstCombiner::visitSExt | ( | SExtInst & | CI | ) |
Definition at line 1046 of file InstCombineCasts.cpp.
References llvm::ARM_PROC::A, CanEvaluateSExtd(), llvm::ComputeNumSignBits(), llvm::dbgs(), DEBUG, llvm::ConstantInt::get(), llvm::Value::getName(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::Value::hasOneUse(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and llvm::Instruction::user_back().
Definition at line 692 of file InstCombineShifts.cpp.
References llvm::ARM_PROC::A, llvm::ComputeNumSignBits(), llvm::APInt::getHighBitsSet(), llvm::User::getOperand(), llvm::ConstantExpr::getShl(), llvm::BinaryOperator::hasNoSignedWrap(), llvm::BinaryOperator::hasNoUnsignedWrap(), I, llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::BinaryOperator::setHasNoSignedWrap(), llvm::BinaryOperator::setHasNoUnsignedWrap(), and llvm::SimplifyShlInst().
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 856 of file InstCombineVectorOps.cpp.
References CanEvaluateShuffled(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::UndefValue::get(), llvm::APInt::getAllOnesValue(), llvm::Value::getContext(), llvm::Type::getInt32Ty(), llvm::User::getOperand(), llvm::ShuffleVectorInst::getShuffleMask(), llvm::Value::getType(), llvm::ShuffleVectorInst::getType(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), RecognizeIdentityMask(), llvm::User::setOperand(), and llvm::SmallVectorTemplateCommon< T, typename >::size().
Instruction * InstCombiner::visitSIToFP | ( | CastInst & | CI | ) |
Definition at line 1407 of file InstCombineCasts.cpp.
Definition at line 1310 of file InstCombineMulDivRem.cpp.
References llvm::CallingConv::C, llvm::ConstantVector::get(), llvm::Constant::getAggregateElement(), llvm::Value::getName(), llvm::ConstantExpr::getNeg(), llvm::User::getOperand(), llvm::Type::getPrimitiveSizeInBits(), llvm::APInt::getSignBit(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), I, llvm::Type::isIntegerTy(), llvm::MaskedValueIsZero(), llvm::User::setOperand(), and llvm::SimplifySRemInst().
Instruction * InstCombiner::visitStoreInst | ( | StoreInst & | SI | ) |
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 598 of file InstCombineLoadStoreAlloca.cpp.
References llvm::InstCombineWorklist::Add(), llvm::BasicBlock::begin(), llvm::WinEH::CE, equivalentAddressValues(), EraseInstFromFunction(), llvm::UndefValue::get(), llvm::DataLayout::getABITypeAlignment(), llvm::StoreInst::getAlignment(), llvm::User::getOperand(), llvm::getOrEnforceKnownAlignment(), llvm::Instruction::getParent(), llvm::StoreInst::getPointerAddressSpace(), llvm::DataLayout::getPrefTypeAlignment(), llvm::Value::getType(), llvm::Value::hasOneUse(), InstCombineStoreToCast(), llvm::StoreInst::isSimple(), LI, llvm::StoreInst::setAlignment(), llvm::User::setOperand(), and Worklist.
Definition at line 1526 of file InstCombineAddSub.cpp.
References llvm::ARM_PROC::A, llvm::AddOne(), CreateAdd(), llvm::BinaryOperator::CreateNeg(), llvm::BinaryOperator::CreateNot(), llvm::CastInst::CreateSExtOrBitCast(), llvm::CastInst::CreateZExtOrBitCast(), llvm::ConstantExpr::getNeg(), llvm::User::getOperand(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarType(), llvm::ConstantExpr::getSub(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::BinaryOperator::hasNoSignedWrap(), llvm::BinaryOperator::hasNoUnsignedWrap(), llvm::Type::isIntegerTy(), llvm::Constant::isNotMinSignedValue(), llvm::Constant::isOneValue(), llvm::APFloat::isZero(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_Neg(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_SDiv(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::BinaryOperator::setHasNoSignedWrap(), llvm::BinaryOperator::setHasNoUnsignedWrap(), llvm::SimplifySubInst(), llvm::X, and Y.
Reimplemented from llvm::InstVisitor< InstCombiner, Instruction * >.
Definition at line 2076 of file InstructionCombining.cpp.
References llvm::SwitchInst::case_begin(), llvm::SwitchInst::case_end(), llvm::SwitchInst::getCondition(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::ConstantExpr::getSub(), and llvm::SwitchInst::setCondition().
Instruction * InstCombiner::visitTrunc | ( | TruncInst & | CI | ) |
Definition at line 440 of file InstCombineCasts.cpp.
References llvm::ARM_PROC::A, CanEvaluateTruncated(), llvm::CastInst::CreateIntegerCast(), llvm::dbgs(), DEBUG, llvm::ConstantInt::get(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::ConstantInt::getZExtValue(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_NE, llvm::Type::isVectorTy(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), and llvm::Value::takeName().
Definition at line 955 of file InstCombineMulDivRem.cpp.
References llvm::SelectInst::Create(), dyn_castZExtVal(), llvm::User::getOperand(), llvm::ConstantExpr::getShl(), llvm::Value::getType(), llvm::Instruction::insertBefore(), llvm::BinaryOperator::isExact(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::SimplifyUDivInst(), visitUDivOperand(), and llvm::X.
Instruction * InstCombiner::visitUIToFP | ( | CastInst & | CI | ) |
Definition at line 1403 of file InstCombineCasts.cpp.
Definition at line 1275 of file InstCombineMulDivRem.cpp.
References dyn_castZExtVal(), llvm::MipsISD::Ext, llvm::Constant::getAllOnesValue(), llvm::User::getOperand(), llvm::Value::getType(), llvm::isKnownToBeAPowerOfTwo(), llvm::PatternMatch::m_One(), llvm::PatternMatch::match(), and llvm::SimplifyURemInst().
Definition at line 2390 of file InstCombineAndOrXor.cpp.
References llvm::ARM_PROC::A, llvm::APIntOps::And(), llvm::CallingConv::C, llvm::tgtok::Code, llvm::CastInst::Create(), llvm::CmpInst::Create(), CreateAdd(), llvm::BinaryOperator::CreateNot(), llvm::dyn_cast(), dyn_castNotVal(), llvm::ConstantInt::get(), llvm::ConstantExpr::getAnd(), llvm::ConstantExpr::getCast(), llvm::Instruction::getDebugLoc(), llvm::getICmpCode(), llvm::Value::getName(), llvm::ConstantExpr::getNeg(), getNewICmpValue(), llvm::ConstantExpr::getNot(), llvm::BinaryOperator::getOpcode(), llvm::CmpInst::getOpcode(), llvm::User::getOperand(), llvm::ConstantExpr::getOr(), llvm::ConstantExpr::getSub(), llvm::ConstantInt::getType(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::Value::hasOneUse(), I, isFreeToInvert(), llvm::Type::isIntegerTy(), llvm::LShr, llvm::APInt::lshr(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::AArch64CC::NV, llvm::APIntOps::Or(), llvm::PredicatesFoldable(), llvm::User::setOperand(), llvm::SExt, llvm::SimplifyXorInst(), std::swap(), llvm::BinaryOperator::swapOperands(), llvm::Value::takeName(), and llvm::APIntOps::Xor().
Instruction * InstCombiner::visitZExt | ( | ZExtInst & | CI | ) |
Definition at line 763 of file InstCombineCasts.cpp.
References llvm::ARM_PROC::A, llvm::APIntOps::And(), llvm::CallingConv::C, CanEvaluateZExtd(), llvm::BinaryOperator::Create(), llvm::dbgs(), DEBUG, llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::APInt::getHighBitsSet(), llvm::APInt::getLowBitsSet(), llvm::Value::getName(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::Value::getType(), llvm::ConstantExpr::getZExt(), llvm::Value::hasOneUse(), llvm::Type::isIntegerTy(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::APIntOps::Or(), llvm::Trunc, llvm::Instruction::user_back(), and llvm::X.
Definition at line 113 of file InstCombine.h.
Referenced by EvaluateGEPOffsetExpression(), FoldOperationIntoSelectOperand(), foldUDivNegCst(), foldUDivShl(), GetShiftedValue(), InstCombineLoadCast(), InstCombineStoreToCast(), OptimizeIntegerToVectorInsertions(), OptimizeIntToFloatBitCast(), OptimizeVectorResize(), ProcessUAddIdiom(), ProcessUGT_ADDCST_ADD(), ProcessUMulZExtIdiom(), simplifyValueKnownNonZero(), SliceUpIllegalIntegerPHI(), visitAllocaInst(), and visitLoadInst().
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().