LLVM 22.0.0git
|
#include "Transforms/InstCombine/InstCombineInternal.h"
Additional Inherited Members | |
![]() | |
using | BuilderTy = IRBuilder< TargetFolder, IRBuilderCallbackInserter > |
An IRBuilder that automatically inserts new instructions into the worklist. | |
![]() | |
static Value * | peekThroughBitcast (Value *V, bool OneUseOnly=false) |
Return the source operand of a potentially bitcasted value while optionally checking if it has one use. | |
static unsigned | getComplexity (Value *V) |
Assign a complexity or rank value to LLVM Values. | |
static bool | isCanonicalPredicate (CmpPredicate Pred) |
Predicate canonicalization reduces the number of patterns that need to be matched by other transforms. | |
static Constant * | AddOne (Constant *C) |
Add one to a Constant. | |
static Constant * | SubOne (Constant *C) |
Subtract one from a Constant. | |
static bool | shouldAvoidAbsorbingNotIntoSelect (const SelectInst &SI) |
static Constant * | getSafeVectorConstantForBinop (BinaryOperator::BinaryOps Opcode, Constant *In, bool IsRHSConstant) |
Some binary operators require special handling to avoid poison and undefined behavior. | |
![]() | |
uint64_t | MaxArraySizeForCombine = 0 |
Maximum size of array considered when transforming. | |
BuilderTy & | Builder |
![]() | |
InstructionWorklist & | Worklist |
A worklist of the instructions that need to be simplified. | |
const bool | MinimizeSize |
AAResults * | AA |
AssumptionCache & | AC |
TargetLibraryInfo & | TLI |
DominatorTree & | DT |
const DataLayout & | DL |
SimplifyQuery | SQ |
OptimizationRemarkEmitter & | ORE |
BlockFrequencyInfo * | BFI |
BranchProbabilityInfo * | BPI |
ProfileSummaryInfo * | PSI |
DomConditionCache | DC |
ReversePostOrderTraversal< BasicBlock * > & | RPOT |
bool | MadeIRChange = false |
SmallDenseSet< std::pair< BasicBlock *, BasicBlock * >, 8 > | DeadEdges |
Edges that are known to never be taken. | |
SmallDenseMap< BasicBlock *, SmallVector< BasicBlock * >, 8 > | PredOrder |
Order of predecessors to canonicalize phi nodes towards. | |
SmallDenseSet< std::pair< const BasicBlock *, const BasicBlock * >, 8 > | BackEdges |
Backedges, used to avoid pushing instructions across backedges in cases where this may result in infinite combine loops. | |
bool | ComputedBackEdges = false |
Definition at line 60 of file InstCombineInternal.h.
|
inline |
Definition at line 64 of file InstCombineInternal.h.
|
virtualdefault |
void InstCombinerImpl::addDeadEdge | ( | BasicBlock * | From, |
BasicBlock * | To, | ||
SmallVectorImpl< BasicBlock * > & | Worklist | ||
) |
Definition at line 4039 of file InstructionCombining.cpp.
References llvm::InstCombiner::addToWorklist(), llvm::InstCombiner::DeadEdges, From, llvm::PoisonValue::get(), llvm::InstCombiner::MadeIRChange, llvm::BasicBlock::phis(), llvm::InstCombiner::replaceUse(), and llvm::InstCombiner::Worklist.
Referenced by handlePotentiallyDeadSuccessors(), and handleUnreachableFrom().
Instruction * InstCombinerImpl::canonicalizeCondSignextOfHighBitExtractToSignextHighBitExtract | ( | BinaryOperator & | I | ) |
Definition at line 1346 of file InstCombineAddSub.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::CastInst::CreateTruncOrBitCast(), llvm::Value::getName(), llvm::Type::getScalarSizeInBits(), I, llvm::IRBuilderBase::Insert(), llvm::isSignBitCheck(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_SExtOrSelf(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_TruncOrSelf(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::m_ZExtOrSelf(), llvm::PatternMatch::match(), Select, std::swap(), and X.
Referenced by visitAdd(), visitOr(), and visitSub().
If we have a comparison with a non-canonical predicate, if we can update all the users, invert the predicate and adjust all the users.
Definition at line 7193 of file InstCombineCompares.cpp.
References llvm::InstCombiner::canFreelyInvertAllUsersOf(), freelyInvertAllUsersOf(), llvm::CmpInst::getInversePredicate(), I, and llvm::InstCombiner::isCanonicalPredicate().
Referenced by visitICmpInst().
LoadInst * InstCombinerImpl::combineLoadToNewType | ( | LoadInst & | LI, |
Type * | NewTy, | ||
const Twine & | Suffix = "" |
||
) |
Helper to combine a load to a new type.
This just does the work of combining a load to a new type. It handles metadata, etc., and returns the new instruction. The NewTy
should be the loaded value type. This will convert it to a pointer, cast the operand to that pointer type, load it, etc.
Note that this will create all of the instructions with whatever insert point the InstCombinerImpl
currently is using.
Definition at line 590 of file InstCombineLoadStoreAlloca.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::copyMetadataForLoad(), llvm::IRBuilderBase::CreateAlignedLoad(), llvm::LoadInst::getAlign(), llvm::Value::getName(), llvm::LoadInst::getOrdering(), llvm::LoadInst::getPointerOperand(), llvm::LoadInst::getSyncScopeID(), llvm::Instruction::isAtomic(), isSupportedAtomicType(), llvm::LoadInst::isVolatile(), and llvm::LoadInst::setAtomic().
Referenced by combineLoadToOperationType(), and unpackLoadToAggregate().
Instruction * InstCombinerImpl::commonCastTransforms | ( | CastInst & | CI | ) |
Implement the transforms common to all CastInst visitors.
Definition at line 156 of file InstCombineCasts.cpp.
References llvm::InstCombiner::Builder, llvm::ConstantFoldCastOperand(), llvm::CastInst::Create(), llvm::IRBuilderBase::CreateCast(), llvm::InstCombiner::DL, llvm::InstCombiner::DT, foldOpIntoPhi(), FoldOpIntoSelect(), llvm::CastInst::getOpcode(), llvm::User::getOperand(), llvm::Type::getPrimitiveSizeInBits(), llvm::CastInst::getSrcTy(), llvm::Value::getType(), llvm::Type::isIntegerTy(), llvm::PatternMatch::m_ElementWiseBitCast(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Shuffle(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::replaceAllDbgUsesWith(), llvm::InstCombiner::replaceInstUsesWith(), and X.
Referenced by visitAddrSpaceCast(), visitBitCast(), visitFPExt(), visitFPToSI(), visitFPToUI(), visitFPTrunc(), visitIntToPtr(), visitPtrToInt(), visitSExt(), visitSIToFP(), visitTrunc(), visitUIToFP(), and visitZExt().
Instruction * InstCombinerImpl::commonIDivRemTransforms | ( | BinaryOperator & | I | ) |
Common integer divide/remainder transforms.
Definition at line 1270 of file InstCombineMulDivRem.cpp.
References assert(), foldBinopWithPhiOperands(), FoldOpIntoSelect(), llvm::PoisonValue::get(), llvm::Constant::getAggregateElement(), I, llvm::Constant::isNullValue(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), simplifyDivRemOfSelectWithZeroOp(), and simplifyValueKnownNonZero().
Referenced by commonIDivTransforms(), and commonIRemTransforms().
Instruction * InstCombinerImpl::commonIDivTransforms | ( | BinaryOperator & | I | ) |
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. Common integer divide transforms
Definition at line 1317 of file InstCombineMulDivRem.cpp.
References A, assert(), B, llvm::InstCombiner::Builder, commonIDivRemTransforms(), llvm::BinaryOperator::Create(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateFreeze(), llvm::IRBuilderBase::CreateICmpEQ(), llvm::IRBuilderBase::CreateICmpULT(), llvm::IRBuilderBase::CreateShl(), foldBinOpIntoSelectOrPhi(), foldIDivShl(), llvm::APInt::getBitWidth(), llvm::APInt::getOneBitSet(), llvm::APInt::getZExtValue(), llvm::Instruction::hasNoSignedWrap(), hasNoUnsignedWrap(), I, llvm::APInt::isAllOnes(), llvm::isGuaranteedNotToBeUndef(), llvm::Type::isIntOrIntVectorTy(), isMultiple(), llvm::APInt::isZero(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_c_Mul(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_NSWAddLike(), llvm::PatternMatch::m_NSWMul(), llvm::PatternMatch::m_NSWShl(), llvm::PatternMatch::m_NUWAddLike(), llvm::PatternMatch::m_NUWMul(), llvm::PatternMatch::m_NUWShl(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_SDiv(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_SRem(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_UDiv(), llvm::PatternMatch::m_URem(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::Mul, multiplyOverflows(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), llvm::Instruction::setIsExact(), SimplifyDemandedInstructionBits(), llvm::APInt::udiv(), llvm::APInt::ule(), llvm::APInt::ult(), X, and Y.
Referenced by visitSDiv(), and visitUDiv().
Instruction * InstCombinerImpl::commonIRemTransforms | ( | BinaryOperator & | I | ) |
This function implements the transforms common to both integer remainder instructions (urem and srem).
It is called by the visitors to those integer remainder instructions. Common integer remainder transforms
Definition at line 2370 of file InstCombineMulDivRem.cpp.
References commonIDivRemTransforms(), foldOpIntoPhi(), FoldOpIntoSelect(), I, llvm::APInt::isMinSignedValue(), llvm::APInt::isMinValue(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), SimplifyDemandedInstructionBits(), and simplifyIRemMulShl().
Referenced by visitSRem(), and visitURem().
Instruction * InstCombinerImpl::commonShiftTransforms | ( | BinaryOperator & | I | ) |
Definition at line 405 of file InstCombineShifts.cpp.
References A, llvm::InstCombiner::AC, assert(), llvm::BitWidth, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::BinaryOperator::Create(), llvm::CastInst::Create(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateBinOp(), llvm::IRBuilderBase::CreateICmp(), llvm::IRBuilderBase::CreateZExt(), foldBinopWithPhiOperands(), FoldOpIntoSelect(), FoldShiftByConstant(), foldShiftOfShiftedBinOp(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::ConstantExpr::getSub(), llvm::Value::getType(), I, llvm::APInt::isNegative(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_NUWAddLike(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_SRem(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), reassociateShiftAmtsOfTwoSameDirectionShifts(), llvm::InstCombiner::replaceOperand(), llvm::Instruction::setHasNoSignedWrap(), llvm::Instruction::setHasNoUnsignedWrap(), llvm::Instruction::setIsExact(), SimplifyDemandedInstructionBits(), llvm::InstCombiner::SQ, and Y.
Referenced by visitAShr(), visitLShr(), and visitShl().
|
inline |
Definition at line 203 of file InstCombineInternal.h.
References llvm::computeKnownFPClass(), and llvm::Depth.
Referenced by foldSelectIntoOp(), and SimplifyDemandedUseFPClass().
|
inline |
Definition at line 212 of file InstCombineInternal.h.
References llvm::computeKnownFPClass(), and llvm::Depth.
OverflowResult InstCombinerImpl::computeOverflow | ( | Instruction::BinaryOps | BinaryOp, |
bool | IsSigned, | ||
Value * | LHS, | ||
Value * | RHS, | ||
Instruction * | CxtI | ||
) | const |
Definition at line 6494 of file InstCombineCompares.cpp.
References llvm::InstCombiner::computeOverflowForSignedAdd(), llvm::InstCombiner::computeOverflowForSignedMul(), llvm::InstCombiner::computeOverflowForSignedSub(), llvm::InstCombiner::computeOverflowForUnsignedAdd(), llvm::InstCombiner::computeOverflowForUnsignedMul(), llvm::InstCombiner::computeOverflowForUnsignedSub(), LHS, llvm_unreachable, and RHS.
Referenced by foldICmpBinOpEqualityWithConstant(), and visitCallInst().
std::optional< std::pair< Intrinsic::ID, SmallVector< Value *, 3 > > > InstCombinerImpl::convertOrOfShiftsToFunnelShift | ( | Instruction & | Or | ) |
Definition at line 2931 of file InstCombineAndOrXor.cpp.
References assert(), llvm::InstCombiner::computeKnownBits(), llvm::DominatorTree::dominates(), llvm::InstCombiner::DT, llvm::SmallVectorBase< Size_T >::empty(), llvm::ConstantExpr::getAdd(), llvm::KnownBits::getMaxValue(), llvm::Instruction::getOpcode(), llvm::Value::getType(), High, llvm::CmpInst::ICMP_ULT, llvm::isPowerOf2_32(), llvm::Low, llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_APIntAllowPoison(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_LogicalShift(), llvm::MIPatternMatch::m_Neg(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_SpecificInt_ICMP(), llvm::PatternMatch::m_SpecificIntAllowPoison(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::Constant::mergeUndefsWith(), std::swap(), llvm::APInt::uge(), llvm::APInt::ugt(), llvm::APInt::ule(), llvm::APInt::ult(), llvm::Value::users(), X, and Y.
Referenced by matchFunnelShift(), and SimplifyDemandedUseBits().
|
inline |
Create and insert the idiom we use to indicate a block is unreachable without having to rewrite the CFG from within InstCombine.
Definition at line 492 of file InstCombineInternal.h.
References Align, llvm::Value::getContext(), llvm::ilist_node_impl< OptionsT >::getIterator(), and SI().
Referenced by visitCallInst(), visitFree(), and visitLoadInst().
bool InstCombinerImpl::dominatesAllUses | ( | const Instruction * | DI, |
const Instruction * | UI, | ||
const BasicBlock * | DB | ||
) | const |
True when DB dominates all uses of DI except UI.
Check that one use is in the same block as the definition and all other uses are in blocks dominated by a given block.
UI must be in the same block as DI. The routine checks that the DI parent and DB are different.
DI | Definition |
UI | Use |
DB | Block that must dominate all uses of DI outside the parent block |
UI
is the only use of DI
in the parent block and all other uses of DI
are in blocks dominated by DB
. Definition at line 6767 of file InstCombineCompares.cpp.
References assert(), llvm::DominatorTree::dominates(), llvm::InstCombiner::DT, llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), and llvm::Value::users().
Referenced by replacedSelectWithOperand().
|
inlineoverridevirtual |
Combiner aware instruction erasure.
When dealing with an instruction that has side effects or produces a void value, we can't rely on DCE to delete the instruction. Instead, visit methods should return the value returned by this function.
Implements llvm::InstCombiner.
Definition at line 505 of file InstCombineInternal.h.
References assert(), llvm::dbgs(), I, LLVM_DEBUG, and llvm::salvageDebugInfo().
Referenced by combineLoadToOperationType(), convertFSqrtDivIntoFMul(), foldAllocaCmp(), foldBinopWithRecurrence(), foldDeadPhiWeb(), foldIntegerTypedPHI(), foldMultiplicationOverflowCheck(), foldOpIntoPhi(), handleUnreachableFrom(), mergeStoreIntoSuccessor(), processUGT_ADDCST_ADD(), removeInstructionsBeforeUnreachable(), removeTriviallyEmptyRange(), run(), visitAllocaInst(), visitAllocSite(), visitCallInst(), visitFenceInst(), visitFree(), visitICmpInst(), and visitStoreInst().
Given an expression that CanEvaluateTruncated or CanEvaluateSExtd returns true for, actually insert the code to evaluate the expression.
Definition at line 30 of file InstCombineCasts.cpp.
References llvm::PHINode::addIncoming(), llvm::CallingConv::C, llvm::ConstantFoldIntegerCast(), llvm::BinaryOperator::Create(), llvm::CallInst::Create(), llvm::CastInst::Create(), llvm::PHINode::Create(), llvm::SelectInst::Create(), llvm::CastInst::CreateIntegerCast(), llvm::InstCombiner::DL, EvaluateInDifferentType(), llvm::VectorType::get(), llvm::Function::getFunctionType(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), llvm::Intrinsic::getOrInsertDeclaration(), I, II, llvm::InstCombiner::InsertNewInstWith(), isSigned(), LHS, llvm_unreachable, Opc, RHS, llvm::Instruction::setIsExact(), and llvm::Value::takeName().
Referenced by EvaluateInDifferentType(), visitSExt(), visitTrunc(), and visitZExt().
bool llvm::InstCombinerImpl::fmulByZeroIsZero | ( | Value * | MulVal, |
FastMathFlags | FMF, | ||
const Instruction * | CtxI | ||
) | const |
Check if fmul MulVal
, +0.0 will yield +0.0 (or signed zero is ignorable).
Instruction * InstCombinerImpl::foldAddLikeCommutative | ( | Value * | LHS, |
Value * | RHS, | ||
bool | NSW, | ||
bool | NUW | ||
) |
Common transforms for add / disjoint or.
Definition at line 1316 of file InstCombineAddSub.cpp.
References A, B, llvm::CallingConv::C, llvm::APInt::getBitWidth(), llvm::Value::getType(), LHS, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_NSWSub(), llvm::PatternMatch::m_NUWSub(), llvm::PatternMatch::m_SDiv(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and RHS.
Referenced by visitAdd(), and visitOr().
Instruction * InstCombinerImpl::foldAddWithConstant | ( | BinaryOperator & | Add | ) |
Definition at line 856 of file InstCombineAddSub.cpp.
References llvm::Add, llvm::InstCombiner::AddOne(), llvm::BitWidth, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::InstCombiner::computeKnownBits(), llvm::CastInst::Create(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateBinaryIntrinsic(), llvm::IRBuilderBase::CreateIsNotNeg(), llvm::IRBuilderBase::CreateNot(), llvm::IRBuilderBase::CreateShl(), foldBinOpIntoSelectOrPhi(), llvm::ConstantExpr::getAdd(), llvm::APInt::getHighBitsSet(), llvm::Type::getScalarSizeInBits(), llvm::ConstantExpr::getSub(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::Value::hasOneUse(), llvm::isKnownNonZero(), llvm::APInt::isMask(), llvm::APInt::isMinSignedValue(), llvm::APInt::isPowerOf2(), llvm::APInt::isSignMask(), llvm::APInt::logBase2(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_DisjointOr(), llvm::PatternMatch::m_ImmConstant(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_SpecificIntAllowPoison(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_UMax(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::PatternMatch::m_ZExt(), llvm::InstCombiner::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), llvm::Instruction::setHasNoSignedWrap(), llvm::Instruction::setHasNoUnsignedWrap(), llvm::APInt::sext(), llvm::InstCombiner::SQ, llvm::InstCombiner::SubOne(), X, Y, and llvm::KnownBits::Zero.
Referenced by visitAdd().
Instruction * InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse | ( | InsertValueInst & | OrigIVI | ) |
Look for chain of insertvalue's that fully define an aggregate, and trace back the values inserted, see if they are all were extractvalue'd from the same source aggregate from the exact same element indexes.
If they were, just reuse the source aggregate. This potentially deals with PHI indirections.
When analyzing the value that was inserted into an aggregate, we did not manage to find defining extractvalue
instruction to analyze.
When analyzing the value that was inserted into an aggregate, we did manage to find defining extractvalue
instruction[s], and everything matched perfectly - aggregate type, element insertion/extraction index.
When analyzing the value that was inserted into an aggregate, we did manage to find defining extractvalue
instruction, but there was a mismatch: either the source type from which the extraction was didn't match the aggregate type into which the insertion was, or the extraction/insertion channels mismatched, or different elements had different source aggregates.
Definition at line 887 of file InstCombineVectorOps.cpp.
References llvm::Type::ArrayTyID, assert(), llvm::InstCombiner::Builder, llvm::IRBuilderBase::CreateInsertValue(), llvm::IRBuilderBase::CreatePHI(), llvm::Depth, llvm::Value::DoPHITranslation(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::enumerate(), llvm::ArrayRef< T >::front(), llvm::PoisonValue::get(), llvm::Type::getArrayNumElements(), llvm::Value::getName(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getParent(), llvm::Type::getStructNumElements(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::Type::getTypeID(), I, Idx, llvm::is_contained(), IV, llvm_unreachable, PHI, llvm::pred_empty(), llvm::predecessors(), llvm::InstCombiner::replaceInstUsesWith(), llvm::IRBuilderBase::SetInsertPoint(), llvm::ArrayRef< T >::size(), llvm::SmallVectorBase< Size_T >::size(), llvm::Type::StructTyID, and llvm::MapVector< KeyT, ValueT, MapType, VectorType >::try_emplace().
Referenced by visitInsertValueInst().
bool InstCombinerImpl::foldAllocaCmp | ( | AllocaInst * | Alloca | ) |
The value of the map is a bit mask of which icmp operands the alloca is used in.
Definition at line 870 of file InstCombineCompares.cpp.
References llvm::Continue, eraseInstFromFunction(), llvm::getUnderlyingObject(), llvm::CmpInst::ICMP_NE, llvm_unreachable, Operands, llvm::PointerMayBeCaptured(), and llvm::InstCombiner::replaceInstUsesWith().
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldBinOpIntoSelectOrPhi | ( | BinaryOperator & | I | ) |
This is a convenience wrapper function for the above two functions.
Definition at line 2255 of file InstructionCombining.cpp.
References foldOpIntoPhi(), FoldOpIntoSelect(), and I.
Referenced by commonIDivTransforms(), foldAddWithConstant(), FoldShiftByConstant(), visitAnd(), visitFAdd(), visitFMul(), visitMul(), visitOr(), and visitXor().
Instruction * InstCombinerImpl::foldBinOpOfSelectAndCastOfSelectCondition | ( | BinaryOperator & | I | ) |
Tries to simplify binops of select and cast of the select condition.
(Binop (cast C), (select C, T, F)) -> (select C, C0, C1)
Definition at line 1097 of file InstructionCombining.cpp.
References A, llvm::BitWidth, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateBinOp(), llvm::Constant::getAllOnesValue(), llvm::Constant::getIntegerValue(), llvm::Constant::getNullValue(), I, LHS, llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::PatternMatch::match(), Opc, and RHS.
Referenced by visitAdd(), visitMul(), and visitSub().
Instruction * InstCombinerImpl::foldBinOpShiftWithShift | ( | BinaryOperator & | I | ) |
Definition at line 951 of file InstructionCombining.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::ConstantFoldBinaryOpOperands(), llvm::BinaryOperator::Create(), llvm::IRBuilderBase::CreateBinOp(), llvm::IRBuilderBase::CreateNot(), llvm::InstCombiner::DL, I, llvm::Instruction::isBitwiseLogicOp(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_CombineAnd(), llvm::PatternMatch::m_ImmConstant(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Shift(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), Opc, X, and Y.
Referenced by visitAdd(), visitAnd(), visitOr(), and visitXor().
Instruction * InstCombinerImpl::foldBinopWithPhiOperands | ( | BinaryOperator & | BO | ) |
For a binary operator with 2 phi operands, try to hoist the binary operation before the phi.
This can result in fewer instructions in patterns where at least one set of phi operands simplifies. Example: BB3: binop (phi [X, BB1], [C1, BB2]), (phi [Y, BB1], [C2, BB2]) --> BB1: BO = binop X, Y BB3: phi [BO, BB1], [(binop C1, C2), BB2]
Definition at line 2140 of file InstructionCombining.cpp.
References llvm::PHINode::addIncoming(), llvm::all_of(), assert(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::ConstantFoldBinaryOpOperands(), llvm::PHINode::Create(), llvm::IRBuilderBase::CreateBinOp(), llvm::InstCombiner::DL, llvm::InstCombiner::DT, foldBinopWithRecurrence(), llvm::ConstantExpr::getBinOpIdentity(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), I, llvm::isGuaranteedToTransferExecutionToSuccessor(), llvm::DominatorTree::isReachableFromEntry(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::match(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::IRBuilderBase::SetInsertPoint(), llvm::SmallVectorBase< Size_T >::size(), and llvm::zip().
Referenced by commonIDivRemTransforms(), commonShiftTransforms(), visitAdd(), visitAnd(), visitFAdd(), visitFDiv(), visitFMul(), visitFRem(), visitFSub(), visitMul(), visitOr(), visitSub(), and visitXor().
Instruction * InstCombinerImpl::foldBinopWithRecurrence | ( | BinaryOperator & | BO | ) |
Try to fold binary operators whose operands are simple interleaved recurrences to a single recurrence.
This is a common pattern in reduction operations. Example: phi1 = phi [init1, BB1], [op1, BB2] phi2 = phi [init2, BB1], [op2, BB2] op1 = binop phi1, constant1 op2 = binop phi2, constant2 rdx = binop op1, op2 --> phi_combined = phi [init_combined, BB1], [op_combined, BB2] rdx_combined = binop phi_combined, constant_combined
Definition at line 2037 of file InstructionCombining.cpp.
References assert(), llvm::CallingConv::C, llvm::ConstantFoldBinaryInstruction(), llvm::BinaryOperator::Create(), llvm::PHINode::Create(), llvm::dbgs(), eraseInstFromFunction(), llvm::PoisonValue::get(), llvm::Instruction::getFastMathFlags(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::PHINode::getNumIncomingValues(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::Value::getType(), llvm::Value::hasNUses(), llvm::Value::hasOneUse(), I, llvm::InstCombiner::InsertNewInstWith(), llvm::Instruction::isAssociative(), llvm::Instruction::isCommutative(), LLVM_DEBUG, llvm_unreachable, llvm::matchSimpleRecurrence(), Opc, and llvm::InstCombiner::replaceInstUsesWith().
Referenced by foldBinopWithPhiOperands().
Instruction * InstCombinerImpl::foldCmpLoadFromIndexedGlobal | ( | LoadInst * | LI, |
GetElementPtrInst * | GEP, | ||
GlobalVariable * | GV, | ||
CmpInst & | ICI, | ||
ConstantInt * | AndCst = nullptr |
||
) |
This is called when we see this pattern: cmp pred (load (gep GV, ...)), cmpcst where GV is a global variable with a constant initializer.
Try to simplify this into some simple computation that does not need the load. For example we can optimize "icmp eq (load (gep "foo", 0, i)), 0" into "icmp eq i, 3".
If AndCst is non-null, then the loaded value is masked with that constant before doing the comparison. This handles cases like "A[i]&4 == 0".
TrueRangeEnd/FalseRangeEnd - In conjunction with First*Element, these define a state machine that triggers for ranges of values that the index is true or false for. This triggers on things like "abbbbc"[i] == 'b'. This is -2 when undefined, -3 when overdefined, and otherwise the last index in the range (inclusive). We use -2 for undefined here because we use relative comparisons and don't want 0-1 to match -1.
Definition at line 112 of file InstCombineCompares.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::ConstantFoldBinaryOpOperands(), llvm::ConstantFoldCompareInstOperands(), llvm::ConstantFoldExtractValueInstruction(), llvm::countr_zero(), llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateICmpEQ(), llvm::IRBuilderBase::CreateICmpNE(), llvm::IRBuilderBase::CreateIntCast(), llvm::IRBuilderBase::CreateLShr(), llvm::InstCombiner::DL, llvm::SmallVectorBase< Size_T >::empty(), End, GEP, llvm::Constant::getAllOnesValue(), llvm::Type::getArrayElementType(), llvm::IRBuilderBase::getFalse(), llvm::DataLayout::getIndexType(), llvm::GlobalVariable::getInitializer(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::DataLayout::getSmallestLegalIntType(), llvm::IRBuilderBase::getTrue(), llvm::Value::getType(), getType(), llvm::DataLayout::getTypeAllocSize(), llvm::GlobalValue::getValueType(), llvm::GlobalVariable::hasDefinitiveInitializer(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, Idx, llvm::Type::isArrayTy(), llvm::GlobalVariable::isConstant(), llvm::LoadInst::isVolatile(), llvm::MIPatternMatch::m_ZeroInt(), llvm::PatternMatch::match(), llvm::InstCombiner::MaxArraySizeForCombine, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::InstCombiner::replaceInstUsesWith(), and llvm::InstCombiner::TLI.
Referenced by foldICmpAndConstant(), foldICmpInstWithConstantNotInt(), and visitFCmpInst().
If the phi is within a phi web, which is formed by the def-use chain of phis and all the phis in the web are only used in the other phis.
In this case, these phis are dead and we will remove all of them.
Definition at line 59 of file InstCombinePHI.cpp.
References eraseInstFromFunction(), llvm::PoisonValue::get(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::InstCombiner::replaceInstUsesWith(), and llvm::SmallPtrSetImplBase::size().
Referenced by visitPHINode().
Instruction * InstCombinerImpl::foldFCmpIntToFPConst | ( | FCmpInst & | I, |
Instruction * | LHSI, | ||
Constant * | RHSC | ||
) |
Fold fcmp ([us]itofp x, cst) if possible.
Definition at line 7978 of file InstCombineCompares.cpp.
References assert(), 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::ConstantInt::getFalse(), llvm::Type::getFPMantissaWidth(), llvm::APFloat::getLargest(), llvm::APInt::getMaxValue(), llvm::APInt::getMinValue(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::APFloatBase::IEK_Inf, llvm::ilogb(), llvm_unreachable, llvm::PatternMatch::m_APFloat(), llvm::PatternMatch::match(), P, llvm::InstCombiner::replaceInstUsesWith(), RHS, llvm::APFloatBase::rmNearestTiesToEven, llvm::APFloatBase::rmTowardZero, llvm::APFloat::roundToIntegral(), llvm::SMax, llvm::SMin, llvm::UMax, and llvm::UMin.
Referenced by visitFCmpInst().
Instruction * InstCombinerImpl::foldFMulReassoc | ( | BinaryOperator & | I | ) |
Definition at line 776 of file InstCombineMulDivRem.cpp.
References llvm::FastMathFlags::allowReassoc(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::ConstantFoldBinaryOpOperands(), llvm::IRBuilderBase::CreateBinaryIntrinsic(), llvm::IRBuilderBase::CreateFAddFMF(), llvm::BinaryOperator::CreateFAddFMF(), llvm::BinaryOperator::CreateFDivFMF(), llvm::IRBuilderBase::CreateFMulFMF(), llvm::BinaryOperator::CreateFMulFMF(), llvm::BinaryOperator::CreateFSubFMF(), llvm::IRBuilderBase::CreateUnaryIntrinsic(), llvm::InstCombiner::DL, foldPowiReassoc(), llvm::Instruction::getFastMathFlags(), llvm::Value::hasNUses(), llvm::Value::hasOneUse(), I, llvm::Constant::isNormalFP(), llvm::PatternMatch::m_AllowReassoc(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_c_FMul(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_FAdd(), llvm::PatternMatch::m_FDiv(), llvm::PatternMatch::m_FSub(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificFP(), llvm::PatternMatch::m_Sqrt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), X, and Y.
Referenced by visitFMul().
Instruction * InstCombinerImpl::foldFreezeIntoRecurrence | ( | FreezeInst & | I, |
PHINode * | PN | ||
) |
Definition at line 5028 of file InstructionCombining.cpp.
References llvm::append_range(), llvm::InstCombiner::Builder, llvm::canCreateUndefOrPoison(), llvm::IRBuilderBase::CreateFreeze(), llvm::DominatorTree::dominates(), llvm::InstCombiner::DT, llvm::PHINode::getIncomingBlock(), llvm::Value::getName(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getTerminator(), I, llvm::PHINode::incoming_values(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isGuaranteedNotToBeUndefOrPoison(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceUse(), llvm::IRBuilderBase::SetInsertPoint(), llvm::SmallPtrSetImplBase::size(), and llvm::InstCombiner::Worklist.
Referenced by visitFreeze().
Instruction * InstCombinerImpl::foldGEPICmp | ( | GEPOperator * | GEPLHS, |
Value * | RHS, | ||
CmpPredicate | Cond, | ||
Instruction & | I | ||
) |
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 686 of file InstCombineCompares.cpp.
References assert(), llvm::sampleprof::Base, llvm::InstCombiner::Builder, llvm::CommonPointerBase::compute(), Cond, llvm::IRBuilderBase::CreateICmp(), llvm::IRBuilderBase::CreateTrunc(), llvm::IRBuilderBase::CreateVectorSplat(), llvm::InstCombiner::DL, llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getFixedValue(), llvm::DataLayout::getIndexType(), llvm::GEPOperator::getNoWrapFlags(), llvm::Constant::getNullValue(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::Type::getPointerAddressSpace(), llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(), llvm::GEPOperator::getPointerOperand(), llvm::Type::getPrimitiveSizeInBits(), llvm::ICmpInst::getSignedPredicate(), llvm::GEPOperator::getSourceElementType(), llvm::Value::getType(), llvm::GEPOperator::hasAllConstantIndices(), llvm::GEPNoWrapFlags::hasNoUnsignedSignedWrap(), llvm::GEPNoWrapFlags::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), I, llvm::ICmpInst::isEquality(), llvm::GEPOperator::isInBounds(), llvm::CmpInst::isSigned(), llvm::CmpInst::isTrueWhenEqual(), llvm::CmpInst::isUnsigned(), llvm::Type::isVectorTy(), llvm::CmpInst::makeCmpResultType(), llvm::GEPNoWrapFlags::none(), llvm::NullPointerIsDefined(), llvm::Offset, llvm::InstCombiner::replaceInstUsesWith(), RHS, llvm::Value::stripPointerCasts(), and transformToIndexedCompare().
Referenced by foldICmpCommutative().
Instruction * InstCombinerImpl::foldICmpAddConstant | ( | ICmpInst & | Cmp, |
BinaryOperator * | Add, | ||
const APInt & | C | ||
) |
Fold icmp (add X, Y), C.
Definition at line 3176 of file InstCombineCompares.cpp.
References llvm::Add, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::ICmpInst::compare(), llvm::computeConstantRange(), Cond, llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateAnd(), createLogicFromTable(), llvm::ConstantRange::getEquivalentICmp(), llvm::ConstantExpr::getNeg(), llvm::Type::getScalarSizeInBits(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), llvm::ICmpInst::getSignedPredicate(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), 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_ULE, llvm::CmpInst::ICMP_ULT, llvm::APInt::isAllOnes(), llvm::Type::isIntOrIntVectorTy(), llvm::isKnownNonZero(), llvm::APInt::isPowerOf2(), llvm::CmpInst::isUnsigned(), llvm::APInt::isZero(), llvm::Lower, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_CombineAnd(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::ConstantRange::makeExactICmpRegion(), llvm::PatternMatch::match(), llvm::TruncInst::NoUnsignedWrap, llvm::InstCombiner::replaceInstUsesWith(), llvm::SMax, llvm::SMin, llvm::InstCombiner::SQ, llvm::ConstantRange::subtract(), llvm::ConstantRange::truncate(), llvm::Upper, X, and Y.
Referenced by foldICmpBinOpWithConstant().
Instruction * InstCombinerImpl::foldICmpAddOpConst | ( | Value * | X, |
const APInt & | C, | ||
CmpPredicate | Pred | ||
) |
Fold "icmp pred (X+C), X".
Definition at line 948 of file InstCombineCompares.cpp.
References assert(), llvm::CallingConv::C, llvm::APInt::getMaxValue(), llvm::APInt::getSignedMaxValue(), 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::SMax, and X.
Referenced by foldICmpCommutative().
Instruction * InstCombinerImpl::foldICmpAndConstant | ( | ICmpInst & | Cmp, |
BinaryOperator * | And, | ||
const APInt & | C | ||
) |
Fold icmp (and X, Y), C.
Definition at line 1964 of file InstCombineCompares.cpp.
References A, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateLShr(), llvm::BinaryOperator::CreateNot(), llvm::IRBuilderBase::CreateTrunc(), foldCmpLoadFromIndexedGlobal(), foldICmpAndConstConst(), GEP, llvm::Constant::getNullValue(), llvm::APInt::getSignedMinValue(), llvm::Value::getType(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::isSignBitCheck(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_LowBitMask(), llvm::MIPatternMatch::m_Neg(), llvm::MIPatternMatch::m_Not(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::InstCombiner::SubOne(), X, and Y.
Referenced by foldICmpBinOpWithConstant().
Instruction * InstCombinerImpl::foldICmpAndConstConst | ( | ICmpInst & | Cmp, |
BinaryOperator * | And, | ||
const APInt & | C1 | ||
) |
Fold icmp (and X, C2), C1.
Definition at line 1817 of file InstCombineCompares.cpp.
References A, B, llvm::APFloat::bitcastToAPInt(), llvm::InstCombiner::Builder, llvm::InstCombiner::computeKnownBits(), llvm::KnownBits::countMinLeadingZeros(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::createIsFPClass(), llvm::IRBuilderBase::CreateOr(), llvm::IRBuilderBase::CreateShl(), llvm::fcAllFlags, llvm::fcInf, llvm::fcNan, llvm::fcSubnormal, llvm::fcZero, foldICmpAndShift(), llvm::APInt::getBitWidth(), llvm::APInt::getHighBitsSet(), llvm::APFloat::getInf(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::Type::getScalarSizeInBits(), llvm::Value::hasOneUse(), I, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_ULT, llvm::APInt::isNegatedPowerOf2(), llvm::APInt::isNegative(), llvm::APInt::isSignMask(), llvm::APInt::isZero(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_ElementWiseBitCast(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), llvm::APInt::ule(), X, and llvm::APInt::zext().
Referenced by foldICmpAndConstant().
Instruction * InstCombinerImpl::foldICmpAndShift | ( | ICmpInst & | Cmp, |
BinaryOperator * | And, | ||
const APInt & | C1, | ||
const APInt & | C2 | ||
) |
Fold icmp (and (sh X, Y), C2), C1.
Definition at line 1730 of file InstCombineCompares.cpp.
References llvm::APInt::ashr(), assert(), llvm::InstCombiner::Builder, llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateLShr(), llvm::IRBuilderBase::CreateShl(), llvm::ConstantInt::getFalse(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::ConstantInt::getTrue(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::Instruction::isArithmeticShift(), llvm::APInt::isNegative(), llvm::APInt::isOne(), llvm::Instruction::isShift(), llvm::APInt::isZero(), llvm::APInt::lshr(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), and llvm::APInt::shl().
Referenced by foldICmpAndConstConst().
Instruction * InstCombinerImpl::foldICmpBinOp | ( | ICmpInst & | I, |
const SimplifyQuery & | SQ | ||
) |
Try to fold icmp (binop), X or icmp X, (binop).
TODO: A large part of this logic is duplicated in InstSimplify's simplifyICmpWithBinOp(). We should be able to share that and avoid the code duplication.
Definition at line 5170 of file InstCombineCompares.cpp.
References A, llvm::APInt::abs(), assert(), B, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::InstCombiner::computeKnownBits(), llvm::KnownBits::countMaxTrailingZeros(), llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateNot(), llvm::IRBuilderBase::CreateSub(), D, foldICmpAndXX(), foldICmpOrXX(), foldICmpWithTruncSignExtendedVal(), foldICmpXNegX(), foldICmpXorXX(), foldMultiplicationOverflowCheck(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), llvm::Constant::getAllOnesValue(), llvm::ConstantInt::getFalse(), llvm::CmpInst::getFlippedStrictnessPredicate(), llvm::Constant::getIntegerValue(), llvm::APInt::getLowBitsSet(), llvm::ConstantExpr::getNeg(), llvm::ConstantExpr::getNot(), llvm::Constant::getNullValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::ICmpInst::getSignedPredicate(), llvm::ConstantExpr::getSub(), llvm::CmpInst::getSwappedPredicate(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::APInt::isAllOnes(), llvm::ICmpInst::isEquality(), llvm::Instruction::isExact(), llvm::ICmpInst::isGE(), llvm::ICmpInst::isGT(), llvm::isKnownNonEqual(), llvm::isKnownNonZero(), llvm::ICmpInst::isLE(), llvm::ICmpInst::isLT(), isMultipleOf(), llvm::APInt::isNegative(), llvm::KnownBits::isNegative(), llvm::APInt::isOne(), llvm::ICmpInst::isRelational(), llvm::CmpInst::isSigned(), llvm::KnownBits::isStrictlyPositive(), llvm::CmpInst::isUnsigned(), llvm::APInt::isZero(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AddLike(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_APIntAllowPoison(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_Mul(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_LowBitMask(), llvm::PatternMatch::m_Mul(), llvm::MIPatternMatch::m_Neg(), llvm::PatternMatch::m_NegatedPower2OrZero(), llvm::PatternMatch::m_NonNegative(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_SignMask(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificIntAllowPoison(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::KnownBits::One, llvm::InstCombiner::replaceInstUsesWith(), llvm::simplifyICmpInst(), llvm::InstCombiner::SQ, llvm::APInt::uge(), llvm::APInt::ule(), X, and Y.
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldICmpBinOpEqualityWithConstant | ( | ICmpInst & | Cmp, |
BinaryOperator * | BO, | ||
const APInt & | C | ||
) |
Fold an icmp equality instruction with binary operator LHS and constant RHS: icmp eq/ne BO, C.
Definition at line 3643 of file InstCombineCompares.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, computeOverflow(), Cond, llvm::BinaryOperator::Create(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateICmp(), llvm::IRBuilderBase::CreateMul(), llvm::IRBuilderBase::CreateNeg(), llvm::IRBuilderBase::CreateNot(), llvm::IRBuilderBase::CreateOr(), llvm::IRBuilderBase::CreateURem(), llvm::Value::getName(), llvm::ConstantExpr::getNot(), llvm::Constant::getNullValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::ConstantExpr::getSub(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::ConstantExpr::getXor(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::Instruction::isExact(), llvm::isKnownNonZero(), llvm::APInt::isPowerOf2(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_CombineAnd(), llvm::PatternMatch::m_NUWAdd(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::NeverOverflows, llvm::Other, RHS, llvm::APInt::sgt(), llvm::InstCombiner::SQ, and llvm::Value::takeName().
Referenced by foldICmpBinOpWithConstant().
Instruction * InstCombinerImpl::foldICmpBinOpWithConstant | ( | ICmpInst & | Cmp, |
BinaryOperator * | BO, | ||
const APInt & | C | ||
) |
Fold an icmp with BinaryOp and constant operand: icmp Pred BO, C.
Definition at line 4022 of file InstCombineCompares.cpp.
References llvm::CallingConv::C, foldICmpAddConstant(), foldICmpAndConstant(), foldICmpBinOpEqualityWithConstant(), foldICmpBinOpWithConstantViaTruthTable(), foldICmpDivConstant(), foldICmpMulConstant(), foldICmpOrConstant(), foldICmpShlConstant(), foldICmpShrConstant(), foldICmpSRemConstant(), foldICmpSubConstant(), foldICmpUDivConstant(), foldICmpXorConstant(), llvm::BinaryOperator::getOpcode(), and I.
Referenced by foldICmpInstWithConstant().
Instruction * InstCombinerImpl::foldICmpBinOpWithConstantViaTruthTable | ( | ICmpInst & | Cmp, |
BinaryOperator * | BO, | ||
const APInt & | C | ||
) |
Definition at line 3137 of file InstCombineCompares.cpp.
References A, B, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::ICmpInst::compare(), Cond, llvm::ConstantFoldBinaryOpOperands(), createLogicFromTable(), llvm::InstCombiner::DL, llvm::First, llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Value::hasOneUse(), I, llvm::Type::isVectorTy(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and llvm::InstCombiner::replaceInstUsesWith().
Referenced by foldICmpBinOpWithConstant().
Instruction * InstCombinerImpl::foldICmpBitCast | ( | ICmpInst & | Cmp | ) |
Definition at line 3442 of file InstCombineCompares.cpp.
References llvm::all_equal(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::APFloat::classify(), llvm::IRBuilderBase::CreateBitCast(), llvm::IRBuilderBase::CreateExtractElement(), llvm::IRBuilderBase::createIsFPClass(), llvm::fcInf, llvm::fcZero, llvm::VectorType::get(), llvm::Constant::getAllOnesValue(), llvm::InstCombiner::getFreelyInverted(), llvm::IRBuilderBase::getInt32(), llvm::IRBuilderBase::getIntNTy(), llvm::Constant::getNullValue(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::Type::isIntegerTy(), llvm::Type::isIntOrIntVectorTy(), llvm::Type::isPPC_FP128Ty(), llvm::isSignBitCheck(), llvm::Type::isVectorTy(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_FPExt(), llvm::PatternMatch::m_FPTrunc(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Shuffle(), llvm::PatternMatch::m_SIToFP(), llvm::PatternMatch::m_UIToFP(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), and X.
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldICmpCommutative | ( | CmpPredicate | Pred, |
Value * | Op0, | ||
Value * | Op1, | ||
ICmpInst & | CxtI | ||
) |
Definition at line 7502 of file InstCombineCompares.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::IRBuilderBase::CreateICmpSGT(), llvm::IRBuilderBase::CreateICmpSLT(), llvm::IRBuilderBase::CreateICmpUGT(), llvm::IRBuilderBase::CreateICmpULT(), foldGEPICmp(), foldICmpAddOpConst(), foldICmpWithLowBitMaskedVal(), foldICmpWithMinMax(), foldSelectICmp(), GEP, llvm::Constant::getAllOnesValue(), llvm::ConstantInt::getFalse(), llvm::Constant::getNullValue(), llvm::APInt::getSignedMinValue(), llvm::CmpInst::getSwappedPredicate(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), 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::CmpInst::isUnsigned(), llvm_unreachable, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_CheckedInt(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_SDiv(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_UDiv(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), llvm::SMin, llvm::InstCombiner::SQ, and X.
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldICmpDivConstant | ( | ICmpInst & | Cmp, |
BinaryOperator * | Div, | ||
const APInt & | C | ||
) |
Fold icmp ({su}div X, Y), C.
Definition at line 2821 of file InstCombineCompares.cpp.
References addWithOverflow(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::BinaryOperator::Create(), llvm::IRBuilderBase::CreateICmp(), llvm::APInt::getBitWidth(), llvm::IRBuilderBase::getFalse(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::CmpInst::getSwappedPredicate(), llvm::IRBuilderBase::getTrue(), llvm::Value::getType(), 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, insertRangeTest(), llvm::APInt::isAllOnes(), llvm::Instruction::isExact(), llvm::APInt::isNegative(), llvm::APInt::isOne(), llvm::APInt::isStrictlyPositive(), llvm::APInt::isZero(), llvm_unreachable, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), llvm::APInt::negate(), llvm::InstCombiner::replaceInstUsesWith(), llvm::APInt::sdiv(), subWithOverflow(), llvm::APInt::udiv(), X, and Y.
Referenced by foldICmpBinOpWithConstant().
Instruction * InstCombinerImpl::foldICmpEqIntrinsicWithConstant | ( | ICmpInst & | ICI, |
IntrinsicInst * | II, | ||
const APInt & | C | ||
) |
Fold an equality icmp with LLVM intrinsic and constant operand.
Definition at line 3836 of file InstCombineCompares.cpp.
References llvm::BitWidth, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateOr(), llvm::Constant::getAllOnesValue(), llvm::APInt::getHighBitsSet(), llvm::APInt::getLowBitsSet(), llvm::Constant::getNullValue(), llvm::APInt::getOneBitSet(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, II, llvm::PatternMatch::m_APInt(), and llvm::PatternMatch::match().
Referenced by foldICmpIntrinsicWithConstant().
Instruction * InstCombinerImpl::foldICmpEquality | ( | ICmpInst & | Cmp | ) |
Definition at line 6003 of file InstCombineCompares.cpp.
References A, llvm::Add, B, llvm::BitWidth, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::APInt::countr_one(), llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateTrunc(), llvm::IRBuilderBase::CreateXor(), D, foldICmpEqualityWithOffset(), foldICmpIntrinsicWithIntrinsic(), llvm::APInt::getBitWidth(), llvm::ConstantInt::getBitWidth(), llvm::IRBuilderBase::getInt(), llvm::CmpInst::getInversePredicate(), llvm::APInt::getLimitedValue(), llvm::ConstantInt::getLimitedValue(), llvm::APInt::getLowBitsSet(), llvm::ConstantExpr::getNot(), llvm::Constant::getNullValue(), llvm::APInt::getOneBitSet(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::InstCombiner::getSimplifyQuery(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::Value::hasOneUse(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_ULT, llvm::InstCombiner::isKnownToBeAPowerOfTwo(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_APIntAllowPoison(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_ICmp(), llvm::PatternMatch::m_c_Xor(), llvm::PatternMatch::m_CombineAnd(), llvm::PatternMatch::m_CombineOr(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_LowBitMask(), llvm::PatternMatch::m_LShr(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Unless(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), NC, X, llvm::Xor, Y, and llvm::APInt::zext().
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldICmpInstWithConstant | ( | ICmpInst & | Cmp | ) |
Try to fold integer comparisons with a constant operand: icmp Pred X, C where X is some kind of instruction.
Definition at line 3596 of file InstCombineCompares.cpp.
References llvm::CallingConv::C, foldICmpBinOpWithConstant(), foldICmpInstWithConstantAllowPoison(), foldICmpIntrinsicWithConstant(), foldICmpSelectConstant(), foldICmpTruncConstant(), llvm::Value::hasOneUse(), I, II, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_APIntAllowPoison(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), X, and Y.
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldICmpInstWithConstantAllowPoison | ( | ICmpInst & | Cmp, |
const APInt & | C | ||
) |
Try to fold integer comparisons with a constant operand: icmp Pred X, C where X is some kind of instruction and C is AllowPoison.
TODO: Move more folds which allow poison to this function.
Definition at line 4000 of file InstCombineCompares.cpp.
References llvm::CallingConv::C, and II.
Referenced by foldICmpInstWithConstant().
Instruction * InstCombinerImpl::foldICmpInstWithConstantNotInt | ( | ICmpInst & | Cmp | ) |
Handle icmp with constant (but not simple integer constant) RHS.
Definition at line 4335 of file InstCombineCompares.cpp.
References llvm::InstCombiner::DL, foldCmpLoadFromIndexedGlobal(), GEP, llvm::DataLayout::getIntPtrType(), llvm::Constant::getNullValue(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), I, and llvm::Constant::isNullValue().
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldICmpIntrinsicWithConstant | ( | ICmpInst & | ICI, |
IntrinsicInst * | II, | ||
const APInt & | C | ||
) |
Fold an icmp with LLVM intrinsic and constant operand: icmp Pred II, C.
Definition at line 4227 of file InstCombineCompares.cpp.
References llvm::BitWidth, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::CmpInst::Create(), llvm::IRBuilderBase::CreateAnd(), foldCtpopPow2Test(), foldICmpEqIntrinsicWithConstant(), foldICmpOfCmpIntrinsicWithConstant(), foldICmpUSubSatOrUAddSatWithConstant(), llvm::Constant::getAllOnesValue(), llvm::APInt::getLowBitsSet(), llvm::Constant::getNullValue(), llvm::APInt::getOneBitSet(), llvm::SimplifyQuery::getWithInstruction(), 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_UGT, llvm::CmpInst::ICMP_ULT, II, llvm::CmpInst::isSigned(), llvm::InstCombiner::SQ, and X.
Referenced by foldICmpInstWithConstant(), and foldICmpWithTrunc().
Instruction * InstCombinerImpl::foldICmpMulConstant | ( | ICmpInst & | Cmp, |
BinaryOperator * | Mul, | ||
const APInt & | C | ||
) |
Fold icmp (mul X, Y), C.
Definition at line 2221 of file InstCombineCompares.cpp.
References assert(), llvm::CallingConv::C, llvm::APInt::DOWN, llvm::Constant::getNullValue(), llvm::CmpInst::getSwappedPredicate(), 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::isAllOnes(), llvm::APInt::isNegative(), llvm::CmpInst::isSigned(), isSignTest(), llvm::CmpInst::isUnsigned(), llvm::APInt::isZero(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), llvm::Mul, llvm::APIntOps::RoundingSDiv(), llvm::APIntOps::RoundingUDiv(), llvm::APInt::UP, and X.
Referenced by foldICmpBinOpWithConstant().
Instruction * InstCombinerImpl::foldICmpOrConstant | ( | ICmpInst & | Cmp, |
BinaryOperator * | Or, | ||
const APInt & | C | ||
) |
Fold icmp (or X, Y), C.
Definition at line 2120 of file InstCombineCompares.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::BinaryOperator::Create(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateICmp(), llvm::IRBuilderBase::CreateXor(), foldICmpOrXorSubChain(), llvm::CmpInst::getFlippedStrictnessPredicate(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::isSignBitCheck(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_Signum(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), P, llvm::InstCombiner::replaceInstUsesWith(), llvm::APInt::sge(), llvm::APInt::sgt(), and X.
Referenced by foldICmpBinOpWithConstant().
Instruction * InstCombinerImpl::foldICmpSelectConstant | ( | ICmpInst & | Cmp, |
SelectInst * | Select, | ||
ConstantInt * | C | ||
) |
Definition at line 3394 of file InstCombineCompares.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::ICmpInst::compare(), Cond, llvm::IRBuilderBase::CreateICmp(), llvm::IRBuilderBase::CreateOr(), llvm::IRBuilderBase::getFalse(), llvm::ConstantInt::getValue(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, matchThreeWayIntCompare(), llvm::InstCombiner::replaceInstUsesWith(), and Select.
Referenced by foldICmpInstWithConstant().
Instruction * InstCombinerImpl::foldICmpShlConstant | ( | ICmpInst & | Cmp, |
BinaryOperator * | Shl, | ||
const APInt & | C | ||
) |
Fold icmp (shl X, Y), C.
Definition at line 2362 of file InstCombineCompares.cpp.
References llvm::APInt::ashr(), assert(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::APInt::countr_zero(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateTrunc(), foldICmpShlConstConst(), foldICmpShlLHSC(), llvm::Type::getContext(), llvm::getFlippedStrictnessPredicateAndConstant(), llvm::APInt::getLimitedValue(), llvm::APInt::getLowBitsSet(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::APInt::getOneBitSet(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::Type::getWithNewBitWidth(), llvm::APInt::getZExtValue(), llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::ICmpInst::isEquality(), llvm::isSignBitCheck(), llvm::CmpInst::isStrictPredicate(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), llvm::APInt::trunc(), llvm::APInt::uge(), and X.
Referenced by foldICmpBinOpWithConstant().
Instruction * InstCombinerImpl::foldICmpShlConstConst | ( | ICmpInst & | I, |
Value * | ShAmt, | ||
const APInt & | C1, | ||
const APInt & | C2 | ||
) |
Handle "(icmp eq/ne (shl AP2, A), AP1)" -> (icmp eq/ne A, TrailingZeros(AP1) - TrailingZeros(AP2)).
Definition at line 1057 of file InstCombineCompares.cpp.
References A, assert(), llvm::APInt::countr_zero(), llvm::APInt::getBitWidth(), llvm::CmpInst::getInversePredicate(), llvm::Constant::getNullValue(), I, llvm::APInt::isZero(), LHS, llvm::InstCombiner::replaceInstUsesWith(), RHS, and llvm::APInt::shl().
Referenced by foldICmpShlConstant().
Instruction * InstCombinerImpl::foldICmpShrConstant | ( | ICmpInst & | Cmp, |
BinaryOperator * | Shr, | ||
const APInt & | C | ||
) |
Fold icmp ({al}shr X, Y), C.
Definition at line 2542 of file InstCombineCompares.cpp.
References llvm::APInt::ashr(), assert(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::APInt::countl_zero(), llvm::countl_zero(), llvm::IRBuilderBase::CreateAnd(), foldICmpShrConstConst(), llvm::Constant::getAllOnesValue(), llvm::APInt::getHighBitsSet(), llvm::APInt::getLimitedValue(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::Instruction::isExact(), llvm::APInt::isNegative(), llvm::APInt::isPowerOf2(), llvm::isSignBitCheck(), llvm::APInt::lshr(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), llvm::APInt::uge(), and X.
Referenced by foldICmpBinOpWithConstant().
Instruction * InstCombinerImpl::foldICmpShrConstConst | ( | ICmpInst & | I, |
Value * | ShAmt, | ||
const APInt & | C1, | ||
const APInt & | C2 | ||
) |
Handle "(icmp eq/ne (ashr/lshr AP2, A), AP1)" -> (icmp eq/ne A, Log2(AP2/AP1)) -> (icmp eq/ne A, Log2(AP2) - Log2(AP1)).
Definition at line 998 of file InstCombineCompares.cpp.
References A, llvm::APInt::ashr(), assert(), llvm::APInt::countl_one(), llvm::APInt::countl_zero(), llvm::CmpInst::getInversePredicate(), llvm::Constant::getNullValue(), I, llvm::APInt::isAllOnes(), llvm::APInt::isNegative(), llvm::APInt::isPowerOf2(), llvm::APInt::isZero(), LHS, llvm::APInt::logBase2(), llvm::APInt::lshr(), llvm::InstCombiner::replaceInstUsesWith(), RHS, and llvm::APInt::sgt().
Referenced by foldICmpShrConstant().
Instruction * InstCombinerImpl::foldICmpSRemConstant | ( | ICmpInst & | Cmp, |
BinaryOperator * | UDiv, | ||
const APInt & | C | ||
) |
Definition at line 2706 of file InstCombineCompares.cpp.
References llvm::APInt::abs(), assert(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::IRBuilderBase::CreateAnd(), llvm::APInt::flipAllBits(), llvm::Constant::getAllOnesValue(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::APInt::getSignMask(), llvm::Value::getType(), 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::APInt::isZero(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Power2(), llvm::PatternMatch::match(), and llvm::APInt::uge().
Referenced by foldICmpBinOpWithConstant().
Instruction * InstCombinerImpl::foldICmpSubConstant | ( | ICmpInst & | Cmp, |
BinaryOperator * | Sub, | ||
const APInt & | C | ||
) |
Fold icmp (sub X, Y), C.
Definition at line 3003 of file InstCombineCompares.cpp.
References llvm::Add, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateOr(), llvm::ConstantExpr::getSub(), 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_UGT, llvm::CmpInst::ICMP_ULT, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::match(), llvm::none_of(), llvm::Sub, subWithOverflow(), X, and Y.
Referenced by foldICmpBinOpWithConstant().
Instruction * InstCombinerImpl::foldICmpTruncConstant | ( | ICmpInst & | Cmp, |
TruncInst * | Trunc, | ||
const APInt & | C | ||
) |
Fold icmp (trunc X), C.
Definition at line 1483 of file InstCombineCompares.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::InstCombiner::computeKnownBits(), llvm::IRBuilderBase::CreateAnd(), llvm::Constant::getAllOnesValue(), llvm::APInt::getHighBitsSet(), llvm::APInt::getLowBitsSet(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::TruncInst::hasNoSignedWrap(), llvm::TruncInst::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::isSignBitCheck(), llvm::Type::isVectorTy(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_Signum(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::KnownBits::One, X, Y, and llvm::KnownBits::Zero.
Referenced by foldICmpInstWithConstant().
Instruction * InstCombinerImpl::foldICmpTruncWithTruncOrExt | ( | ICmpInst & | Cmp, |
const SimplifyQuery & | Q | ||
) |
Fold icmp (trunc nuw/nsw X), (trunc nuw/nsw Y).
Fold icmp (trunc nuw/nsw X), (zext/sext Y).
Definition at line 1570 of file InstCombineCompares.cpp.
References llvm::InstCombiner::Builder, llvm::IRBuilderBase::CreateIntCast(), llvm::Type::getScalarSizeInBits(), llvm::PatternMatch::m_c_ICmp(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_NSWTrunc(), llvm::PatternMatch::m_NUWTrunc(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::PatternMatch::match(), llvm::TruncInst::NoSignedWrap, llvm::TruncInst::NoUnsignedWrap, std::swap(), X, and Y.
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldICmpUDivConstant | ( | ICmpInst & | Cmp, |
BinaryOperator * | UDiv, | ||
const APInt & | C | ||
) |
Fold icmp (udiv X, Y), C.
Definition at line 2788 of file InstCombineCompares.cpp.
References assert(), llvm::CallingConv::C, llvm::User::getOperand(), llvm::Value::getType(), llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), llvm::APInt::udiv(), X, and Y.
Referenced by foldICmpBinOpWithConstant().
Instruction * InstCombinerImpl::foldICmpUsingBoolRange | ( | ICmpInst & | I | ) |
If one operand of an icmp is effectively a bool (value range of {0,1}), then try to reduce patterns based on that limit.
Definition at line 7083 of file InstCombineCompares.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::BinaryOperator::Create(), llvm::CmpInst::Create(), llvm::IRBuilderBase::CreateICmp(), llvm::IRBuilderBase::CreateIsNull(), llvm::ConstantInt::getBool(), llvm::Constant::getNullValue(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::ConstantInt::getSigned(), llvm::Value::hasOneUse(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::ICmpInst::isEquality(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_ICmp(), llvm::PatternMatch::m_CombineAnd(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Instruction(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), X, and Y.
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldICmpUsingKnownBits | ( | ICmpInst & | Cmp | ) |
Try to fold the comparison based on range information we can get by checking whether bits are known to be zero or one in the inputs.
Definition at line 6870 of file InstCombineCompares.cpp.
References A, B, llvm::BitWidth, llvm::APInt::ceilLogBase2(), llvm::ICmpInst::compare(), llvm::KnownBits::countMinTrailingZeros(), llvm::APInt::countr_zero(), llvm::InstCombiner::DL, llvm::SelectPatternResult::Flavor, llvm::APInt::getActiveBits(), llvm::APInt::getAllOnes(), llvm::ConstantInt::getBool(), llvm::KnownBits::getConstant(), getDemandedBitsLHSMask(), llvm::Constant::getIntegerValue(), llvm::CmpInst::getInversePredicate(), llvm::KnownBits::getMaxValue(), llvm::KnownBits::getMinValue(), llvm::Constant::getNullValue(), llvm::DataLayout::getPointerTypeSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::KnownBits::getSignedMaxValue(), llvm::KnownBits::getSignedMinValue(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::SimplifyQuery::getWithoutDomCondCache(), 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::KnownBits::isConstant(), llvm::Type::isIntOrIntVectorTy(), llvm::SelectPatternResult::isMinOrMax(), llvm::APInt::isNegative(), llvm::APInt::isPowerOf2(), llvm::KnownBits::isZero(), LHS, llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_MaxOrMin(), llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::matchSelectPattern(), llvm::KnownBits::One, llvm::InstCombiner::replaceInstUsesWith(), SimplifyDemandedBits(), llvm::InstCombiner::SQ, X, and llvm::KnownBits::Zero.
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldICmpWithCastOp | ( | ICmpInst & | ICmp | ) |
Handle icmp (cast x), (cast or constant).
Definition at line 6412 of file InstCombineCompares.cpp.
References llvm::ConstantFoldConstant(), llvm::InstCombiner::DL, foldICmpWithTrunc(), foldICmpWithZextOrSext(), llvm::ConstantExpr::getIntToPtr(), llvm::User::getOperand(), llvm::DataLayout::getPointerTypeSizeInBits(), llvm::CmpInst::getPredicate(), llvm::ConstantExpr::getPtrToInt(), and llvm::Value::getType().
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldICmpWithConstant | ( | ICmpInst & | Cmp | ) |
Fold icmp Pred X, C.
TODO: This code structure does not make sense. The saturating add fold should be moved to some other helper and extended as noted below (it is also possible that code has been made unnecessary - do we canonicalize IR to overflow/saturating intrinsics or not?).
Definition at line 1357 of file InstCombineCompares.cpp.
References A, llvm::PHINode::addIncoming(), llvm::all_of(), B, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::ConstantFoldCompareInstOperands(), llvm::IRBuilderBase::CreatePHI(), llvm::InstCombiner::DL, llvm::CmpInst::ICMP_UGT, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), processUGT_ADDCST_ADD(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::InstCombiner::replaceInstUsesWith(), llvm::IRBuilderBase::SetInsertPoint(), tryFoldInstWithCtpopWithNot(), and llvm::zip().
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldICmpWithDominatingICmp | ( | ICmpInst & | Cmp | ) |
Canonicalize icmp instructions based on dominating conditions.
Definition at line 1407 of file InstCombineCompares.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::DomConditionCache::conditionsFor(), llvm::InstCombiner::DC, llvm::ConstantRange::difference(), llvm::DominatorTree::dominates(), llvm::InstCombiner::DT, llvm::IRBuilderBase::getFalse(), llvm::IRBuilderBase::getInt(), llvm::CmpInst::getInversePredicate(), llvm::ConstantRange::getSingleElement(), llvm::IRBuilderBase::getTrue(), hasBranchUse(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::ConstantRange::intersectWith(), llvm::ConstantRange::isEmptySet(), llvm::isSignBitCheck(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_MaxOrMin(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::ConstantRange::makeExactICmpRegion(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), X, and Y.
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldICmpWithMinMax | ( | Instruction & | I, |
MinMaxIntrinsic * | MinMax, | ||
Value * | Z, | ||
CmpPredicate | Pred | ||
) |
Fold icmp Pred min|max(X, Y), Z.
Definition at line 5682 of file InstCombineCompares.cpp.
References llvm::CmpInst::Create(), llvm::CmpPredicate::dropSameSign(), llvm::ConstantInt::getBool(), llvm::ConstantInt::getFalse(), llvm::ICmpInst::getFlippedSignednessPredicate(), llvm::CmpInst::getInversePredicate(), llvm::CmpInst::getNonStrictPredicate(), llvm::CmpInst::getStrictPredicate(), llvm::ConstantInt::getTrue(), llvm::SimplifyQuery::getWithInstruction(), 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::isKnownNonNegative(), llvm::CmpInst::isSigned(), llvm::CmpInst::isUnsigned(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), llvm::simplifyICmpInst(), llvm::InstCombiner::SQ, std::swap(), X, and Y.
Referenced by foldICmpCommutative().
Instruction * InstCombinerImpl::foldICmpWithTrunc | ( | ICmpInst & | Cmp | ) |
Definition at line 6256 of file InstCombineCompares.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::IRBuilderBase::CreateAnd(), llvm::decomposeBitTestICmp(), foldICmpIntrinsicWithConstant(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), I, II, llvm::Log2_32(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and X.
Referenced by foldICmpWithCastOp().
Instruction * InstCombinerImpl::foldICmpWithZero | ( | ICmpInst & | Cmp | ) |
Definition at line 1238 of file InstCombineCompares.cpp.
References A, B, llvm::InstCombiner::computeKnownBits(), llvm::KnownBits::countMaxPopulation(), llvm::KnownBits::countMaxTrailingZeros(), llvm::KnownBits::countMinPopulation(), foldIRemByPowerOfTwoToBitTest(), llvm::Constant::getNullValue(), llvm::SimplifyQuery::getWithInstruction(), llvm::CmpInst::ICMP_SGT, llvm::ICmpInst::isEquality(), llvm::isKnownNonZero(), llvm::isKnownPositive(), llvm::APInt::isZero(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_SMin(), llvm::PatternMatch::m_URem(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::KnownBits::One, llvm::InstCombiner::SQ, llvm::stripNullTest(), X, and Y.
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldICmpWithZextOrSext | ( | ICmpInst & | ICmp | ) |
Definition at line 6299 of file InstCombineCompares.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::IRBuilderBase::CreateCast(), llvm::IRBuilderBase::CreateOr(), llvm::Constant::getAllOnesValue(), getLosslessTrunc(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::Type::getScalarSizeInBits(), llvm::ICmpInst::getUnsignedPredicate(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::ICmpInst::isEquality(), llvm::CmpInst::isSigned(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::PatternMatch::match(), X, and Y.
Referenced by foldICmpWithCastOp().
Instruction * InstCombinerImpl::foldICmpXorConstant | ( | ICmpInst & | Cmp, |
BinaryOperator * | Xor, | ||
const APInt & | C | ||
) |
Fold icmp (xor X, Y), C.
Definition at line 1629 of file InstCombineCompares.cpp.
References llvm::CallingConv::C, foldICmpXorShiftConst(), llvm::Constant::getAllOnesValue(), llvm::Constant::getNullValue(), I, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::APInt::isMaxSignedValue(), llvm::APInt::isNegative(), llvm::isSignBitCheck(), llvm::APInt::isSignMask(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceOperand(), X, llvm::Xor, and Y.
Referenced by foldICmpBinOpWithConstant().
Instruction * InstCombinerImpl::foldICmpXorShiftConst | ( | ICmpInst & | Cmp, |
BinaryOperator * | Xor, | ||
const APInt & | C | ||
) |
For power-of-2 C: ((X s>> ShiftC) ^ X) u< C --> (X + C) u< (C << 1) ((X s>> ShiftC) ^ X) u> (C - 1) --> (X + C) u> ((C << 1) - 1)
Definition at line 1701 of file InstCombineCompares.cpp.
References llvm::Add, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::IRBuilderBase::CreateAdd(), llvm::APInt::getLimitedValue(), llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::APInt::isMinSignedValue(), llvm::APInt::isPowerOf2(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_c_Xor(), llvm::PatternMatch::m_Deferred(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), X, and llvm::Xor.
Referenced by foldICmpXorConstant().
If an integer typed PHI has only one use which is an IntToPtr operation, replace the PHI with an existing pointer typed PHI if it exists.
Otherwise insert a new pointer typed PHI and replace the original one.
Definition at line 134 of file InstCombinePHI.cpp.
References llvm::PHINode::addIncoming(), llvm::all_of(), llvm::any_of(), assert(), llvm::PHINode::blocks(), llvm::PHINode::Create(), llvm::CastInst::CreateBitOrPointerCast(), llvm::InstCombiner::DL, llvm::DominatorTree::dominates(), llvm::InstCombiner::DT, llvm::SmallVectorImpl< T >::emplace_back(), llvm::BasicBlock::end(), eraseInstFromFunction(), llvm::BasicBlock::getFirstInsertionPt(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getParent(), llvm::DataLayout::getPointerSizeInBits(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), llvm::Value::hasOneUse(), if(), llvm::PHINode::incoming_values(), llvm::InstCombiner::InsertNewInstBefore(), llvm::Type::isIntegerTy(), MaxNumPhis, Ptr, llvm::InstCombiner::replaceInstUsesWith(), llvm::SmallVectorBase< Size_T >::size(), llvm::Instruction::user_back(), llvm::Value::users(), and llvm::zip().
Referenced by visitPHINode().
Instruction * InstCombinerImpl::foldIRemByPowerOfTwoToBitTest | ( | ICmpInst & | I | ) |
If we have: icmp eq/ne (urem/srem x, y), 0 iff y is a power-of-two, we can replace this with a bit test: icmp eq/ne (and x, (add y, -1)), 0.
Definition at line 1188 of file InstCombineCompares.cpp.
References llvm::InstCombiner::Builder, llvm::CmpInst::Create(), llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateAnd(), llvm::Constant::getAllOnesValue(), I, llvm::InstCombiner::isKnownToBeAPowerOfTwo(), llvm::PatternMatch::m_CombineAnd(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_IRem(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::Masked, llvm::PatternMatch::match(), X, and Y.
Referenced by foldICmpWithZero().
Instruction * InstCombinerImpl::foldIsMultipleOfAPowerOfTwo | ( | ICmpInst & | Cmp | ) |
Fold icmp eq (num + mask) & ~mask, num to icmp eq (and num, mask), 0 Where mask is a low bit mask.
Definition at line 1327 of file InstCombineCompares.cpp.
References llvm::InstCombiner::Builder, llvm::IRBuilderBase::CreateAnd(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::ICmpInst::isEquality(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_ICmp(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_LowBitMask(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().
Referenced by visitICmpInst().
Instruction * InstCombinerImpl::foldItoFPtoI | ( | CastInst & | FI | ) |
fpto{s/u}i({u/s}itofp(X)) --> X or zext(X) or sext(X) or trunc(X) This is safe if the intermediate type has enough bits in its mantissa to accurately represent all values of X.
For example, this won't work with i64 -> float -> i64.
Definition at line 1968 of file InstCombineCasts.cpp.
References assert(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), isKnownExactCastIntToFP(), llvm::InstCombiner::replaceInstUsesWith(), and X.
Referenced by visitFPToSI(), and visitFPToUI().
Fold (-1 u/ x) u< y ((x * y) ?/ x) != y to @llvm.
?mul.with.overflow(x, y) plus extraction of overflow bit Note that the comparison is commutative, while inverted (u>=, ==) predicate will mean that we are looking for the opposite answer.
Definition at line 4913 of file InstCombineCompares.cpp.
References llvm::InstCombiner::Builder, llvm::IRBuilderBase::CreateExtractValue(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateNot(), eraseInstFromFunction(), llvm::Instruction::getOpcode(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_ULT, llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_c_ICmp(), llvm::PatternMatch::m_c_Mul(), llvm::PatternMatch::m_CombineAnd(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_IDiv(), llvm::PatternMatch::m_Instruction(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_UDiv(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::Mul, llvm::InstCombiner::replaceInstUsesWith(), llvm::IRBuilderBase::SetInsertPoint(), X, and Y.
Referenced by foldICmpBinOp().
Instruction * InstCombinerImpl::foldOpIntoPhi | ( | Instruction & | I, |
PHINode * | PN, | ||
bool | AllowMultipleUses = false |
||
) |
Given a binary operator, cast instruction, or select which has a PHI node as operand #0, see if we can fold the instruction into the PHI (which is only possible if all operands to the PHI are constants).
Definition at line 1860 of file InstructionCombining.cpp.
References llvm::PHINode::addIncoming(), llvm::PHINode::Create(), llvm::InstCombiner::DL, llvm::DominatorTree::dominates(), llvm::Instruction::dropUBImplyingAttrsAndMetadata(), llvm::InstCombiner::DT, eraseInstFromFunction(), llvm::Instruction::getDebugLoc(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::PHINode::getNumIncomingValues(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), getParent(), llvm::BasicBlock::getTerminator(), llvm::Value::hasOneUse(), llvm::Value::hasOneUser(), llvm::Value::hasUseList(), I, llvm::CmpInst::ICMP_EQ, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::SetVector< T, Vector, Set, N >::insert(), llvm::InstCombiner::InsertNewInstBefore(), llvm::InstCombiner::isBackEdge(), llvm::DominatorTree::isReachableFromEntry(), llvm::BranchInst::isUnconditional(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::lookup(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificICmp(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::User::operands(), OpIndex, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::replaceAllDbgUsesWith(), llvm::InstCombiner::replaceInstUsesWith(), llvm::Instruction::setDebugLoc(), simplifyInstructionWithPHI(), llvm::InstCombiner::SQ, llvm::Value::takeName(), and llvm::Value::users().
Referenced by commonCastTransforms(), commonIRemTransforms(), foldBinOpIntoSelectOrPhi(), visitCallInst(), visitExtractValueInst(), visitFCmpInst(), visitFreeze(), visitICmpInst(), visitShuffleVectorInst(), and visitSub().
Instruction * InstCombinerImpl::FoldOpIntoSelect | ( | Instruction & | Op, |
SelectInst * | SI, | ||
bool | FoldWithMultiUse = false |
||
) |
Given an instruction with a select as one operand and a constant as the other operand, try to fold the binary operator into the select arguments.
This also works for Cast instructions, which obviously do not have a second operand.
Definition at line 1767 of file InstructionCombining.cpp.
References llvm::SelectInst::Create(), foldOperationIntoSelectOperand(), and simplifyOperationIntoSelectOperand().
Referenced by commonCastTransforms(), commonIDivRemTransforms(), commonIRemTransforms(), commonShiftTransforms(), foldBinOpIntoSelectOrPhi(), visitCallInst(), visitExtractElementInst(), visitExtractValueInst(), visitFCmpInst(), visitFDiv(), visitFSub(), visitShuffleVectorInst(), and visitSub().
Instruction * InstCombinerImpl::foldPHIArgBinOpIntoPHI | ( | PHINode & | PN | ) |
If we have something like phi [add (a,b), add(a,c)] and if a/b/c and the adds all have a single user, turn this into a phi and a single binop.
Definition at line 439 of file InstCombinePHI.cpp.
References llvm::PHINode::addIncoming(), llvm::Instruction::andIRFlags(), assert(), llvm::PHINode::blocks(), llvm::Instruction::copyIRFlags(), llvm::BinaryOperator::Create(), llvm::CmpInst::Create(), llvm::PHINode::Create(), llvm::drop_begin(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), llvm::BinaryOperator::getOpcode(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), I, llvm::PHINode::incoming_values(), llvm::InstCombiner::InsertNewInstBefore(), Opc, PHIArgMergedDebugLoc(), and llvm::zip().
Referenced by foldPHIArgOpIntoPHI().
Instruction * InstCombinerImpl::foldPHIArgExtractValueInstructionIntoPHI | ( | PHINode & | PN | ) |
If we have something like phi [extractvalue(a,0), extractvalue(b,0)], turn this into a phi[a,b] and a single extractvalue.
Definition at line 403 of file InstCombinePHI.cpp.
References llvm::PHINode::blocks(), llvm::PHINode::Create(), llvm::ExtractValueInst::Create(), llvm::drop_begin(), llvm::PHINode::getIncomingValue(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), I, llvm::PHINode::incoming_values(), llvm::InstCombiner::InsertNewInstBefore(), PHIArgMergedDebugLoc(), and llvm::zip().
Referenced by foldPHIArgOpIntoPHI().
Instruction * InstCombinerImpl::foldPHIArgGEPIntoPHI | ( | PHINode & | PN | ) |
Definition at line 534 of file InstCombinePHI.cpp.
References llvm::PHINode::addIncoming(), llvm::sampleprof::Base, llvm::PHINode::blocks(), llvm::GetElementPtrInst::Create(), llvm::PHINode::Create(), llvm::drop_begin(), GEP, llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Value::getName(), llvm::GetElementPtrInst::getNoWrapFlags(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::GetElementPtrInst::getSourceElementType(), llvm::Value::getType(), I, llvm::PHINode::incoming_values(), llvm::InstCombiner::InsertNewInstBefore(), llvm::User::op_begin(), llvm::User::op_end(), PHIArgMergedDebugLoc(), llvm::SmallVectorBase< Size_T >::size(), and llvm::zip().
Referenced by foldPHIArgOpIntoPHI().
Instruction * InstCombinerImpl::foldPHIArgInsertValueInstructionIntoPHI | ( | PHINode & | PN | ) |
If we have something like phi [insertvalue(a,b,0), insertvalue(c,d,0)], turn this into a phi[a,c] and phi[b,d] and a single insertvalue.
Definition at line 363 of file InstCombinePHI.cpp.
References llvm::PHINode::blocks(), llvm::PHINode::Create(), llvm::InsertValueInst::Create(), llvm::drop_begin(), llvm::PHINode::getIncomingValue(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), I, llvm::PHINode::incoming_values(), llvm::InstCombiner::InsertNewInstBefore(), OpIdx, PHIArgMergedDebugLoc(), and llvm::zip().
Referenced by foldPHIArgOpIntoPHI().
Instruction * InstCombinerImpl::foldPHIArgIntToPtrToPHI | ( | PHINode & | PN | ) |
Definition at line 339 of file InstCombinePHI.cpp.
References llvm::all_of(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), llvm::InstCombiner::replaceOperand(), and llvm::Value::users().
Referenced by visitPHINode().
Instruction * InstCombinerImpl::foldPHIArgLoadIntoPHI | ( | PHINode & | PN | ) |
Definition at line 697 of file InstCombinePHI.cpp.
References llvm::PHINode::addIncoming(), llvm::PHINode::blocks(), llvm::combineMetadataForCSE(), llvm::Instruction::copyMetadata(), llvm::PHINode::Create(), llvm::drop_begin(), llvm::LoadInst::getAlign(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), llvm::User::getOperand(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::LoadInst::getPointerAddressSpace(), llvm::Value::getType(), llvm::Value::hasOneUser(), llvm::PHINode::incoming_values(), llvm::InstCombiner::InsertNewInstBefore(), llvm::Instruction::isAtomic(), isSafeAndProfitableToSinkLoad(), llvm::Value::isSwiftError(), llvm::LoadInst::isVolatile(), PHIArgMergedDebugLoc(), llvm::User::setOperand(), and llvm::zip().
Referenced by foldPHIArgOpIntoPHI().
Instruction * InstCombinerImpl::foldPHIArgOpIntoPHI | ( | PHINode & | PN | ) |
Try to rotate an operation below a PHI node, using PHI nodes for its operands.
If all operands to a PHI node are the same "unary" operator and they all are only used by the PHI, PHI together their inputs, and do the operation once, to the result of the PHI.
Definition at line 886 of file InstCombinePHI.cpp.
References llvm::PHINode::addIncoming(), llvm::PHINode::blocks(), llvm::BinaryOperator::Create(), llvm::CastInst::Create(), llvm::CmpInst::Create(), llvm::PHINode::Create(), llvm::drop_begin(), foldPHIArgBinOpIntoPHI(), foldPHIArgExtractValueInstructionIntoPHI(), foldPHIArgGEPIntoPHI(), foldPHIArgInsertValueInstructionIntoPHI(), foldPHIArgLoadIntoPHI(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), llvm::CmpInst::getOpcode(), llvm::User::getOperand(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::CmpInst::getPredicate(), llvm::Value::getType(), I, llvm::PHINode::incoming_values(), llvm::InstCombiner::InsertNewInstBefore(), llvm::Type::isIntegerTy(), PHIArgMergedDebugLoc(), and llvm::zip().
Referenced by visitPHINode().
Instruction * InstCombinerImpl::foldPHIArgZextsIntoPHI | ( | PHINode & | Phi | ) |
TODO: This function could handle other cast types, but then it might require special-casing a cast from the 'i1' type.
See the comment in FoldPHIArgOpIntoPHI() about pessimizing illegal integer types.
Definition at line 805 of file InstCombinePHI.cpp.
References llvm::PHINode::addIncoming(), llvm::CallingConv::C, llvm::PHINode::Create(), llvm::CastInst::CreateZExtOrBitCast(), llvm::DebugLoc::getDropped(), getLosslessUnsignedTrunc(), I, llvm::InstCombiner::InsertNewInstBefore(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by visitPHINode().
Instruction * InstCombinerImpl::foldPowiReassoc | ( | BinaryOperator & | I | ) |
Definition at line 617 of file InstCombineMulDivRem.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::IRBuilderBase::CreateAdd(), llvm::BinaryOperator::CreateFDivFMF(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::Constant::getAllOnesValue(), llvm::Value::getType(), I, llvm::PatternMatch::m_AllowReassoc(), llvm::PatternMatch::m_c_FMul(), llvm::PatternMatch::m_Deferred(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), X, and Y.
Referenced by foldFMulReassoc(), and visitFDiv().
Definition at line 2102 of file InstCombineCasts.cpp.
References llvm::InstCombiner::Builder, llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateZExtOrTrunc(), llvm::InstCombiner::DL, llvm::SmallVectorBase< Size_T >::empty(), GEP, llvm::DataLayout::getIndexType(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::PatternMatch::m_IntToPtr(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::Offset, Ptr, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::reverse().
Referenced by visitPtrToInt().
Value * InstCombinerImpl::foldReversedIntrinsicOperands | ( | IntrinsicInst * | II | ) |
If all arguments of the intrinsic are reverses, try to pull the reverse after the intrinsic.
Definition at line 1459 of file InstCombineCalls.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateVectorReverse(), II, llvm::isSplatValue(), llvm::isTriviallyVectorizable(), llvm::isVectorIntrinsicWithScalarOpAtArg(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_VecReverse(), llvm::PatternMatch::match(), llvm::none_of(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and X.
Referenced by visitCallInst().
Instruction * llvm::InstCombinerImpl::foldSelectEqualityTest | ( | SelectInst & | SI | ) |
Instruction * llvm::InstCombinerImpl::foldSelectExtConst | ( | SelectInst & | Sel | ) |
Instruction * InstCombinerImpl::foldSelectICmp | ( | CmpPredicate | Pred, |
SelectInst * | SI, | ||
Value * | RHS, | ||
const ICmpInst & | I | ||
) |
Definition at line 4366 of file InstCombineCompares.cpp.
References llvm::InstCombiner::Builder, llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateICmp(), llvm::InstCombiner::DL, I, Idx, llvm::isImpliedCondition(), llvm::ConstantInt::isZero(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), replacedSelectWithOperand(), RHS, llvm::simplifyICmpInst(), and llvm::InstCombiner::SQ.
Referenced by foldICmpCommutative().
Instruction * llvm::InstCombinerImpl::foldSelectInstWithICmp | ( | SelectInst & | SI, |
ICmpInst * | ICI | ||
) |
Instruction * InstCombinerImpl::foldSelectIntoOp | ( | SelectInst & | SI, |
Value * | TrueVal, | ||
Value * | FalseVal | ||
) |
Try to fold the select into one of the operands to allow further optimization.
Definition at line 495 of file InstCombineSelect.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, computeKnownFPClass(), llvm::Instruction::copyIRFlags(), llvm::BinaryOperator::Create(), llvm::IRBuilderBase::CreateSelect(), llvm::fcNan, llvm::ConstantExpr::getBinOpIdentity(), getSelectFoldableOperands(), llvm::Instruction::hasNoInfs(), llvm::Instruction::hasNoNaNs(), llvm::Instruction::hasNoSignedZeros(), llvm::isKnownNeverNaN(), isSelect01(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), llvm::FastMathFlags::noInfs(), llvm::FastMathFlags::noNaNs(), llvm::FastMathFlags::noSignedZeros(), llvm::Instruction::setHasNoInfs(), llvm::Instruction::setHasNoNaNs(), llvm::Instruction::setHasNoSignedZeros(), and llvm::Value::takeName().
Instruction * llvm::InstCombinerImpl::foldSelectOfBools | ( | SelectInst & | SI | ) |
Instruction * InstCombinerImpl::foldSelectOpOp | ( | SelectInst & | SI, |
Instruction * | TI, | ||
Instruction * | FI | ||
) |
We have (select c, TI, FI), and we know that TI and FI have the same opcode.
Definition at line 244 of file InstCombineSelect.cpp.
References llvm::Instruction::andIRFlags(), assert(), llvm::InstCombiner::Builder, Cond, llvm::Instruction::copyIRFlags(), llvm::BinaryOperator::Create(), llvm::CallInst::Create(), llvm::CastInst::Create(), llvm::GetElementPtrInst::Create(), llvm::IRBuilderBase::CreateFreeze(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateSelect(), llvm::FPMathOperator::getFastMathFlags(), llvm::Instruction::getFastMathFlags(), llvm::CmpPredicate::getMatching(), llvm::User::getNumOperands(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::ICmpInst::getSwappedCmpPredicate(), llvm::Value::getType(), llvm::HexagonInstrInfo::getType(), llvm::Value::hasOneUse(), llvm::Instruction::isCast(), llvm::Instruction::isCommutative(), llvm::ICmpInst::isEquality(), llvm::isGuaranteedNotToBePoison(), llvm::ICmpInst::isRelational(), llvm::Instruction::isSameOperationAs(), llvm::Type::isVectorTy(), llvm_unreachable, llvm::PatternMatch::m_FNeg(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_MaxOrMin(), llvm::PatternMatch::m_SMax(), llvm::PatternMatch::m_SMin(), llvm::PatternMatch::m_UMax(), llvm::PatternMatch::m_UMin(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), P, llvm::InstCombiner::replaceInstUsesWith(), llvm::Instruction::setFastMathFlags(), TII, X, and Y.
Instruction * InstCombinerImpl::foldSelectShuffle | ( | ShuffleVectorInst & | Shuf | ) |
Try to fold shuffles that are the equivalent of a vector select.
Definition at line 2332 of file InstCombineVectorOps.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::ShuffleVectorInst::commute(), llvm::IRBuilderBase::CreateBinOp(), llvm::IRBuilderBase::CreateShuffleVector(), llvm::InstCombiner::DL, foldSelectShuffleOfSelectShuffle(), foldSelectShuffleWith1Binop(), getAlternateBinop(), llvm::ShuffleVectorInst::getMaskValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::InstCombiner::getSafeVectorConstantForBinop(), llvm::ShuffleVectorInst::getShuffleMask(), llvm::ConstantExpr::getShuffleVector(), llvm::InstCombiner::getSimplifyQuery(), llvm::ShuffleVectorInst::getType(), llvm::Value::hasOneUse(), I, llvm::is_contained(), llvm::Instruction::isIntDivRem(), llvm::ShuffleVectorInst::isSelect(), llvm::Instruction::isShift(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_CombineOr(), llvm::PatternMatch::m_Constant(), llvm::MIPatternMatch::m_Neg(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::PoisonMaskElem, llvm::InstCombiner::replaceInstUsesWith(), X, and Y.
Referenced by visitShuffleVectorInst().
Instruction * llvm::InstCombinerImpl::foldSelectToCmp | ( | SelectInst & | SI | ) |
Instruction * llvm::InstCombinerImpl::foldSelectValueEquivalence | ( | SelectInst & | SI, |
CmpInst & | CI | ||
) |
Value * llvm::InstCombinerImpl::foldSelectWithConstOpToBinOp | ( | ICmpInst * | Cmp, |
Value * | TrueVal, | ||
Value * | FalseVal | ||
) |
Instruction * InstCombinerImpl::FoldShiftByConstant | ( | Value * | Op0, |
Constant * | Op1, | ||
BinaryOperator & | I | ||
) |
Definition at line 783 of file InstCombineShifts.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::CallingConv::C, canEvaluateShifted(), canShiftBinOpWithConstantRHS(), Cond, llvm::BinaryOperator::Create(), llvm::CastInst::Create(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateBinOp(), llvm::IRBuilderBase::CreateICmp(), llvm::dbgs(), llvm::InstCombiner::DL, foldBinOpIntoSelectOrPhi(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), getShiftedValue(), llvm::APInt::getZExtValue(), llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), I, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SLE, llvm::Instruction::isExact(), llvm::APInt::isMinSignedValue(), llvm::APInt::isNegative(), llvm::APInt::isZero(), LLVM_DEBUG, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_ImmConstant(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_SDiv(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_SpecificIntAllowPoison(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), llvm::Value::takeName(), llvm::APInt::uge(), and X.
Referenced by commonShiftTransforms().
Instruction * InstCombinerImpl::foldShuffledIntrinsicOperands | ( | IntrinsicInst * | II | ) |
If all arguments of the intrinsic are unary shuffles with the same mask, try to shuffle after the intrinsic.
Definition at line 1400 of file InstCombineCalls.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::IRBuilderBase::CreateIntrinsic(), llvm::find_if_not(), llvm::VectorType::get(), llvm::Use::getOperandNo(), II, llvm::isTriviallyVectorizable(), llvm::isVectorIntrinsicWithScalarOpAtArg(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_Poison(), llvm::PatternMatch::m_Shuffle(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::none_of(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), unshuffleConstant(), and X.
Referenced by visitCallInst().
Instruction * InstCombinerImpl::foldSignBitTest | ( | ICmpInst & | I | ) |
Fold equality-comparison between zero and any (maybe truncated) right-shift by one-less-than-bitwidth into a sign test on the original value.
Definition at line 1207 of file InstCombineCompares.cpp.
References llvm::CallingConv::C, llvm::CmpInst::Create(), llvm::Constant::getNullValue(), llvm::Type::getScalarSizeInBits(), llvm::SimplifyQuery::getWithInstruction(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SLT, llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_SpecificInt_ICMP(), llvm::PatternMatch::m_TruncOrSelf(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), reassociateShiftAmtsOfTwoSameDirectionShifts(), llvm::InstCombiner::SQ, and X.
Referenced by visitICmpInst().
Instruction * llvm::InstCombinerImpl::foldSPFofSPF | ( | Instruction * | Inner, |
SelectPatternFlavor | SPF1, | ||
Value * | A, | ||
Value * | B, | ||
Instruction & | Outer, | ||
SelectPatternFlavor | SPF2, | ||
Value * | C | ||
) |
Instruction * InstCombinerImpl::foldSquareSumFP | ( | BinaryOperator & | I | ) |
Definition at line 1069 of file InstCombineAddSub.cpp.
References A, assert(), B, llvm::InstCombiner::Builder, llvm::IRBuilderBase::CreateFAddFMF(), llvm::BinaryOperator::CreateFMulFMF(), I, and llvm::PatternMatch::m_SpecificFP().
Referenced by visitFAdd().
Instruction * InstCombinerImpl::foldSquareSumInt | ( | BinaryOperator & | I | ) |
Definition at line 1058 of file InstCombineAddSub.cpp.
References A, B, llvm::InstCombiner::Builder, llvm::IRBuilderBase::CreateAdd(), I, and llvm::PatternMatch::m_SpecificInt().
Referenced by visitAdd().
Value * InstCombinerImpl::foldUsingDistributiveLaws | ( | BinaryOperator & | I | ) |
Tries to simplify binary operations which some other binary operation distributes over.
This tries to simplify binary operations which some other binary operation distributes over either by factorizing out common terms (eg "(A*B)+(A*C)" -> "A*(B+C)") or expanding out if this results in simplifications (eg: "A & (B | C) -> (A&B) | (A&C)" if this is a win).
It does this by either by factorizing out common terms (eg "(A*B)+(A*C)" -> "A*(B+C)") or expanding out if this results in simplifications (eg: "A & (B | C) -> (A&B) | (A&C)" if this is a win). Returns the simplified value, or null if it didn't simplify.
Returns the simplified value, or null if it didn't simplify.
Definition at line 1199 of file InstructionCombining.cpp.
References A, B, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::IRBuilderBase::CreateBinOp(), llvm::ConstantExpr::getBinOpIdentity(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::SimplifyQuery::getWithInstruction(), llvm::SimplifyQuery::getWithoutUndef(), I, leftDistributesOverRight(), LHS, RHS, rightDistributesOverLeft(), llvm::simplifyBinOp(), SimplifySelectsFeedingBinaryOp(), llvm::InstCombiner::SQ, and tryFactorizationFolds().
Referenced by visitAdd(), visitAnd(), visitMul(), visitOr(), visitSub(), and visitXor().
Instruction * InstCombinerImpl::foldVariableSignZeroExtensionOfVariableHighBitExtract | ( | BinaryOperator & | OldAShr | ) |
Definition at line 1642 of file InstCombineShifts.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::Instruction::copyIRFlags(), llvm::BinaryOperator::Create(), llvm::CastInst::CreateTruncOrBitCast(), llvm::BinaryOperator::getOpcode(), llvm::Instruction::getOpcode(), llvm::Value::getType(), llvm::CmpInst::ICMP_EQ, llvm::IRBuilderBase::Insert(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_Instruction(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt_ICMP(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_TruncOrSelf(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExtOrSelf(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), and X.
Referenced by visitAShr().
Instruction * InstCombinerImpl::foldVectorBinop | ( | BinaryOperator & | Inst | ) |
Canonicalize the position of binops relative to shufflevector.
Definition at line 2322 of file InstructionCombining.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::Instruction::copyIRFlags(), llvm::BinaryOperator::Create(), llvm::CallInst::Create(), llvm::IRBuilderBase::CreateBinOp(), llvm::IRBuilderBase::CreateShuffleVector(), llvm::IRBuilderBase::CreateVectorSplat(), F, llvm::Instruction::getModule(), llvm::Value::getName(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Intrinsic::getOrInsertDeclaration(), llvm::InstCombiner::getSafeVectorConstantForBinop(), llvm::Type::getScalarType(), llvm::IRBuilderBase::getTrue(), llvm::Value::getType(), llvm::Value::hasNUses(), llvm::Value::hasOneUse(), llvm::is_contained(), llvm::Instruction::isAssociative(), llvm::Instruction::isCommutative(), llvm::Instruction::isIntDivRem(), llvm::isSafeToSpeculativelyExecuteWithVariableReplaced(), llvm::isSplatValue(), LHS, llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_ImmConstant(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Poison(), llvm::PatternMatch::m_Shuffle(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_VecReverse(), llvm::PatternMatch::match(), llvm::PoisonMaskElem, RHS, llvm::ArrayRef< T >::size(), std::swap(), unshuffleConstant(), X, and Y.
Referenced by visitAdd(), visitAnd(), visitAShr(), visitFAdd(), visitFDiv(), visitFMul(), visitFRem(), visitFSub(), visitLShr(), visitMul(), visitOr(), visitSDiv(), visitShl(), visitSRem(), visitSub(), visitUDiv(), visitURem(), and visitXor().
Instruction * llvm::InstCombinerImpl::foldVectorSelect | ( | SelectInst & | Sel | ) |
Freely adapt every user of V as-if V was changed to !V.
WARNING: only if canFreelyInvertAllUsersOf() said this can be done.
Definition at line 1435 of file InstructionCombining.cpp.
References llvm::InstCombiner::addToWorklist(), llvm::DIExpression::appendOpsToArg(), assert(), llvm::InstCombiner::BPI, End, llvm::findDbgValues(), getOpcode(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), I, Idx, llvm_unreachable, llvm::make_early_inc_range(), llvm::InstCombiner::replaceInstUsesWith(), llvm::BranchProbabilityInfo::swapSuccEdgesProbabilities(), and llvm::BranchInst::swapSuccessors().
Referenced by canonicalizeICmpPredicate(), freelyInvert(), sinkNotIntoLogicalOp(), and sinkNotIntoOtherHandOfLogicalOp().
bool InstCombinerImpl::freezeOtherUses | ( | FreezeInst & | FI | ) |
Definition at line 5096 of file InstructionCombining.cpp.
References llvm::DominatorTree::dominates(), llvm::InstCombiner::DT, llvm::Function::getEntryBlock(), llvm::BasicBlock::getFirstNonPHIOrDbgOrAlloca(), llvm::Instruction::getFunction(), llvm::User::getOperand(), and llvm::Instruction::moveBefore().
Referenced by visitFreeze().
Definition at line 238 of file InstCombineInternal.h.
References C.
Referenced by foldLogicCastConstant(), and visitCallInst().
|
inline |
Definition at line 225 of file InstCombineInternal.h.
References C, llvm::ConstantFoldCastOperand(), and DL.
Referenced by foldICmpWithZextOrSext().
Definition at line 234 of file InstCombineInternal.h.
References C.
Referenced by foldLogicCastConstant(), foldPHIArgZextsIntoPHI(), narrowUDivURem(), and visitCallInst().
void InstCombinerImpl::handlePotentiallyDeadBlocks | ( | SmallVectorImpl< BasicBlock * > & | Worklist | ) |
Definition at line 4088 of file InstructionCombining.cpp.
References llvm::all_of(), llvm::InstCombiner::DeadEdges, llvm::DominatorTree::dominates(), llvm::InstCombiner::DT, llvm::BasicBlock::front(), handleUnreachableFrom(), llvm::predecessors(), and llvm::InstCombiner::Worklist.
Referenced by handlePotentiallyDeadSuccessors(), and visitStoreInst().
void InstCombinerImpl::handlePotentiallyDeadSuccessors | ( | BasicBlock * | BB, |
BasicBlock * | LiveSucc | ||
) |
Definition at line 4101 of file InstructionCombining.cpp.
References addDeadEdge(), handlePotentiallyDeadBlocks(), llvm::successors(), and llvm::InstCombiner::Worklist.
Referenced by visitBranchInst(), and visitSwitchInst().
void InstCombinerImpl::handleUnreachableFrom | ( | Instruction * | I, |
SmallVectorImpl< BasicBlock * > & | Worklist | ||
) |
Definition at line 4058 of file InstructionCombining.cpp.
References addDeadEdge(), llvm::InstCombiner::addToWorklist(), eraseInstFromFunction(), llvm::PoisonValue::get(), llvm::ilist_node_impl< OptionsT >::getReverseIterator(), llvm::BasicBlock::getTerminator(), llvm::handleUnreachableTerminator(), I, llvm::InstCombiner::MadeIRChange, llvm::make_early_inc_range(), llvm::make_range(), llvm::InstCombiner::replaceInstUsesWith(), llvm::successors(), and llvm::InstCombiner::Worklist.
Referenced by handlePotentiallyDeadBlocks(), and visitStoreInst().
Value * InstCombinerImpl::insertRangeTest | ( | Value * | V, |
const APInt & | Lo, | ||
const APInt & | Hi, | ||
bool | isSigned, | ||
bool | Inside | ||
) |
Emit a computation of: (V >= Lo && V < Hi) if Inside is true, otherwise (V < Lo || V >= Hi).
This method expects that Lo < Hi. IsSigned indicates whether to treat V, Lo, and Hi as signed or not.
Definition at line 56 of file InstCombineAndOrXor.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::IRBuilderBase::CreateICmp(), llvm::IRBuilderBase::CreateSub(), llvm::ICmpInst::getSignedPredicate(), llvm::Hi, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_ULT, isSigned(), and llvm::Lo.
Referenced by foldICmpDivConstant().
Instruction * InstCombinerImpl::matchBSwapOrBitReverse | ( | Instruction & | I, |
bool | MatchBSwaps, | ||
bool | MatchBitReversals | ||
) |
Given an initial instruction, check to see if it is the root of a bswap/bitreverse idiom.
If so, return the equivalent bswap/bitreverse intrinsic.
Definition at line 2913 of file InstCombineAndOrXor.cpp.
References I, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::InstructionWorklist::push(), llvm::recognizeBSwapOrBitReverseIdiom(), llvm::Instruction::removeFromParent(), and llvm::InstCombiner::Worklist.
Referenced by visitCallInst(), and visitOr().
bool InstCombinerImpl::matchThreeWayIntCompare | ( | SelectInst * | SI, |
Value *& | LHS, | ||
Value *& | RHS, | ||
ConstantInt *& | Less, | ||
ConstantInt *& | Equal, | ||
ConstantInt *& | Greater | ||
) |
Match a select chain which produces one of three values based on whether the LHS is less than, equal to, or greater than RHS respectively.
Return true if we matched a three way compare idiom. The LHS, RHS, Less, Equal and Greater values are saved in the matching process and returned to the caller.
Definition at line 3341 of file InstCombineCompares.cpp.
References assert(), llvm::getFlippedStrictnessPredicateAndConstant(), llvm::CmpInst::getSwappedPredicate(), llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::ICmpInst::isEquality(), llvm::Less, LHS, llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), RHS, and std::swap().
Referenced by foldICmpSelectConstant().
Try to transform: if () { *P = v1; } else { *P = v2 } or: *P = v1; if () { *P = v2; } into a phi node with a store in the successor.
Definition at line 1537 of file InstCombineLoadStoreAlloca.cpp.
References llvm::PHINode::addIncoming(), llvm::BasicBlock::begin(), llvm::InstCombiner::Builder, llvm::PHINode::Create(), llvm::IRBuilderBase::CreateBitOrPointerCast(), llvm::InstCombiner::DL, eraseInstFromFunction(), llvm::Instruction::getAAMetadata(), llvm::Instruction::getDebugLoc(), llvm::BasicBlock::getFirstInsertionPt(), llvm::DebugLoc::getMergedLocation(), llvm::BranchInst::getSuccessor(), llvm::Instruction::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::StoreInst::getValueOperand(), llvm::BasicBlock::hasNPredecessors(), I, llvm::InstCombiner::InsertNewInstBefore(), llvm::CastInst::isBitOrNoopPointerCastable(), llvm::BranchInst::isUnconditional(), llvm::AAMDNodes::merge(), llvm::Instruction::mergeDIAssignID(), llvm::pred_begin(), llvm::Instruction::setAAMetadata(), llvm::Instruction::setDebugLoc(), and llvm::IRBuilderBase::SetInsertPoint().
Referenced by visitUnconditionalBranchInst().
Value * InstCombinerImpl::OptimizePointerDifference | ( | Value * | LHS, |
Value * | RHS, | ||
Type * | Ty, | ||
bool | IsNUW | ||
) |
Optimize pointer differences into the same array into a size.
Consider: &A[10] - &A[0]: we should compile this to "10". LHS/RHS are the pointer operands to the ptrtoint instructions for the LHS/RHS of the subtract.
Definition at line 2171 of file InstCombineAddSub.cpp.
References llvm::sampleprof::Base, llvm::InstCombiner::Builder, llvm::CommonPointerBase::compute(), llvm::IRBuilderBase::CreateIntCast(), llvm::IRBuilderBase::CreateSub(), llvm::InstCombiner::DL, llvm::DataLayout::getIndexType(), llvm::Value::getType(), I, LHS, llvm::PatternMatch::m_NonNegative(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), and RHS.
Referenced by visitSub().
void InstCombinerImpl::PHIArgMergedDebugLoc | ( | Instruction * | Inst, |
PHINode & | PN | ||
) |
Helper function for FoldPHIArgXIntoPHI() to set debug location for the folded operation.
The PHI arguments will be folded into a single operation with a PHI node as input.
The debug location of the single operation will be the merged locations of the original PHI node arguments.
Definition at line 43 of file InstCombinePHI.cpp.
References llvm::Instruction::applyMergedLocation(), assert(), llvm::drop_begin(), llvm::Instruction::getDebugLoc(), llvm::PHINode::getIncomingValue(), I, llvm::PHINode::incoming_values(), and llvm::Instruction::setDebugLoc().
Referenced by foldPHIArgBinOpIntoPHI(), foldPHIArgExtractValueInstructionIntoPHI(), foldPHIArgGEPIntoPHI(), foldPHIArgInsertValueInstructionIntoPHI(), foldPHIArgLoadIntoPHI(), and foldPHIArgOpIntoPHI().
Perform early cleanup and prepare the InstCombine worklist.
Populate the IC worklist from a function, by walking it in reverse post-order and adding all reachable code to the worklist.
This has a couple of tricks to make the code faster and more powerful. In particular, we constant fold and DCE instructions as we go, to avoid adding them to the worklist (this significantly speeds up instcombine on code where many instructions are dead or constant). Additionally, if we find a branch whose condition is a known constant, we only visit the reachable successors.
Definition at line 5741 of file InstructionCombining.cpp.
References llvm::all_of(), AliasScopeTracker::analyse(), llvm::CallingConv::C, Cond, llvm::ConstantFoldConstant(), llvm::ConstantFoldInstruction(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dbgs(), llvm::InstCombiner::DeadEdges, llvm::InstCombiner::DL, llvm::DominatorTree::dominates(), llvm::InstCombiner::DT, F, llvm::PoisonValue::get(), llvm::BasicBlock::getTerminator(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::BranchInst::isConditional(), llvm::BasicBlock::isEntryBlock(), llvm::isInstructionTriviallyDead(), AliasScopeTracker::isNoAliasScopeDeclDead(), LLVM_DEBUG, llvm::InstCombiner::MadeIRChange, llvm::make_early_inc_range(), llvm::predecessors(), llvm::InstructionWorklist::push(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::removeAllNonTerminatorAndEHPadInstructions(), llvm::InstructionWorklist::reserve(), llvm::reverse(), llvm::InstCombiner::RPOT, llvm::salvageDebugInfo(), llvm::SmallVectorBase< Size_T >::size(), llvm::successors(), llvm::InstCombiner::TLI, and llvm::InstCombiner::Worklist.
Referenced by combineInstructionsOverFunction().
Value * InstCombinerImpl::pushFreezeToPreventPoisonFromPropagating | ( | FreezeInst & | FI | ) |
Definition at line 4962 of file InstructionCombining.cpp.
References llvm::InstCombiner::Builder, llvm::canCreateUndefOrPoison(), llvm::IRBuilderBase::CreateFreeze(), llvm::User::getOperandUse(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isGuaranteedNotToBeUndefOrPoison(), llvm::reverse(), llvm::IRBuilderBase::SetInsertPoint(), and llvm::InstCombiner::Worklist.
Referenced by visitFreeze().
Value * InstCombinerImpl::reassociateShiftAmtsOfTwoSameDirectionShifts | ( | BinaryOperator * | Sh0, |
const SimplifyQuery & | SQ, | ||
bool | AnalyzeForSignBitExtraction = false |
||
) |
Definition at line 58 of file InstCombineShifts.cpp.
References assert(), llvm::InstCombiner::Builder, canTryToConstantAddTwoShiftAmounts(), llvm::ConstantFoldCastOperand(), llvm::BinaryOperator::Create(), llvm::CastInst::Create(), llvm::SimplifyQuery::DL, llvm::BinaryOperator::getOpcode(), llvm::Instruction::getOpcode(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_ULT, llvm::IRBuilderBase::Insert(), llvm::Instruction::isExact(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_CombineAnd(), llvm::PatternMatch::m_CombineOr(), llvm::PatternMatch::m_Instruction(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Shift(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_SpecificInt_ICMP(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExtOrSelf(), llvm::PatternMatch::match(), llvm::Instruction::setHasNoSignedWrap(), llvm::Instruction::setHasNoUnsignedWrap(), llvm::Instruction::setIsExact(), llvm::simplifyAddInst(), llvm::InstCombiner::SQ, and X.
Referenced by commonShiftTransforms(), and foldSignBitTest().
bool InstCombinerImpl::removeInstructionsBeforeUnreachable | ( | Instruction & | I | ) |
Definition at line 3983 of file InstructionCombining.cpp.
References eraseInstFromFunction(), llvm::PoisonValue::get(), I, llvm::isGuaranteedToTransferExecutionToSuccessor(), and llvm::InstCombiner::replaceInstUsesWith().
Referenced by visitStoreInst(), and visitUnreachableInst().
bool InstCombinerImpl::replacedSelectWithOperand | ( | SelectInst * | SI, |
const ICmpInst * | Icmp, | ||
const unsigned | SIOpd | ||
) |
Try to replace select with select operand SIOpd in SI-ICmp sequence.
True when a select result is replaced by one of its operands in select-icmp sequence.
This will eventually result in the elimination of the select.
SI | Select instruction |
Icmp | Compare instruction |
SIOpd | Operand that replaces the select |
Notes:
Example:
entry: %4 = select i1 %3, C* %0, C* null %5 = icmp eq C* %4, null br i1 %5, label %9, label %7 ... ; <label>:7 ; preds = entry %8 = getelementptr inbounds C* %4, i64 0, i32 0 ...
can be transformed to
%5 = icmp eq C* %0, null %6 = select i1 %3, i1 %5, i1 true br i1 %6, label %9, label %7 ... ; <label>:7 ; preds = entry %8 = getelementptr inbounds C* %0, i64 0, i32 0 // replace by %0!
Similar when the first operand of the select is a constant or/and the compare is for not equal rather than equal.
NOTE: The function is only called when the select and compare constants are equal, the optimization can work only for EQ predicates. This is not a major restriction since a NE compare should be 'normalized' to an equal compare, which usually happens in the combiner and test case select-cmp-br.ll checks for it.
Definition at line 6842 of file InstCombineCompares.cpp.
References assert(), dominatesAllUses(), llvm::CmpInst::getPredicate(), llvm::BasicBlock::getSinglePredecessor(), llvm::CmpInst::ICMP_EQ, and isChainSelectCmpBranch().
Referenced by foldSelectICmp().
bool llvm::InstCombinerImpl::replaceInInstruction | ( | Value * | V, |
Value * | Old, | ||
Value * | New, | ||
unsigned | Depth = 0 |
||
) |
bool InstCombinerImpl::run | ( | ) |
Run the combiner over the entire worklist until it is empty.
Definition at line 5502 of file InstructionCombining.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::IRBuilderBase::CollectMetadataToCopy(), llvm::dbgs(), llvm::DominatorTree::dominates(), llvm::InstCombiner::DT, EnableCodeSinking, eraseInstFromFunction(), llvm::BasicBlock::getFirstInsertionPt(), llvm::BasicBlock::getFirstNonPHIIt(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getTerminator(), llvm::BasicBlock::getUniquePredecessor(), I, llvm::User::isDroppable(), llvm::InstructionWorklist::isEmpty(), llvm::isInstructionTriviallyDead(), llvm::DominatorTree::isReachableFromEntry(), LLVM_DEBUG, llvm::InstCombiner::MadeIRChange, MaxSinkNumUsers, llvm::InstructionWorklist::popDeferred(), llvm::InstructionWorklist::push(), llvm::InstructionWorklist::pushUsersToWorkList(), llvm::InstructionWorklist::removeOne(), llvm::IRBuilderBase::SetInsertPoint(), llvm::DebugCounter::shouldExecute(), llvm::succ_empty(), llvm::InstCombiner::TLI, tryToSinkInstruction(), llvm::InstVisitor< InstCombinerImpl, Instruction * >::visit(), llvm::InstCombiner::Worklist, and llvm::InstructionWorklist::zap().
Referenced by combineInstructionsOverFunction().
Value * InstCombinerImpl::SimplifyAddWithRemainder | ( | BinaryOperator & | I | ) |
Tries to simplify add operations using the definition of remainder.
The definition of remainder is X % C = X - (X / C ) * C. The add expression X % C0 + (( X / C0 ) % C1) * C0 can be simplified to X % (C0 * C1)
Definition at line 1156 of file InstCombineAddSub.cpp.
References llvm::InstCombiner::AC, llvm::InstCombiner::Builder, llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateMul(), llvm::IRBuilderBase::CreateSRem(), llvm::IRBuilderBase::CreateURem(), llvm::InstCombiner::DT, llvm::Value::hasOneUse(), I, llvm::isGuaranteedNotToBeUndef(), llvm::APInt::isOne(), llvm::APInt::isPowerOf2(), llvm::APInt::isZero(), LHS, llvm::PatternMatch::m_IRem(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), MatchDiv(), MatchMul(), MatchRem(), MulWillOverflow(), RHS, std::swap(), and X.
Referenced by visitAdd(), and visitOr().
Instruction * InstCombinerImpl::SimplifyAnyMemSet | ( | AnyMemSetInst * | MI | ) |
Definition at line 218 of file InstCombineCalls.cpp.
References llvm::InstCombiner::AA, llvm::InstCombiner::AC, assert(), llvm::InstCombiner::Builder, llvm::Instruction::copyMetadata(), llvm::IRBuilderBase::CreateStore(), llvm::InstCombiner::DL, llvm::InstCombiner::DT, llvm::at::getDVRAssignmentMarkers(), llvm::getKnownAlignment(), llvm::ConstantInt::getLimitedValue(), llvm::AAResults::getModRefInfoMask(), llvm::APInt::getSplat(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::is_contained(), llvm::Type::isIntegerTy(), llvm::isModSet(), llvm::isPowerOf2_32(), MI, llvm::StoreInst::setAlignment(), llvm::StoreInst::setOrdering(), and llvm::Unordered.
Referenced by visitCallInst().
Instruction * InstCombinerImpl::SimplifyAnyMemTransfer | ( | AnyMemTransferInst * | MI | ) |
Definition at line 116 of file InstCombineCalls.cpp.
References llvm::InstCombiner::AA, llvm::InstCombiner::AC, assert(), llvm::InstCombiner::Builder, llvm::Instruction::copyMetadata(), llvm::IRBuilderBase::CreateLoad(), llvm::IRBuilderBase::CreateStore(), llvm::InstCombiner::DL, llvm::InstCombiner::DT, llvm::IntegerType::get(), llvm::getKnownAlignment(), llvm::ConstantInt::getLimitedValue(), llvm::AAResults::getModRefInfoMask(), hasUndefSource(), llvm::isModSet(), MI, llvm::Instruction::setAAMetadata(), llvm::StoreInst::setAlignment(), llvm::Instruction::setMetadata(), llvm::StoreInst::setOrdering(), llvm::StoreInst::setVolatile(), Size, and llvm::Unordered.
Referenced by visitCallInst().
bool InstCombinerImpl::SimplifyAssociativeOrCommutative | ( | BinaryOperator & | I | ) |
Performs a few simplifications for operators which are associative or commutative.
This performs a few simplifications for operators that are associative or commutative:
Commutative operators:
Associative operators:
Associative and commutative operators:
Definition at line 495 of file InstructionCombining.cpp.
References A, B, llvm::CallingConv::C, ClearSubclassDataAfterReassociation(), llvm::ConstantFoldBinaryOpOperands(), llvm::BinaryOperator::Create(), llvm::BinaryOperator::CreateNUW(), llvm::InstCombiner::DL, llvm::InstCombiner::getComplexity(), llvm::Instruction::getFastMathFlags(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::SimplifyQuery::getWithInstruction(), hasNoSignedWrap(), hasNoUnsignedWrap(), I, llvm::InstCombiner::InsertNewInstWith(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_Constant(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), maintainNoSignedWrap(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceOperand(), llvm::Instruction::setFastMathFlags(), simplifyAssocCastAssoc(), llvm::simplifyBinOp(), llvm::InstCombiner::SQ, and llvm::Value::takeName().
Referenced by visitAdd(), visitAnd(), visitFAdd(), visitFMul(), visitMul(), visitOr(), and visitXor().
Instruction * InstCombinerImpl::simplifyBinOpSplats | ( | ShuffleVectorInst & | SVI | ) |
Definition at line 2850 of file InstCombineVectorOps.cpp.
References llvm::InstCombiner::Builder, llvm::IRBuilderBase::CreateBinOp(), llvm::User::getOperand(), llvm::ShuffleVectorInst::getShuffleMask(), llvm::Value::hasOneUse(), llvm::isSafeToSpeculativelyExecuteWithVariableReplaced(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_Poison(), llvm::PatternMatch::m_Shuffle(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), X, and Y.
Referenced by visitShuffleVectorInst().
|
overridevirtual |
This form of SimplifyDemandedBits simplifies the specified instruction operand if possible, updating it in place.
It returns true if it made any change and false otherwise.
Implements llvm::InstCombiner.
Definition at line 95 of file InstCombineSimplifyDemanded.cpp.
References llvm::computeKnownBits(), llvm::Depth, llvm::UndefValue::get(), llvm::Value::hasOneUse(), I, llvm::APInt::isZero(), llvm::MaxAnalysisRecursionDepth, llvm::InstCombiner::replaceUse(), llvm::KnownBits::resetAll(), llvm::salvageDebugInfo(), SimplifyDemandedUseBits(), and SimplifyMultipleUseDemandedBits().
Referenced by foldICmpUsingKnownBits(), SimplifyDemandedUseBits(), and visitCallInst().
|
inline |
Definition at line 516 of file InstCombiner.h.
|
virtual |
Implements llvm::InstCombiner.
bool InstCombinerImpl::SimplifyDemandedFPClass | ( | Instruction * | I, |
unsigned | Op, | ||
FPClassTest | DemandedMask, | ||
KnownFPClass & | Known, | ||
unsigned | Depth = 0 |
||
) |
Definition at line 2077 of file InstCombineSimplifyDemanded.cpp.
References llvm::Depth, I, llvm::InstCombiner::replaceUse(), llvm::salvageDebugInfo(), and SimplifyDemandedUseFPClass().
Referenced by SimplifyDemandedUseFPClass().
bool InstCombinerImpl::SimplifyDemandedInstructionBits | ( | Instruction & | Inst | ) |
Tries to simplify operands to an integer instruction based on its demanded bits.
Inst is an integer instruction that SimplifyDemandedBits knows about.
See if the instruction has any properties that allow us to simplify its operands.
Definition at line 87 of file InstCombineSimplifyDemanded.cpp.
References llvm::InstCombiner::DL, getBitWidth(), llvm::Value::getType(), and SimplifyDemandedInstructionBits().
Referenced by commonIDivTransforms(), commonIRemTransforms(), commonShiftTransforms(), SimplifyDemandedInstructionBits(), visitAnd(), visitCallInst(), visitOr(), visitTrunc(), and visitXor().
bool InstCombinerImpl::SimplifyDemandedInstructionBits | ( | Instruction & | Inst, |
KnownBits & | Known | ||
) |
Inst is an integer instruction that SimplifyDemandedBits knows about.
See if the instruction has any properties that allow us to simplify its operands.
Definition at line 74 of file InstCombineSimplifyDemanded.cpp.
References llvm::APInt::getAllOnes(), llvm::KnownBits::getBitWidth(), llvm::SimplifyQuery::getWithInstruction(), llvm::InstCombiner::replaceInstUsesWith(), SimplifyDemandedUseBits(), and llvm::InstCombiner::SQ.
Value * InstCombinerImpl::SimplifyDemandedUseBits | ( | Instruction * | I, |
const APInt & | DemandedMask, | ||
KnownBits & | Known, | ||
const SimplifyQuery & | Q, | ||
unsigned | Depth = 0 |
||
) |
Attempts to replace I with a simpler value based on the demanded bits.
This function attempts to replace V with a simpler value based on the demanded bits.
When this function is called, it is known that only the bits set in DemandedMask of the result of V are ever used downstream. Consequently, depending on the mask and V, it may be possible to replace V with a constant or one of its operands. In such cases, this function does the replacement and returns true. In all other cases, it returns false after analyzing the expression and setting KnownOne and known to be one in the expression. Known.Zero contains all the bits that are known to be zero in the expression. These are provided to potentially allow the caller (which might recursively be SimplifyDemandedBits itself) to simplify the expression. Known.One and Known.Zero always follow the invariant that: Known.One & Known.Zero == 0. That is, a bit can't be both 1 and 0. The bits in Known.One and Known.Zero are accurate even for bits not in DemandedMask. Note also that the bitwidth of V, DemandedMask, Known.Zero and Known.One must all be the same.
This returns null if it did not change anything and it permits no simplification. This returns V itself if it did some simplification of V's operands based on the information about what bits are demanded. This returns some other non-null value if it found out that V is equal to another value in the context where the specified bits are demanded, but not for all users.
Definition at line 164 of file InstCombineSimplifyDemanded.cpp.
References llvm::KnownBits::add(), llvm::adjustKnownBitsForSelectArm(), llvm::alignDown(), llvm::analyzeKnownBitsFromAndXorOr(), llvm::KnownBits::anyextOrTrunc(), llvm::KnownBits::ashr(), assert(), llvm::BitWidth, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::APInt::clearLowBits(), llvm::computeKnownBits(), llvm::InstCombiner::computeKnownBits(), llvm::InstCombiner::ComputeNumSignBits(), llvm::ConstantFoldBinaryOpOperands(), convertOrOfShiftsToFunnelShift(), llvm::APInt::countl_zero(), llvm::countr_one(), llvm::APInt::countr_zero(), llvm::CallInst::Create(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateGEP(), llvm::IRBuilderBase::CreateLShr(), llvm::IRBuilderBase::CreateNot(), llvm::IRBuilderBase::CreateOr(), llvm::IRBuilderBase::CreateSExt(), llvm::IRBuilderBase::CreateTrunc(), llvm::IRBuilderBase::CreateUnaryIntrinsic(), llvm::IRBuilderBase::CreateXor(), llvm::SimplifyQuery::CxtI, llvm::Depth, llvm::InstCombiner::DL, llvm::errs(), GEP, llvm::APInt::getActiveBits(), llvm::Constant::getAllOnesValue(), llvm::APInt::getBitWidth(), llvm::KnownBits::getBitWidth(), llvm::APInt::getHighBitsSet(), llvm::DataLayout::getIndexType(), llvm::Constant::getIntegerValue(), llvm::APInt::getLimitedValue(), llvm::APInt::getLowBitsSet(), llvm::Constant::getNullValue(), llvm::Intrinsic::getOrInsertDeclaration(), llvm::Type::getScalarSizeInBits(), llvm::APInt::getSignMask(), llvm::ConstantInt::getValue(), llvm::OverflowingBinaryOperator::hasNoSignedWrap(), llvm::OverflowingBinaryOperator::hasNoUnsignedWrap(), llvm::haveNoCommonBitsSet(), I, II, llvm::InstCombiner::InsertNewInstWith(), llvm::KnownBits::intersectWith(), llvm::APInt::isAllOnes(), llvm::Type::isIntOrIntVectorTy(), llvm::KnownBits::isNegative(), llvm::KnownBits::isNonNegative(), llvm::APInt::isOne(), llvm::APInt::isPowerOf2(), llvm::APInt::isSubsetOf(), LHS, llvm::Log2(), llvm::APInt::lshr(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_LowBitMask(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Mul(), llvm::MIPatternMatch::m_Not(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_PtrAdd(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::m_ZExt(), llvm::KnownBits::makeConstant(), llvm::KnownBits::makeNonNegative(), llvm::PatternMatch::match(), llvm::MaxAnalysisRecursionDepth, llvm::Mul, llvm::KnownBits::One, llvm::InstCombiner::replaceOperand(), RHS, llvm::APInt::setBit(), llvm::APInt::setHighBits(), llvm::IRBuilderBase::SetInsertPoint(), llvm::Instruction::setIsExact(), llvm::APInt::setLowBits(), llvm::APInt::setSignBit(), llvm::KnownBits::sext(), llvm::KnownBits::shl(), llvm::APInt::shl(), ShrinkDemandedConstant(), SimplifyDemandedBits(), simplifyShrShlDemandedBits(), llvm::KnownBits::srem(), llvm::KnownBits::sub(), llvm::Value::takeName(), llvm::InstCombiner::targetSimplifyDemandedUseBitsIntrinsic(), llvm::APInt::trunc(), llvm::KnownBits::udiv(), llvm::APInt::ult(), llvm::KnownBits::unionWith(), llvm::APInt::urem(), VerifyKnownBits, X, llvm::Xor, Y, llvm::KnownBits::Zero, llvm::KnownBits::zextOrTrunc(), and llvm::APInt::zextOrTrunc().
Referenced by SimplifyDemandedBits(), and SimplifyDemandedInstructionBits().
Value * InstCombinerImpl::SimplifyDemandedUseFPClass | ( | Value * | V, |
FPClassTest | DemandedMask, | ||
KnownFPClass & | Known, | ||
Instruction * | CxtI, | ||
unsigned | Depth = 0 |
||
) |
Attempts to replace V with a simpler value based on the demanded floating-point classes.
Definition at line 1969 of file InstCombineSimplifyDemanded.cpp.
References assert(), computeKnownFPClass(), llvm::KnownFPClass::copysign(), llvm::Depth, llvm::KnownFPClass::fabs(), llvm::fcAllFlags, llvm::fcNegative, llvm::fcNone, llvm::fcPositive, llvm::KnownFPClass::fneg(), llvm::fneg(), llvm::PoisonValue::get(), getFPClassConstant(), llvm::CallBase::getIntrinsicID(), llvm::ConstantFP::getZero(), I, llvm::inverse_fabs(), llvm::KnownFPClass::isKnownNever(), llvm::KnownFPClass::KnownFPClasses, llvm::MaxAnalysisRecursionDepth, SimplifyDemandedFPClass(), and llvm::unknown_sign().
Referenced by SimplifyDemandedFPClass(), and visitReturnInst().
|
overridevirtual |
The specified value produces a vector with any number of elements.
This method analyzes which elements of the operand are poison and returns that information in PoisonElts.
DemandedElts contains the set of elements that are actually used by the caller, and by default (AllowMultipleUsers equals false) the value is simplified only if it has a single caller. If AllowMultipleUsers is set to true, DemandedElts refers to the union of sets of elements that are used by all callers.
If the information about demanded elements can be used to simplify the operation, the operation is simplified, then the resultant value is returned. This returns null if no change was made.
Implements llvm::InstCombiner.
Definition at line 1395 of file InstCombineSimplifyDemanded.cpp.
References llvm::all_of(), assert(), llvm::CallingConv::C, llvm::APInt::clearAllBits(), llvm::APInt::clearBit(), llvm::InsertElementInst::Create(), llvm::Depth, llvm::DominatorTree::dominates(), llvm::InstCombiner::DT, GEP, llvm::gep_type_begin(), llvm::gep_type_end(), llvm::ConstantVector::get(), llvm::PoisonValue::get(), llvm::Constant::getAggregateElement(), llvm::APInt::getAllOnes(), llvm::SelectInst::getCondition(), llvm::Type::getInt64Ty(), llvm::Value::getName(), getNumElements(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Value::hasOneUse(), llvm::Value::hasUseList(), I, Idx, II, llvm::InstCombiner::InsertNewInstWith(), llvm::APInt::isAllOnes(), llvm::Instruction::isCommutative(), llvm::Instruction::isIntDivRem(), llvm::Constant::isNullValue(), llvm::Constant::isOneValue(), llvm::Instruction::isShift(), llvm::Type::isVectorTy(), llvm::APInt::isZero(), llvm_unreachable, llvm::APInt::lshr(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_ExtractElt(), llvm::PatternMatch::m_Poison(), llvm::PatternMatch::m_Shuffle(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), Poison, llvm::PoisonMaskElem, llvm::APInt::popcount(), llvm::InstructionWorklist::push(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::InstCombiner::replaceOperand(), llvm::APInt::setBit(), SimplifyDemandedVectorElts(), SimplifyDemandedVectorEltsDepthLimit, llvm::InstCombiner::targetSimplifyDemandedVectorEltsIntrinsic(), llvm::Value::users(), llvm::InstCombiner::Worklist, X, Y, and llvm::APInt::zextOrTrunc().
Referenced by SimplifyDemandedVectorElts(), visitCallInst(), visitExtractElementInst(), visitGetElementPtrInst(), visitInsertElementInst(), and visitShuffleVectorInst().
bool InstCombinerImpl::simplifyDivRemOfSelectWithZeroOp | ( | BinaryOperator & | I | ) |
Fold a divide or remainder with a select instruction divisor when one of the select operands is zero.
In that case, we can use the other select operand because div/rem by zero is undefined.
Definition at line 1093 of file InstCombineMulDivRem.cpp.
References llvm::ConstantInt::getFalse(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::Value::hasOneUse(), I, llvm::isGuaranteedToTransferExecutionToSuccessor(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::InstructionWorklist::push(), llvm::InstCombiner::replaceOperand(), llvm::InstCombiner::replaceUse(), and llvm::InstCombiner::Worklist.
Referenced by commonIDivRemTransforms().
Value * InstCombinerImpl::SimplifyMultipleUseDemandedBits | ( | Instruction * | I, |
const APInt & | DemandedMask, | ||
KnownBits & | Known, | ||
const SimplifyQuery & | Q, | ||
unsigned | Depth = 0 |
||
) |
Helper routine of SimplifyDemandedUseBits.
It computes KnownZero/KnownOne bits. It also tries to handle simplifications that can be done based on DemandedMask, but without modifying the Instruction.
It computes Known bits. It also tries to handle simplifications that can be done based on DemandedMask, but without modifying the Instruction.
Definition at line 1144 of file InstCombineSimplifyDemanded.cpp.
References llvm::KnownBits::add(), llvm::analyzeKnownBitsFromAndXorOr(), llvm::BitWidth, llvm::computeKnownBits(), llvm::computeKnownBitsFromContext(), llvm::APInt::countl_zero(), llvm::Depth, llvm::APInt::getBitWidth(), llvm::Constant::getIntegerValue(), llvm::APInt::getLowBitsSet(), llvm::APInt::getZExtValue(), I, llvm::APInt::isSubsetOf(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::KnownBits::One, llvm::KnownBits::sub(), llvm::APInt::ult(), X, and llvm::KnownBits::Zero.
Referenced by SimplifyDemandedBits().
Try to fold a signed range checked with lower bound 0 to an unsigned icmp.
Example: (icmp sge x, 0) & (icmp slt x, n) --> icmp ult x, n If Inverted
is true then the check is for the inverted range, e.g. (icmp slt x, 0) | (icmp sgt x, n) --> icmp ugt x, n
Definition at line 720 of file InstCombineAndOrXor.cpp.
References llvm::InstCombiner::Builder, llvm::InstCombiner::computeKnownBits(), llvm::IRBuilderBase::CreateICmp(), llvm::CmpInst::getInversePredicate(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::CmpInst::getSwappedPredicate(), llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::ConstantInt::isMinusOne(), llvm::KnownBits::isNonNegative(), llvm::ConstantInt::isZero(), llvm::PatternMatch::m_SExtOrSelf(), llvm::PatternMatch::m_Specific(), and llvm::PatternMatch::match().
Value * InstCombinerImpl::SimplifySelectsFeedingBinaryOp | ( | BinaryOperator & | I, |
Value * | LHS, | ||
Value * | RHS | ||
) |
Definition at line 1355 of file InstructionCombining.cpp.
References A, B, llvm::InstCombiner::Builder, llvm::CallingConv::C, Cond, llvm::IRBuilderBase::CreateBinOp(), llvm::IRBuilderBase::CreateSelect(), llvm::IRBuilderBase::CreateSub(), D, F, llvm::SimplifyQuery::getWithInstruction(), llvm::Value::hasOneUse(), I, LHS, llvm::MIPatternMatch::m_Neg(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), N, RHS, llvm::IRBuilderBase::setFastMathFlags(), llvm::simplifyBinOp(), llvm::InstCombiner::SQ, and llvm::Sub.
Referenced by foldUsingDistributiveLaws(), visitFAdd(), visitFMul(), and visitFSub().
Value * InstCombinerImpl::simplifyShrShlDemandedBits | ( | Instruction * | Shr, |
const APInt & | ShrOp1, | ||
Instruction * | Shl, | ||
const APInt & | ShlOp1, | ||
const APInt & | DemandedMask, | ||
KnownBits & | Known | ||
) |
Helper routine of SimplifyDemandedUseBits.
It tries to simplify demanded bit for "r1 = shr x, c1; r2 = shl r1, c2" instruction sequence.
It tries to simplify "E1 = (X lsr C1) << C2", where the C1 and C2 are constant, into "E2 = X << (C2 - C1)" or "E2 = X >> (C1 - C2)", depending on the sign of "C2-C1".
Suppose E1 and E2 are generally different in bits S={bm, bm+1, ..., bn}, without considering the specific value X is holding. This transformation is legal iff one of following conditions is hold: 1) All the bit in S are 0, in this case E1 == E2. 2) We don't care those bits in S, per the input DemandedMask. 3) Combination of 1) and 2). Some bits in S are 0, and we don't care the rest bits.
Currently we only test condition 2).
As with SimplifyDemandedUseBits, it returns NULL if the simplification was not successful.
Definition at line 1320 of file InstCombineSimplifyDemanded.cpp.
References llvm::APInt::ashr(), llvm::BitWidth, llvm::APInt::clearAllBits(), llvm::APInt::getAllOnes(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::APInt::getZExtValue(), llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), llvm::InstCombiner::InsertNewInstWith(), llvm::APInt::lshr(), llvm::KnownBits::One, llvm::APInt::setLowBits(), llvm::APInt::uge(), and llvm::KnownBits::Zero.
Referenced by SimplifyDemandedUseBits().
bool InstCombinerImpl::sinkNotIntoLogicalOp | ( | Instruction & | I | ) |
Definition at line 4873 of file InstCombineAndOrXor.cpp.
References llvm::InstCombiner::Builder, canFreelyInvert(), llvm::InstCombiner::canFreelyInvertAllUsersOf(), llvm::IRBuilderBase::CreateBinOp(), llvm::IRBuilderBase::CreateLogicalOp(), freelyInvert(), freelyInvertAllUsersOf(), I, llvm::PatternMatch::m_LogicalAnd(), llvm::PatternMatch::m_LogicalOp(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), and llvm::IRBuilderBase::SetInsertPoint().
bool InstCombinerImpl::sinkNotIntoOtherHandOfLogicalOp | ( | Instruction & | I | ) |
Definition at line 4925 of file InstCombineAndOrXor.cpp.
References llvm::InstCombiner::Builder, canFreelyInvert(), llvm::InstCombiner::canFreelyInvertAllUsersOf(), llvm::IRBuilderBase::CreateBinOp(), llvm::IRBuilderBase::CreateLogicalOp(), freelyInvert(), freelyInvertAllUsersOf(), I, llvm::PatternMatch::m_LogicalAnd(), llvm::PatternMatch::m_LogicalOp(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), and llvm::IRBuilderBase::SetInsertPoint().
Referenced by visitAnd(), and visitOr().
Instruction * InstCombinerImpl::SliceUpIllegalIntegerPHI | ( | PHINode & | FirstPhi | ) |
This is an integer PHI and we know that it has an illegal type: see if it is only used by trunc or trunc(lshr) operations.
If so, we split the PHI into the various pieces being extracted. This sort of thing is introduced when SROA promotes an aggregate to large integer values.
TODO: The user of the trunc may be an bitcast to float/double/vector or an inttoptr. We should produce new PHIs in the right type.
Definition at line 1101 of file InstCombinePHI.cpp.
References llvm::PHINode::addIncoming(), llvm::array_pod_sort(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::PHINode::blocks(), llvm::InstCombiner::Builder, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::PHINode::Create(), llvm::IRBuilderBase::CreateLShr(), llvm::IRBuilderBase::CreateTrunc(), llvm::dbgs(), llvm::drop_begin(), llvm::SmallVectorBase< Size_T >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::find(), llvm::PoisonValue::get(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::Value::hasOneUse(), I, II, llvm::PHINode::incoming_values(), llvm::SmallPtrSetImpl< PtrType >::insert(), LLVM_DEBUG, llvm::Offset, PHI, Poison, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::InstCombiner::replaceInstUsesWith(), llvm::IRBuilderBase::SetInsertPoint(), llvm::SmallVectorBase< Size_T >::size(), llvm::Instruction::user_back(), llvm::Value::users(), and llvm::zip().
Take the exact integer log2 of the value.
If DoFold is true, create the actual instructions, otherwise return a non-null dummy value. Return nullptr on failure. Note, if DoFold is true the caller must ensure that takeLog2 will succeed, otherwise it may create stray instructions.
Definition at line 1528 of file InstCombineMulDivRem.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateBinaryIntrinsic(), llvm::IRBuilderBase::CreateSelect(), llvm::IRBuilderBase::CreateSub(), llvm::IRBuilderBase::CreateTrunc(), llvm::IRBuilderBase::CreateZExt(), llvm::Depth, llvm::ConstantExpr::getExactLogBase2(), llvm_unreachable, llvm::PatternMatch::m_And(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::MaxAnalysisRecursionDepth, takeLog2(), X, and Y.
Referenced by takeLog2().
Value * InstCombinerImpl::tryFactorizationFolds | ( | BinaryOperator & | I | ) |
This tries to simplify binary operations by factorizing out common terms (e.
g. "(A*B)+(A*C)" -> "A*(B+C)").
Definition at line 1156 of file InstructionCombining.cpp.
References A, B, llvm::InstCombiner::Builder, llvm::CallingConv::C, D, getBinOpsForFactorization(), getIdentityValue(), I, LHS, RHS, llvm::InstCombiner::SQ, and tryFactorization().
Referenced by foldUsingDistributiveLaws().
Instruction * InstCombinerImpl::tryFoldInstWithCtpopWithNot | ( | Instruction * | I | ) |
Definition at line 846 of file InstructionCombining.cpp.
References assert(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::ConstantFoldCompareInstOperands(), llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateICmp(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateSub(), llvm::InstCombiner::DL, llvm::ConstantExpr::getAdd(), llvm::InstCombiner::getFreelyInverted(), llvm::Type::getScalarSizeInBits(), llvm::ConstantExpr::getSub(), I, llvm::CmpInst::ICMP_UGT, llvm::InstCombiner::isFreeToInvert(), isSigned(), llvm_unreachable, llvm::PatternMatch::m_DisjointOr(), llvm::PatternMatch::m_ImmConstant(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), Opc, and llvm::InstCombiner::replaceInstUsesWith().
Referenced by foldICmpWithConstant(), visitAdd(), visitOr(), and visitSub().
Definition at line 848 of file InstCombineInternal.h.
Referenced by foldCttzCtlz(), visitMul(), and visitUDiv().
bool InstCombinerImpl::tryToSinkInstruction | ( | Instruction * | I, |
BasicBlock * | DestBlock | ||
) |
Try to move the specified instruction from its current block into the beginning of DestBlock, which can only happen if it's safe to move the instruction past all of the instructions between it and the end of its block.
FIXME: We could remove droppable uses that are not dominated by the new position.
Definition at line 5287 of file InstructionCombining.cpp.
References llvm::InstructionWorklist::add(), llvm::SmallVectorBase< Size_T >::empty(), llvm::findDbgUsers(), llvm::BasicBlock::getFirstInsertionPt(), llvm::BasicBlock::getTerminator(), llvm::BasicBlock::getUniquePredecessor(), I, SoleWriteToDeadLocal(), llvm::InstCombiner::TLI, tryToSinkInstructionDbgVariableRecords(), and llvm::InstCombiner::Worklist.
Referenced by run().
void InstCombinerImpl::tryToSinkInstructionDbgVariableRecords | ( | Instruction * | I, |
BasicBlock::iterator | InsertPos, | ||
BasicBlock * | SrcBlock, | ||
BasicBlock * | DestBlock, | ||
SmallVectorImpl< DbgVariableRecord * > & | DPUsers | ||
) |
Definition at line 5374 of file InstructionCombining.cpp.
References A, assert(), B, llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::dbgs(), llvm::DbgVariableRecord::Declare, llvm::SmallVectorImpl< T >::emplace_back(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::empty(), llvm::SmallVectorBase< Size_T >::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::filterDbgVars(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), I, llvm::SmallSet< T, N, C >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), LLVM_DEBUG, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::reverse(), llvm::salvageDebugInfoForDbgValues(), llvm::SmallVectorBase< Size_T >::size(), and llvm::stable_sort().
Referenced by tryToSinkInstruction().
Constant * InstCombinerImpl::unshuffleConstant | ( | ArrayRef< int > | ShMask, |
Constant * | C, | ||
VectorType * | NewCTy | ||
) |
Find a constant NewC that has property: shuffle(NewC, ShMask) = C Returns nullptr if such a constant does not exist e.g.
ShMask=<0,0> C=<1,2>
A 1-to-1 mapping is not required. Example: ShMask = <1,1,2,2> and C = <5,5,6,6> --> NewC = <poison,5,6,poison>
Definition at line 2285 of file InstructionCombining.cpp.
References assert(), llvm::CallingConv::C, llvm::ConstantVector::get(), llvm::PoisonValue::get(), llvm::VectorType::getElementCount(), getNumElements(), llvm::ConstantVector::getSplat(), I, and llvm::Splat.
Referenced by foldShuffledIntrinsicOperands(), and foldVectorBinop().
Instruction * InstCombinerImpl::visitAdd | ( | BinaryOperator & | I | ) |
Definition at line 1521 of file InstCombineAddSub.cpp.
References A, llvm::Add, llvm::InstCombiner::AddOne(), llvm::AllOnes, assert(), B, llvm::BitWidth, llvm::InstCombiner::Builder, llvm::CallingConv::C, canonicalizeCondSignextOfHighBitExtractToSignextHighBitExtract(), canonicalizeLowbitMask(), checkForNegativeOperand(), combineAddSubWithShlAddSub(), llvm::InstCombiner::ComputeNumSignBits(), Cond, llvm::APInt::countl_zero(), llvm::APInt::countr_zero(), llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateBinaryIntrinsic(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateIsNotNull(), llvm::IRBuilderBase::CreateMul(), llvm::BinaryOperator::CreateNeg(), llvm::IRBuilderBase::CreateNUWAdd(), llvm::IRBuilderBase::CreateSelect(), llvm::IRBuilderBase::CreateShl(), llvm::IRBuilderBase::CreateSub(), llvm::IRBuilderBase::CreateXor(), llvm::IRBuilderBase::CreateZExt(), llvm::IRBuilderBase::CreateZExtOrTrunc(), factorizeMathWithShlOps(), foldAddLikeCommutative(), foldAddToAshr(), foldAddWithConstant(), foldBinOpOfSelectAndCastOfSelectCondition(), foldBinOpShiftWithShift(), foldBinopWithPhiOperands(), foldBoxMultiply(), foldNoWrapAdd(), foldSquareSumInt(), foldToUnsignedSaturatedAdd(), foldUsingDistributiveLaws(), foldVectorBinop(), llvm::ConstantExpr::getAdd(), llvm::Constant::getAllOnesValue(), llvm::IRBuilderBase::getFalse(), llvm::InstCombiner::getFreelyInverted(), llvm::Constant::getNullValue(), llvm::Type::getScalarSizeInBits(), llvm::ConstantInt::getSigned(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::Value::hasOneUse(), llvm::haveNoCommonBitsSet(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_UGT, llvm::InstCombiner::isFreeToInvert(), llvm::ICmpInst::isGT(), llvm::Type::isIntOrIntVectorTy(), llvm::ICmpInst::isLT(), llvm::APInt::isPowerOf2(), llvm::CmpInst::isSigned(), LHS, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_c_ICmp(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_LowBitMask(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Mul(), llvm::MIPatternMatch::m_Neg(), llvm::PatternMatch::m_NegatedPower2(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_NUWSub(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificICmp(), llvm::PatternMatch::m_SpecificIntAllowPoison(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_TruncOrSelf(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::MIPatternMatch::m_ZeroInt(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::m_ZExtOrSelf(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::PatternMatch::match(), llvm::matchSimpleRecurrence(), PHI, llvm::InstructionWorklist::pushUsersToWorkList(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), RHS, llvm::simplifyAddInst(), SimplifyAddWithRemainder(), SimplifyAssociativeOrCommutative(), llvm::InstCombiner::SQ, llvm::Sub, llvm::InstCombiner::SubOne(), std::swap(), tryFoldInstWithCtpopWithNot(), llvm::UMax, llvm::InstCombiner::Worklist, and X.
Instruction * InstCombinerImpl::visitAddrSpaceCast | ( | AddrSpaceCastInst & | CI | ) |
Definition at line 2928 of file InstCombineCasts.cpp.
References commonCastTransforms().
Instruction * InstCombinerImpl::visitAllocaInst | ( | AllocaInst & | AI | ) |
Definition at line 489 of file InstCombineLoadStoreAlloca.cpp.
References llvm::InstCombiner::AA, llvm::InstCombiner::AC, llvm::dbgs(), llvm::InstCombiner::DL, llvm::InstCombiner::DT, eraseInstFromFunction(), llvm::AllocaInst::getAddressSpace(), llvm::AllocaInst::getAlign(), llvm::AllocaInst::getAllocatedType(), llvm::AllocaInst::getArraySize(), llvm::BasicBlock::getFirstNonPHIOrDbg(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::getOrEnforceKnownAlignment(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::Type::getPointerAddressSpace(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), I, llvm::AllocaInst::isArrayAllocation(), isDereferenceableForAllocaSize(), isOnlyCopiedFromConstantMemory(), llvm::Type::isSized(), LLVM_DEBUG, llvm::Instruction::moveBefore(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), llvm::AllocaInst::setAlignment(), simplifyAllocaArraySize(), and visitAllocSite().
Instruction * InstCombinerImpl::visitAllocSite | ( | Instruction & | FI | ) |
Definition at line 3658 of file InstructionCombining.cpp.
References llvm::InstCombiner::AA, llvm::InstructionWorklist::add(), assert(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::ConvertDebugDeclareToDebugValue(), llvm::InvokeInst::Create(), llvm::IRBuilderBase::CreateMemSet(), llvm::InstCombiner::DL, eraseInstFromFunction(), F, llvm::findDbgUsers(), llvm::UndefValue::get(), llvm::PoisonValue::get(), llvm::getInitialValueOfAllocation(), llvm::Type::getInt1Ty(), llvm::Type::getInt8Ty(), llvm::Constant::getNullValue(), llvm::Intrinsic::getOrInsertDeclaration(), I, II, isAllocSiteRemovable(), llvm::isRefSet(), llvm::isRemovableAlloc(), llvm::lowerObjectSizeCall(), MI, llvm::InstCombiner::replaceInstUsesWith(), llvm::IRBuilderBase::SetInsertPoint(), llvm::InstCombiner::TLI, Users, and llvm::InstCombiner::Worklist.
Referenced by visitAllocaInst().
Instruction * InstCombinerImpl::visitAnd | ( | BinaryOperator & | I | ) |
Definition at line 2422 of file InstCombineAndOrXor.cpp.
References A, assert(), B, llvm::InstCombiner::Builder, llvm::CallingConv::C, canonicalizeLogicFirst(), llvm::InstCombiner::computeKnownBits(), llvm::ConstantFoldCompareInstOperands(), llvm::APInt::countr_zero(), llvm::BinaryOperator::Create(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateBinOp(), llvm::IRBuilderBase::CreateICmpEQ(), llvm::IRBuilderBase::CreateIsNeg(), llvm::IRBuilderBase::CreateIsNull(), llvm::IRBuilderBase::CreateNot(), llvm::IRBuilderBase::CreateSExt(), llvm::IRBuilderBase::CreateTrunc(), llvm::IRBuilderBase::CreateUnaryIntrinsic(), llvm::InstCombiner::DL, llvm::DominatorTree::dominates(), llvm::InstCombiner::DT, llvm::APInt::exactLogBase2(), foldAndToXor(), foldBinOpIntoSelectOrPhi(), foldBinOpShiftWithShift(), foldBinopWithPhiOperands(), foldBitwiseLogicWithIntrinsics(), foldComplexAndOrPatterns(), foldUsingDistributiveLaws(), foldVectorBinop(), llvm::ConstantExpr::getAdd(), llvm::Constant::getAllOnesValue(), llvm::ConstantExpr::getExactLogBase2(), llvm::Type::getFltSemantics(), llvm::InstCombiner::getFreelyInverted(), llvm::IRBuilderBase::GetInsertBlock(), llvm::APInt::getLowBitsSet(), llvm::KnownBits::getMaxValue(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::BasicBlock::getParent(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::ConstantExpr::getSub(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::APInt::getZExtValue(), llvm::Function::hasFnAttribute(), llvm::Value::hasOneUse(), llvm::APFloatBase::hasSignBitInMSB(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_ULT, llvm::Type::isFloatingPointTy(), llvm::InstCombiner::isKnownToBeAPowerOfTwo(), llvm::APInt::isPowerOf2(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_APIntAllowPoison(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_c_Xor(), llvm::PatternMatch::m_CombineOr(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_ElementWiseBitCast(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_LogicalAnd(), llvm::PatternMatch::m_LogicalShift(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_MaxSignedValue(), llvm::MIPatternMatch::m_Neg(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_SExtOrSelf(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_SignMask(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt_ICMP(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::m_ZExtOrSelf(), llvm::InstCombiner::MaskedValueIsZero(), llvm::PatternMatch::match(), matchDeMorgansLaws(), llvm::matchSimpleRecurrence(), reassociateFCmps(), reassociateForUses(), llvm::InstCombiner::replaceInstUsesWith(), llvm::simplifyAndInst(), simplifyAndOrWithOpReplaced(), SimplifyAssociativeOrCommutative(), SimplifyDemandedInstructionBits(), sinkNotIntoOtherHandOfLogicalOp(), llvm::InstCombiner::SQ, llvm::APInt::trunc(), llvm::APInt::ult(), X, llvm::Xor, Y, and llvm::APInt::zext().
Instruction * InstCombinerImpl::visitAShr | ( | BinaryOperator & | I | ) |
Definition at line 1710 of file InstCombineShifts.cpp.
References llvm::BitWidth, llvm::InstCombiner::Builder, commonShiftTransforms(), llvm::BinaryOperator::Create(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateAShr(), llvm::IRBuilderBase::CreateICmpSLT(), llvm::IRBuilderBase::CreateIsNotNull(), llvm::IRBuilderBase::CreateIsNull(), llvm::BinaryOperator::CreateNeg(), llvm::BinaryOperator::CreateNot(), foldVariableSignZeroExtensionOfVariableHighBitExtract(), foldVectorBinop(), llvm::Value::getName(), llvm::Type::getScalarSizeInBits(), llvm::APInt::getSignMask(), llvm::SimplifyQuery::getWithInstruction(), llvm::APInt::getZExtValue(), hasNoUnsignedWrap(), I, llvm::Type::isVectorTy(), llvm::APInt::logBase2(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_Deferred(), llvm::MIPatternMatch::m_Neg(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_NSWMul(), llvm::PatternMatch::m_NSWShl(), llvm::PatternMatch::m_NSWSub(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificIntAllowPoison(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::InstCombiner::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::Constant::mergeUndefsWith(), llvm::InstCombiner::replaceInstUsesWith(), llvm::Instruction::setIsExact(), setShiftFlags(), llvm::simplifyAShrInst(), llvm::InstCombiner::SQ, llvm::APInt::ult(), X, and Y.
Instruction * InstCombinerImpl::visitAtomicRMWInst | ( | AtomicRMWInst & | SI | ) |
Definition at line 103 of file InstCombineAtomicRMW.cpp.
References assert(), llvm::AtomicRMWInst::FAdd, llvm::ConstantFP::getNegativeZero(), llvm::AtomicRMWInst::getOperation(), llvm::AtomicRMWInst::getOrdering(), llvm::Value::getType(), llvm::Type::isFloatingPointTy(), llvm::Type::isIntegerTy(), llvm::AtomicRMWInst::isVolatile(), llvm::NotAtomic, llvm::AtomicRMWInst::Or, llvm::InstCombiner::replaceOperand(), llvm::AtomicRMWInst::setOperation(), llvm::Unordered, and llvm::AtomicRMWInst::Xchg.
Instruction * InstCombinerImpl::visitBitCast | ( | BitCastInst & | CI | ) |
Definition at line 2781 of file InstCombineCasts.cpp.
References assert(), llvm::BitWidth, llvm::InstCombiner::Builder, canonicalizeBitCastExtElt(), commonCastTransforms(), llvm::CallInst::Create(), llvm::CastInst::Create(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateBitCast(), llvm::IRBuilderBase::CreateExtractElement(), llvm::IRBuilderBase::CreateZExt(), llvm::InstCombiner::DL, foldBitCastBitwiseLogic(), foldBitCastSelect(), foldCopySignIdioms(), llvm::Value::getContext(), llvm::APInt::getHighBitsSet(), llvm::Type::getInt32Ty(), llvm::Instruction::getModule(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::Intrinsic::getOrInsertDeclaration(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), I, llvm::DataLayout::isBigEndian(), llvm::Type::isIntegerTy(), llvm::DataLayout::isLegalInteger(), llvm::Type::isVectorTy(), LHS, llvm::PatternMatch::m_BitCast(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_InsertElt(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), optimizeIntegerToVectorInsertions(), optimizeVectorResizeWithIntegerBitCasts(), llvm::InstCombiner::replaceInstUsesWith(), RHS, llvm::InstCombiner::SQ, X, and Y.
Instruction * InstCombinerImpl::visitBranchInst | ( | BranchInst & | BI | ) |
Definition at line 4115 of file InstructionCombining.cpp.
References llvm::InstCombiner::addToWorklist(), llvm::InstCombiner::BPI, llvm::InstCombiner::Builder, Cond, llvm::IRBuilderBase::CreateLogicalOr(), llvm::IRBuilderBase::CreateNot(), llvm::InstCombiner::DC, llvm::DominatorTree::dominates(), llvm::InstCombiner::DT, llvm::BranchInst::getCondition(), llvm::ConstantInt::getFalse(), llvm::CmpInst::getInversePredicate(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BranchInst::getSuccessor(), llvm::ConstantInt::getTrue(), handlePotentiallyDeadSuccessors(), llvm::InstCombiner::isCanonicalPredicate(), llvm::BranchInst::isUnconditional(), llvm::PatternMatch::m_FCmp(), llvm::PatternMatch::m_LogicalAnd(), llvm::MIPatternMatch::m_Not(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::make_early_inc_range(), llvm::PatternMatch::match(), llvm::InstructionWorklist::push(), llvm::DomConditionCache::registerBranch(), llvm::InstCombiner::replaceOperand(), llvm::InstCombiner::replaceUse(), llvm::BranchProbabilityInfo::swapSuccEdgesProbabilities(), llvm::BranchInst::swapSuccessors(), visitUnconditionalBranchInst(), llvm::InstCombiner::Worklist, X, and Y.
Instruction * InstCombinerImpl::visitCallBrInst | ( | CallBrInst & | CBI | ) |
Definition at line 4000 of file InstCombineCalls.cpp.
Instruction * InstCombinerImpl::visitCallInst | ( | CallInst & | CI | ) |
CallInst simplification.
This mostly only handles folding of intrinsic instructions. For normal calls, it allows visitCallBase to do the heavy lifting.
This will remove the boolean Condition from the assume given as argument and remove the assume if it becomes useless. always returns nullptr for use as a return values.
Note: this doesn't preserve the offset information but merges offset and alignment. TODO: we can generate a GEP instead of merging the alignment with the offset.
Canonicalize Knowledge in operand bundles.
Definition at line 1727 of file InstCombineCalls.cpp.
References A, llvm::InstCombiner::AA, llvm::InstCombiner::AC, llvm::InstructionWorklist::add(), llvm::CallBase::addRetAttr(), llvm::alignDown(), llvm::FastMathFlags::allowReassoc(), llvm::AlwaysOverflowsHigh, llvm::AlwaysOverflowsLow, llvm::CallBase::args(), llvm::RetainedKnowledge::ArgValue, assert(), llvm::RetainedKnowledge::AttrKind, B, llvm::BitWidth, llvm::buildAssumeFromKnowledge(), llvm::InstCombiner::Builder, llvm::CallingConv::C, canonicalizeConstantArg0ToArg1(), llvm::APFloat::clearSign(), llvm::computeConstantRangeIncludingKnownBits(), llvm::InstCombiner::computeKnownBits(), llvm::computeKnownFPSignBit(), computeOverflow(), Cond, llvm::ConstantFoldBinaryOpOperands(), llvm::ConstantFoldCompareInstOperands(), llvm::Instruction::copyIRFlags(), llvm::KnownBits::countMinLeadingZeros(), llvm::KnownBits::countMinTrailingZeros(), llvm::BinaryOperator::Create(), llvm::CallInst::Create(), llvm::CastInst::Create(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateAddReduce(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateAndReduce(), llvm::IRBuilderBase::CreateAssumption(), llvm::IRBuilderBase::CreateBinaryIntrinsic(), llvm::IRBuilderBase::CreateBitCast(), llvm::IRBuilderBase::CreateCall(), llvm::IRBuilderBase::CreateCast(), llvm::IRBuilderBase::CreateCopySign(), llvm::BinaryOperator::CreateFAddFMF(), llvm::BinaryOperator::CreateFDivFMF(), llvm::BinaryOperator::CreateFMulFMF(), llvm::IRBuilderBase::CreateFNeg(), llvm::UnaryOperator::CreateFNegFMF(), llvm::IRBuilderBase::CreateFNegFMF(), llvm::BinaryOperator::CreateFSubFMF(), llvm::IRBuilderBase::CreateICmpEQ(), llvm::IRBuilderBase::CreateICmpNE(), llvm::IRBuilderBase::CreateInsertValue(), llvm::IRBuilderBase::CreateIntCast(), llvm::CastInst::CreateIntegerCast(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateIsNotNull(), llvm::IRBuilderBase::CreateIsNull(), llvm::IRBuilderBase::CreateLdexp(), llvm::IRBuilderBase::CreateLShr(), llvm::IRBuilderBase::CreateMul(), llvm::BinaryOperator::CreateNeg(), llvm::IRBuilderBase::CreateNeg(), CreateNonTerminatorUnreachable(), llvm::BinaryOperator::CreateNot(), llvm::IRBuilderBase::CreateNot(), llvm::BinaryOperator::CreateNSW(), llvm::IRBuilderBase::CreateNSWMul(), llvm::BinaryOperator::CreateNSWNeg(), llvm::BinaryOperator::CreateNUW(), llvm::IRBuilderBase::CreateOrReduce(), llvm::IRBuilderBase::CreatePtrToInt(), llvm::IRBuilderBase::CreateSelect(), llvm::IRBuilderBase::CreateShuffleVector(), llvm::IRBuilderBase::CreateUnaryIntrinsic(), llvm::UnaryOperator::CreateWithCopiedFlags(), llvm::IRBuilderBase::CreateZExt(), llvm::IRBuilderBase::CreateZExtOrTrunc(), llvm::Data, llvm::InstCombiner::DL, llvm::Function::doesNotThrow(), llvm::CallBase::doesNotThrow(), llvm::Value::dropDroppableUse(), llvm::InstCombiner::DT, llvm::EnableKnowledgeRetention, eraseInstFromFunction(), factorizeMinMaxTree(), foldClampRangeOfTwo(), foldCtpop(), foldCttzCtlz(), foldIdempotentBinaryIntrinsicRecurrence(), foldIntrinsicUsingDistributiveLaws(), foldOpIntoPhi(), FoldOpIntoSelect(), foldReversedIntrinsicOperands(), foldShuffledIntrinsicOperands(), llvm::ConstantPtrAuth::get(), llvm::MDNode::get(), llvm::ConstantPointerNull::get(), llvm::ConstantAggregateZero::get(), llvm::APInt::getAllOnes(), llvm::Constant::getAllOnesValue(), llvm::CallBase::getArgOperand(), llvm::InstCombiner::getAssumptionCache(), llvm::KnownBits::getBitWidth(), llvm::ConstantInt::getBool(), llvm::CallBase::getCalledOperand(), llvm::Value::getContext(), llvm::InstCombiner::getDominatorTree(), llvm::VectorType::getElementCount(), llvm::IRBuilderBase::getFalse(), llvm::getFreedOperand(), llvm::InstCombiner::getFreelyInverted(), llvm::Instruction::getFunction(), llvm::IRBuilderBase::getInt1Ty(), llvm::Type::getInt64Ty(), llvm::Constant::getIntegerValue(), llvm::IRBuilderBase::getIntNTy(), llvm::CallBase::getIntrinsicID(), llvm::getInverseMinMaxIntrinsic(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::getKnowledgeFromBundle(), llvm::getKnownAlignment(), getKnownSign(), getKnownSignOrZero(), getLosslessSignedTrunc(), getLosslessUnsignedTrunc(), llvm::APInt::getLowBitsSet(), llvm::APSInt::getMaxValue(), llvm::APSInt::getMinValue(), llvm::Instruction::getModule(), llvm::ConstantExpr::getNeg(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::CmpInst::getNonStrictPredicate(), llvm::Constant::getNullValue(), llvm::Instruction::getOpcode(), getOpcode(), llvm::Intrinsic::getOrInsertDeclaration(), llvm::ConstantExpr::getPointerCast(), llvm::DataLayout::getPointerTypeSizeInBits(), llvm::MinMaxIntrinsic::getPredicate(), llvm::IRBuilderBase::getPtrTy(), llvm::CallBase::getRetAlign(), llvm::Type::getScalarSizeInBits(), llvm::APInt::getSignedMinValue(), llvm::APInt::getSignMask(), llvm::InstCombiner::getSimplifyQuery(), llvm::ConstantExpr::getSub(), llvm::CmpInst::getSwappedPredicate(), llvm::OperandBundleUse::getTagName(), llvm::IRBuilderBase::getTrue(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::getUnderlyingObject(), llvm::Attribute::getWithAlignment(), llvm::SimplifyQuery::getWithInstruction(), GuardWideningWindow, hasNoSignedWrap(), llvm::Value::hasOneUse(), llvm::CallBase::hasRetAttr(), I, llvm::ConstantRange::icmp(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_UGT, Idx, II, llvm::OperandBundleUse::Inputs, llvm::FMFSource::intersect(), llvm::KnownBits::isAllOnes(), llvm::isAssumeWithEmptyBundle(), llvm::InstCombiner::isFreeToInvert(), llvm::ConstantRange::isFullSet(), llvm::details::FixedOrScalableQuantity< ElementCount, unsigned >::isKnownGT(), llvm::details::FixedOrScalableQuantity< ElementCount, unsigned >::isKnownLT(), llvm::isKnownNegation(), llvm::isKnownNonZero(), llvm::InstCombiner::isKnownToBeAPowerOfTwo(), llvm::APFloat::isNegative(), llvm::APInt::isNonNegative(), llvm::KnownBits::isNonZero(), llvm::isNotCrossLaneOperation(), llvm::Type::isPointerTy(), llvm::isPowerOf2_32(), llvm::isPowerOf2_64(), llvm::isSafeToSpeculativelyExecute(), llvm::isSafeToSpeculativelyExecuteWithVariableReplaced(), llvm::MinMaxIntrinsic::isSigned(), llvm::isValidAssumeForContext(), LHS, llvm_unreachable, llvm::Log2(), llvm::Log2_32_Ceil(), llvm::lowerObjectSizeCall(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APFloat(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_APIntAllowPoison(), llvm::PatternMatch::m_BSwap(), llvm::PatternMatch::m_c_Mul(), llvm::PatternMatch::m_c_Select(), llvm::PatternMatch::m_c_Xor(), llvm::PatternMatch::m_CombineOr(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_CopySign(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_FAbs(), llvm::PatternMatch::m_FNeg(), llvm::PatternMatch::m_FPExt(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_LogicalAnd(), llvm::PatternMatch::m_LogicalOr(), llvm::PatternMatch::m_LogicalShift(), llvm::MIPatternMatch::m_Neg(), llvm::PatternMatch::m_NegatedPower2(), llvm::PatternMatch::m_NegZeroFP(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_NSWAddLike(), llvm::PatternMatch::m_NSWNeg(), llvm::PatternMatch::m_NSWSub(), llvm::PatternMatch::m_NUWAddLike(), llvm::PatternMatch::m_NUWMul(), llvm::PatternMatch::m_NUWShl(), llvm::PatternMatch::m_NUWSub(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_PosZeroFP(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_SMax(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificFP(), llvm::PatternMatch::m_SpecificICmp(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_SRem(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_UnOp(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::PatternMatch::m_Zero(), llvm::MIPatternMatch::m_ZeroInt(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::m_ZExtOrSExtOrSelf(), llvm::InstCombiner::MaskedValueIsZero(), llvm::PatternMatch::match(), matchBSwapOrBitReverse(), llvm::Value::MaxAlignmentExponent, llvm::maximum(), llvm::maxnum(), llvm::MayOverflow, MI, llvm::MinAlign(), llvm::minimum(), llvm::minnum(), llvm::Mod, moveAddAfterMinMax(), llvm::Instruction::moveBefore(), llvm::NeverOverflows, llvm::None, llvm::NullPointerIsDefined(), llvm::Offset, llvm::Other, llvm::PoisonMaskElem, Ptr, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::InstructionWorklist::pushValue(), reassociateMinMaxWithConstantInOperand(), reassociateMinMaxWithConstants(), llvm::AssumptionCache::registerAssumption(), removeTriviallyEmptyRange(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), llvm::InstCombiner::replaceUse(), RetTy, llvm::Reverse, RHS, llvm::APInt::sadd_ov(), Select, llvm::CallBase::setCalledFunction(), llvm::CallBase::setDoesNotThrow(), llvm::Value::setMetadata(), llvm::FastMathFlags::setNoSignedZeros(), llvm::APInt::sgt(), signBitMustBeTheSame(), SimplifyAnyMemSet(), SimplifyAnyMemTransfer(), llvm::simplifyCall(), llvm::simplifyConstrainedFPCall(), SimplifyDemandedBits(), SimplifyDemandedInstructionBits(), SimplifyDemandedVectorElts(), llvm::simplifyFMAFMul(), llvm::simplifyFMulInst(), simplifyInvariantGroupIntrinsic(), simplifyNeonTbl1(), simplifyReductionOperand(), llvm::simplifyRetainedKnowledge(), llvm::Splat, llvm::InstCombiner::SQ, std::swap(), llvm::InstCombiner::targetInstCombineIntrinsic(), llvm::InstCombiner::TLI, llvm::APInt::uadd_ov(), llvm::APInt::uadd_sat(), llvm::APInt::ugt(), llvm::AssumptionCache::updateAffectedValues(), llvm::Value::use_empty(), llvm::MaybeAlign::valueOrOne(), visitFree(), llvm::RetainedKnowledge::WasOn, llvm::InstCombiner::Worklist, X, and Y.
Instruction * InstCombinerImpl::visitExtractElementInst | ( | ExtractElementInst & | EI | ) |
Definition at line 398 of file InstCombineVectorOps.cpp.
References llvm::InstructionWorklist::addValue(), llvm::BitWidth, llvm::InstCombiner::Builder, cheapToScalarize(), llvm::count_if(), llvm::CastInst::Create(), llvm::GetElementPtrInst::Create(), llvm::ExtractElementInst::Create(), llvm::IRBuilderBase::CreateExtractElement(), llvm::BinaryOperator::CreateWithCopiedFlags(), llvm::CmpInst::CreateWithCopiedFlags(), llvm::UnaryOperator::CreateWithCopiedFlags(), findDemandedEltsByAllUsers(), FoldOpIntoSelect(), GEP, llvm::PoisonValue::get(), llvm::Value::getContext(), llvm::VectorType::getElementCount(), llvm::ExtractElementInst::getIndexOperand(), llvm::IRBuilderBase::getInt64(), llvm::Type::getInt64Ty(), llvm::Type::getIntegerBitWidth(), llvm::UnaryOperator::getOpcode(), llvm::BinaryOperator::getOpcode(), llvm::CmpInst::getOpcode(), llvm::User::getOperand(), getPreferredVectorIndex(), llvm::getSplatIndex(), llvm::Value::getType(), llvm::ExtractElementInst::getVectorOperand(), llvm::ExtractElementInst::getVectorOperandType(), llvm::SimplifyQuery::getWithInstruction(), llvm::Value::hasOneUse(), I, Idx, II, llvm::APInt::isAllOnes(), llvm::isSafeToSpeculativelyExecuteWithVariableReplaced(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_Cmp(), llvm::PatternMatch::m_UnOp(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), llvm::APInt::setBit(), llvm::GetElementPtrInst::setNoWrapFlags(), SimplifyDemandedVectorElts(), llvm::simplifyExtractElementInst(), llvm::InstCombiner::SQ, llvm::InstCombiner::Worklist, X, and Y.
Instruction * InstCombinerImpl::visitExtractValueInst | ( | ExtractValueInst & | EV | ) |
Definition at line 4486 of file InstructionCombining.cpp.
References llvm::InstCombiner::Builder, Cond, llvm::ExtractValueInst::Create(), llvm::InsertValueInst::Create(), llvm::IRBuilderBase::CreateExtractValue(), llvm::IRBuilderBase::CreateInBoundsGEP(), llvm::IRBuilderBase::CreateLoad(), foldFrexpOfSelect(), foldOpIntoPhi(), FoldOpIntoSelect(), GEP, llvm::ExtractValueInst::getAggregateOperand(), llvm::ExtractValueInst::getIndices(), llvm::IRBuilderBase::getInt32(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::ExtractValueInst::hasIndices(), Idx, llvm::ExtractValueInst::idx_begin(), llvm::ExtractValueInst::idx_end(), llvm::ExtractValueInst::indices(), IV, llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::InstCombiner::replaceInstUsesWith(), llvm::Instruction::setAAMetadata(), llvm::IRBuilderBase::SetInsertPoint(), llvm::simplifyExtractValueInst(), and llvm::InstCombiner::SQ.
Instruction * InstCombinerImpl::visitFAdd | ( | BinaryOperator & | I | ) |
Definition at line 1987 of file InstCombineAddSub.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::ConstantFoldBinaryOpOperands(), llvm::BinaryOperator::CreateFAddFMF(), llvm::IRBuilderBase::CreateFDivFMF(), llvm::IRBuilderBase::CreateFMulFMF(), llvm::BinaryOperator::CreateFMulFMF(), llvm::BinaryOperator::CreateFSubFMF(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::InstCombiner::DL, F, factorizeFAddFSub(), foldBinOpIntoSelectOrPhi(), foldBinopWithPhiOperands(), foldSquareSumFP(), foldVectorBinop(), llvm::SimplifyQuery::getWithInstruction(), I, LHS, llvm::PatternMatch::m_AnyZeroFP(), llvm::PatternMatch::m_APFloat(), llvm::PatternMatch::m_c_FAdd(), llvm::PatternMatch::m_c_FMul(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_FDiv(), llvm::PatternMatch::m_FMul(), llvm::PatternMatch::m_FNeg(), llvm::PatternMatch::m_FSub(), llvm::PatternMatch::m_ImmConstant(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), RHS, simplify, SimplifyAssociativeOrCommutative(), llvm::simplifyFAddInst(), SimplifySelectsFeedingBinaryOp(), llvm::InstCombiner::SQ, X, and Y.
Instruction * InstCombinerImpl::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 8651 of file InstCombineCompares.cpp.
References A, assert(), B, llvm::CmpInst::BAD_ICMP_PREDICATE, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::APFloat::clearSign(), llvm::ConstantFoldUnaryOpOperand(), llvm::APFloat::convert(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateBitCast(), llvm::InstCombiner::DL, llvm::CmpInst::FCMP_FALSE, 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_TRUE, 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::SelectPatternResult::Flavor, foldCmpLoadFromIndexedGlobal(), foldFabsWithFcmpZero(), foldFCmpFNegCommonOp(), foldFCmpFpTrunc(), foldFCmpFSubIntoFCmp(), foldFCmpIntToFPConst(), foldFCmpReciprocalAndZero(), foldFCmpWithFloorAndCeil(), foldOpIntoPhi(), FoldOpIntoSelect(), foldSqrtWithFcmpZero(), foldVectorCmp(), GEP, llvm::VectorType::get(), llvm::InstCombiner::getComplexity(), llvm::ConstantInt::getFalse(), llvm::IRBuilderBase::getIntNTy(), llvm::Constant::getNullValue(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::InstCombiner::getSimplifyQuery(), llvm::APFloat::getSmallestNormalized(), llvm::CmpInst::getSwappedPredicate(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::ConstantFP::getZero(), llvm::Value::hasOneUse(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SLT, IntX, llvm::FCmpInst::isEquality(), llvm::isKnownNeverNaN(), llvm::APFloat::isZero(), llvm_unreachable, llvm::PatternMatch::m_AnyZeroFP(), llvm::PatternMatch::m_APFloat(), llvm::PatternMatch::m_c_Select(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_ElementWiseBitCast(), llvm::PatternMatch::m_FAdd(), llvm::PatternMatch::m_FNeg(), llvm::PatternMatch::m_FPExt(), llvm::PatternMatch::m_Instruction(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_PosZeroFP(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::matchSelectPattern(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), llvm::APFloatBase::rmNearestTiesToEven, llvm::simplifyFCmpInst(), llvm::SPF_UNKNOWN, llvm::InstCombiner::SQ, X, and Y.
Instruction * InstCombinerImpl::visitFDiv | ( | BinaryOperator & | I | ) |
Definition at line 2111 of file InstCombineMulDivRem.cpp.
References B, llvm::InstCombiner::Builder, convertFSqrtDivIntoFMul(), llvm::IRBuilderBase::CreateBinaryIntrinsic(), llvm::IRBuilderBase::CreateFAddFMF(), llvm::BinaryOperator::CreateFDivFMF(), llvm::IRBuilderBase::CreateFMulFMF(), llvm::BinaryOperator::CreateFMulFMF(), D, llvm::emitUnaryFloatFnCall(), foldBinopWithPhiOperands(), foldFDivConstantDividend(), foldFDivPowDivisor(), foldFDivSqrtDivisor(), FoldOpIntoSelect(), foldPowiReassoc(), foldVectorBinop(), llvm::SimplifyQuery::getWithInstruction(), llvm::hasFloatFn(), llvm::Value::hasOneUse(), I, isFSqrtDivToFMulLegal(), llvm::PatternMatch::m_c_FMul(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_FAbs(), llvm::PatternMatch::m_FDiv(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificFP(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::Mul, R2, llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), llvm::simplifyFDivInst(), llvm::InstCombiner::SQ, llvm::InstCombiner::TLI, X, and Y.
Instruction * InstCombinerImpl::visitFenceInst | ( | FenceInst & | FI | ) |
Definition at line 3967 of file InstCombineCalls.cpp.
References eraseInstFromFunction(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::FenceInst::getOrdering(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getPrevNode(), llvm::FenceInst::getSyncScopeID(), llvm::isAtLeastOrStrongerThan(), llvm::Instruction::isIdenticalTo(), llvm::SyncScope::SingleThread, and llvm::SyncScope::System.
Instruction * InstCombinerImpl::visitFMul | ( | BinaryOperator & | I | ) |
Definition at line 953 of file InstCombineMulDivRem.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::ConstantFoldUnaryOpOperand(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateFMulFMF(), llvm::BinaryOperator::CreateFMulFMF(), llvm::UnaryOperator::CreateFNegFMF(), llvm::IRBuilderBase::CreateFNegFMF(), llvm::BinaryOperator::CreateFSubFMF(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateUnaryIntrinsic(), llvm::InstCombiner::DL, foldBinOpIntoSelectOrPhi(), foldBinopWithPhiOperands(), foldFMulReassoc(), foldMulSelectToNegate(), foldVectorBinop(), llvm::SimplifyQuery::getWithInstruction(), I, llvm::isKnownNeverNaN(), llvm::APFloat::isNegative(), llvm::APFloat::isZero(), llvm::Log2(), llvm::PatternMatch::m_APFloatAllowPoison(), llvm::PatternMatch::m_c_FMul(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_FMul(), llvm::PatternMatch::m_FNeg(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_SpecificFP(), llvm::PatternMatch::m_UIToFP(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::matchSimpleRecurrence(), llvm::InstCombiner::replaceInstUsesWith(), llvm::Instruction::setMetadata(), SimplifyAssociativeOrCommutative(), llvm::simplifyFMulInst(), SimplifySelectsFeedingBinaryOp(), llvm::InstCombiner::SQ, X, and Y.
Instruction * InstCombinerImpl::visitFNeg | ( | UnaryOperator & | I | ) |
Definition at line 2994 of file InstCombineAddSub.cpp.
References llvm::InstCombiner::Builder, Cond, llvm::Instruction::copyFastMathFlags(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateCopySign(), llvm::IRBuilderBase::CreateFNegFMF(), llvm::BinaryOperator::CreateFSubFMF(), llvm::IRBuilderBase::CreateVectorReverse(), llvm::InstCombiner::DL, foldFNegIntoConstant(), llvm::InstCombiner::getSimplifyQuery(), I, llvm::isGuaranteedNotToBeUndefOrPoison(), llvm::PatternMatch::m_CopySign(), llvm::PatternMatch::m_FNeg(), llvm::PatternMatch::m_FSub(), llvm::PatternMatch::m_ImmConstant(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Poison(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Shuffle(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_VecReverse(), llvm::PatternMatch::match(), P, llvm::InstCombiner::replaceInstUsesWith(), llvm::Reverse, llvm::Instruction::setFastMathFlags(), llvm::Instruction::setHasNoSignedZeros(), llvm::simplifyFNegInst(), X, and Y.
Instruction * InstCombinerImpl::visitFPExt | ( | CastInst & | CI | ) |
Definition at line 1950 of file InstCombineCasts.cpp.
References commonCastTransforms(), llvm::CastInst::Create(), llvm::User::getOperand(), llvm::Value::getType(), and isKnownExactCastIntToFP().
Instruction * InstCombinerImpl::visitFPToSI | ( | FPToSIInst & | FI | ) |
Definition at line 2030 of file InstCombineCasts.cpp.
References commonCastTransforms(), foldFPtoI(), foldItoFPtoI(), and I.
Instruction * InstCombinerImpl::visitFPToUI | ( | FPToUIInst & | FI | ) |
Definition at line 2020 of file InstCombineCasts.cpp.
References commonCastTransforms(), foldFPtoI(), foldItoFPtoI(), and I.
Instruction * InstCombinerImpl::visitFPTrunc | ( | FPTruncInst & | CI | ) |
Definition at line 1761 of file InstCombineCasts.cpp.
References llvm::InstCombiner::Builder, commonCastTransforms(), Cond, llvm::Instruction::copyFastMathFlags(), llvm::BinaryOperator::Create(), llvm::CallInst::Create(), llvm::CastInst::Create(), llvm::BinaryOperator::CreateFDivFMF(), llvm::BinaryOperator::CreateFMulFMF(), llvm::IRBuilderBase::CreateFNegFMF(), llvm::CastInst::CreateFPCast(), llvm::IRBuilderBase::CreateFPTrunc(), llvm::IRBuilderBase::CreateFPTruncFMF(), llvm::IRBuilderBase::CreateFRemFMF(), llvm::IRBuilderBase::CreateSelectFMF(), llvm::Instruction::getFastMathFlags(), llvm::Type::getFPMantissaWidth(), getMinimumFPType(), llvm::Instruction::getModule(), llvm::User::getOperand(), llvm::Intrinsic::getOrInsertDeclaration(), llvm::CastInst::getSrcTy(), llvm::Value::getType(), I, II, llvm::Type::isBFloatTy(), isKnownExactCastIntToFP(), LHS, llvm::PatternMatch::m_FNeg(), llvm::PatternMatch::m_FPExt(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), RHS, shrinkInsertElt(), X, and Y.
Instruction * InstCombinerImpl::visitFree | ( | CallInst & | FI, |
Value * | FreedOp | ||
) |
Definition at line 3908 of file InstructionCombining.cpp.
References CreateNonTerminatorUnreachable(), llvm::InstCombiner::DL, eraseInstFromFunction(), llvm::TargetLibraryInfo::getLibFunc(), llvm::getReallocatedOperand(), llvm::TargetLibraryInfo::has(), llvm::Value::hasOneUse(), I, llvm::InstCombiner::MinimizeSize, llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::TLI, and tryToMoveFreeBeforeNullTest().
Referenced by visitCallInst().
Instruction * InstCombinerImpl::visitFreeze | ( | FreezeInst & | I | ) |
Definition at line 5147 of file InstructionCombining.cpp.
References llvm::InstCombiner::AC, assert(), llvm::CallingConv::C, llvm::InstCombiner::DT, foldFreezeIntoRecurrence(), foldOpIntoPhi(), freezeOtherUses(), llvm::Constant::getAllOnesValue(), llvm::Constant::getNullValue(), llvm::ConstantInt::getTrue(), llvm::SimplifyQuery::getWithInstruction(), I, llvm::isGuaranteedNotToBeUndefOrPoison(), isUsedWithinShuffleVector(), llvm::PatternMatch::m_c_Select(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), pushFreezeToPreventPoisonFromPropagating(), llvm::InstCombiner::replaceInstUsesWith(), llvm::Constant::replaceUndefsWith(), llvm::simplifyFreezeInst(), and llvm::InstCombiner::SQ.
Instruction * InstCombinerImpl::visitFRem | ( | BinaryOperator & | I | ) |
Definition at line 2549 of file InstCombineMulDivRem.cpp.
References foldBinopWithPhiOperands(), foldVectorBinop(), llvm::SimplifyQuery::getWithInstruction(), I, llvm::InstCombiner::replaceInstUsesWith(), llvm::simplifyFRemInst(), llvm::InstCombiner::SQ, and X.
Instruction * InstCombinerImpl::visitFSub | ( | BinaryOperator & | I | ) |
Definition at line 3086 of file InstCombineAddSub.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::cannotBeNegativeZero(), llvm::ConstantFoldBinaryOpOperands(), llvm::ConstantFoldUnaryOpOperand(), llvm::IRBuilderBase::CreateFAddFMF(), llvm::BinaryOperator::CreateFAddFMF(), llvm::IRBuilderBase::CreateFDivFMF(), llvm::IRBuilderBase::CreateFMulFMF(), llvm::BinaryOperator::CreateFMulFMF(), llvm::UnaryOperator::CreateFNegFMF(), llvm::IRBuilderBase::CreateFPExt(), llvm::IRBuilderBase::CreateFPTrunc(), llvm::IRBuilderBase::CreateFSubFMF(), llvm::BinaryOperator::CreateFSubFMF(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::InstCombiner::DL, F, factorizeFAddFSub(), llvm::FAdd, llvm::FMul, foldBinopWithPhiOperands(), foldFNegIntoConstant(), FoldOpIntoSelect(), foldVectorBinop(), llvm::InstCombiner::getSimplifyQuery(), llvm::Value::getType(), I, llvm::PatternMatch::m_c_FAdd(), llvm::PatternMatch::m_c_FMul(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_FDiv(), llvm::PatternMatch::m_FMul(), llvm::PatternMatch::m_FNeg(), llvm::PatternMatch::m_FPExt(), llvm::PatternMatch::m_FPTrunc(), llvm::PatternMatch::m_FSub(), llvm::PatternMatch::m_ImmConstant(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), simplify, llvm::simplifyFSubInst(), SimplifySelectsFeedingBinaryOp(), llvm::Sub, X, and Y.
Instruction * InstCombinerImpl::visitGEPOfGEP | ( | GetElementPtrInst & | GEP, |
GEPOperator * | Src | ||
) |
Definition at line 2679 of file InstructionCombining.cpp.
References llvm::SmallVectorImpl< T >::append(), llvm::append_range(), llvm::InstCombiner::Builder, canonicalizeGEPOfConstGEPI8(), llvm::count_if(), llvm::IRBuilderBase::CreateGEP(), llvm::InstCombiner::DL, llvm::drop_begin(), llvm::drop_end(), llvm::SmallVectorBase< Size_T >::empty(), llvm::enumerate(), GEP, llvm::gep_type_begin(), llvm::gep_type_end(), llvm::DataLayout::getGEPIndicesForOffset(), llvm::DataLayout::getIndexedOffsetInType(), llvm::generic_gep_type_iterator< ItTy >::getIndexedType(), llvm::DataLayout::getIndexTypeSizeInBits(), llvm::Type::getInt32Ty(), getMergedGEPNoWrapFlags(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), I, Idx, llvm::Offset, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::InstCombiner::replaceInstUsesWith(), shouldMergeGEPs(), llvm::simplifyAddInst(), llvm::InstCombiner::SQ, llvm::GEPNoWrapFlags::withoutNoUnsignedSignedWrap(), and llvm::GEPNoWrapFlags::withoutNoUnsignedWrap().
Referenced by visitGetElementPtrInst().
Instruction * InstCombinerImpl::visitGetElementPtrInst | ( | GetElementPtrInst & | GEP | ) |
Definition at line 3140 of file InstructionCombining.cpp.
References llvm::all_of(), llvm::any_of(), llvm::append_range(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::countr_zero(), llvm::GetElementPtrInst::Create(), llvm::IRBuilderBase::CreateBinOp(), llvm::IRBuilderBase::CreateGEP(), llvm::GetElementPtrInst::CreateInBounds(), llvm::IRBuilderBase::CreatePtrAdd(), llvm::IRBuilderBase::CreateSExt(), llvm::IRBuilderBase::CreateTrunc(), llvm::IRBuilderBase::CreateVectorSplat(), llvm::IRBuilderBase::CreateZExt(), llvm::InstCombiner::DL, llvm::drop_begin(), llvm::drop_end(), llvm::enumerate(), foldGEPOfPhi(), foldSelectGEP(), GEP, llvm::gep_type_begin(), llvm::VectorType::get(), llvm::APInt::getAllOnes(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getFixedValue(), llvm::generic_gep_type_iterator< ItTy >::getIndexedType(), llvm::GetElementPtrInst::getIndexedType(), llvm::DataLayout::getIndexSizeInBits(), llvm::DataLayout::getIndexType(), llvm::DataLayout::getIndexTypeSizeInBits(), llvm::IRBuilderBase::getInt(), llvm::IRBuilderBase::getInt8Ty(), llvm::Constant::getNullValue(), llvm::Type::getPointerAddressSpace(), llvm::Value::getPointerDereferenceableBytes(), llvm::Type::getScalarSizeInBits(), llvm::getSplatValue(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::getUnderlyingObject(), llvm::SimplifyQuery::getWithInstruction(), llvm::has_single_bit(), I, Idx, llvm::APInt::isAllOnes(), llvm::Type::isIntegerTy(), llvm::APInt::isNonNegative(), llvm::Type::isSized(), llvm::generic_gep_type_iterator< ItTy >::isStruct(), llvm::Type::isVectorTy(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isZero(), llvm::PatternMatch::m_AddLike(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_IDiv(), llvm::PatternMatch::m_NNegZExt(), llvm::PatternMatch::m_NSWAddLike(), llvm::PatternMatch::m_NUWAddLike(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_SDiv(), llvm::PatternMatch::m_SExtLike(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_UDiv(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::GEPNoWrapFlags::none(), llvm::GEPNoWrapFlags::noUnsignedWrap(), llvm::Offset, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), llvm::APInt::sdivrem(), shouldCanonicalizeGEPToPtrAdd(), SimplifyDemandedVectorElts(), llvm::simplifyGEPInst(), llvm::InstCombiner::SQ, llvm::Value::stripAndAccumulateInBoundsConstantOffsets(), llvm::ArrayRef< T >::take_front(), llvm::APInt::udivrem(), llvm::APInt::ule(), visitGEPOfGEP(), X, and Y.
Instruction * InstCombinerImpl::visitICmpInst | ( | ICmpInst & | I | ) |
Orders the operands of the compare so that they are listed from most complex to least complex. This puts constants before unary operators, before binary operators.
Definition at line 7614 of file InstCombineCompares.cpp.
References A, llvm::AllOnes, assert(), B, llvm::InstCombiner::Builder, llvm::CallingConv::C, canonicalizeCmpWithConstant(), canonicalizeICmpBool(), canonicalizeICmpPredicate(), Cond, llvm::CmpInst::Create(), llvm::ExtractValueInst::Create(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateICmp(), llvm::IRBuilderBase::CreateICmpSLT(), D, llvm::InstCombiner::DL, eraseInstFromFunction(), llvm::SelectPatternResult::Flavor, foldAllocaCmp(), foldICmpBinOp(), foldICmpBitCast(), foldICmpCommutative(), foldICmpEquality(), foldICmpInstWithConstant(), foldICmpInstWithConstantNotInt(), foldICmpInvariantGroup(), foldICmpOfUAddOv(), foldICmpPow2Test(), foldICmpTruncWithTruncOrExt(), foldICmpUsingBoolRange(), foldICmpUsingKnownBits(), foldICmpWithCastOp(), foldICmpWithConstant(), foldICmpWithDominatingICmp(), foldICmpWithHighBitMask(), foldICmpWithZero(), foldIsMultipleOfAPowerOfTwo(), foldOpIntoPhi(), foldReductionIdiom(), foldSignBitTest(), foldVectorCmp(), llvm::APInt::getActiveBits(), llvm::Constant::getAllOnesValue(), llvm::APInt::getBitWidth(), llvm::InstCombiner::getComplexity(), llvm::InstCombiner::getFreelyInverted(), llvm::Constant::getNullValue(), llvm::APInt::getOneBitSet(), llvm::Instruction::getOpcode(), llvm::Type::getScalarSizeInBits(), llvm::CmpPredicate::getSwapped(), llvm::Value::getType(), llvm::getUnderlyingObject(), llvm::SimplifyQuery::getWithInstruction(), llvm::Value::hasOneUse(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::ICmpInst::isEquality(), llvm::InstCombiner::isFreeToInvert(), llvm::Type::isIntOrIntVectorTy(), llvm::InstCombiner::isKnownToBeAPowerOfTwo(), llvm::Type::isPointerTy(), llvm::CmpInst::isSigned(), llvm::CmpInst::isUnsigned(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_c_ICmp(), llvm::PatternMatch::m_CombineAnd(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_Instruction(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_NUWMul(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificIntAllowPoison(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_UAddWithOverflow(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::PatternMatch::match(), llvm::matchSelectPattern(), processUMulZExtIdiom(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), llvm::APInt::setBit(), llvm::simplifyICmpInst(), llvm::SPF_UNKNOWN, llvm::InstCombiner::SQ, std::swap(), llvm::APInt::trunc(), llvm::APInt::uge(), X, and Y.
Instruction * InstCombinerImpl::visitInsertElementInst | ( | InsertElementInst & | IE | ) |
Definition at line 1691 of file InstCombineVectorOps.cpp.
References llvm::InstCombiner::Builder, collectShuffleElements(), llvm::InsertElementInst::Create(), llvm::IRBuilderBase::CreateInsertElement(), llvm::InstCombiner::DL, foldConstantInsEltIntoShuffle(), foldInsEltIntoIdentityShuffle(), foldInsEltIntoSplat(), foldInsSequenceIntoSplat(), foldTruncInsEltPair(), llvm::VectorType::get(), llvm::UndefValue::get(), llvm::PoisonValue::get(), llvm::APInt::getAllOnes(), llvm::IRBuilderBase::getInt64(), getPreferredVectorIndex(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::Value::hasOneUse(), hoistInsEltConst(), llvm::DataLayout::isBigEndian(), llvm::Type::isFloatingPointTy(), llvm::Type::isIntegerTy(), llvm::Type::isVectorTy(), llvm::PatternMatch::m_BitCast(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_ExtractElt(), llvm::PatternMatch::m_InsertElt(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), narrowInsElt(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), SimplifyDemandedVectorElts(), llvm::simplifyInsertElementInst(), llvm::Splat, and llvm::InstCombiner::SQ.
Instruction * InstCombinerImpl::visitInsertValueInst | ( | InsertValueInst & | I | ) |
Try to find redundant insertvalue instructions, like the following ones: %0 = insertvalue { i8, i32 } undef, i8 x, 0 %1 = insertvalue { i8, i32 } %0, i8 y, 0 Here the second instruction inserts values at the same indices, as the first one, making the first one redundant.
It should be transformed to: %0 = insertvalue { i8, i32 } undef, i8 y, 0
Definition at line 1233 of file InstCombineVectorOps.cpp.
References llvm::Depth, foldAggregateConstructionIntoAggregateReuse(), llvm::SimplifyQuery::getWithInstruction(), I, llvm::InstCombiner::replaceInstUsesWith(), llvm::simplifyInsertValueInst(), and llvm::InstCombiner::SQ.
|
inline |
Specify what to return for unhandled instructions.
Definition at line 188 of file InstCombineInternal.h.
Instruction * InstCombinerImpl::visitIntToPtr | ( | IntToPtrInst & | CI | ) |
Definition at line 2062 of file InstCombineCasts.cpp.
References llvm::all_of(), llvm::sampleprof::Base, llvm::InstCombiner::Builder, commonCastTransforms(), llvm::GetElementPtrInst::Create(), llvm::IRBuilderBase::CreateZExtOrTrunc(), llvm::InstCombiner::DL, llvm::IntToPtrInst::getAddressSpace(), llvm::Value::getContext(), llvm::IRBuilderBase::getInt8Ty(), llvm::DataLayout::getIntPtrType(), llvm::User::getOperand(), llvm::Type::getPointerAddressSpace(), llvm::DataLayout::getPointerSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::Type::getWithNewType(), I, llvm::PatternMatch::m_c_Add(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_PtrToIntSameSize(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::Offset, P, and llvm::Value::users().
Instruction * InstCombinerImpl::visitInvokeInst | ( | InvokeInst & | II | ) |
Definition at line 3995 of file InstCombineCalls.cpp.
References II.
Instruction * InstCombinerImpl::visitLandingPadInst | ( | LandingPadInst & | LI | ) |
Definition at line 4652 of file InstructionCombining.cpp.
References llvm::LandingPadInst::addClause(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::CallingConv::C, llvm::classifyEHPersonality(), llvm::LandingPadInst::Create(), llvm::SmallVectorImpl< T >::erase(), llvm::Filter, llvm::ConstantArray::get(), llvm::ArrayType::get(), llvm::LandingPadInst::getClause(), llvm::ArrayType::getElementType(), llvm::Constant::getNullValue(), llvm::LandingPadInst::getNumClauses(), llvm::ArrayType::getNumElements(), llvm::User::getOperand(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::Value::getType(), getType(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::LandingPadInst::isCatch(), isCatchAll(), llvm::LandingPadInst::isCleanup(), llvm::LandingPadInst::isFilter(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorImpl< T >::reserve(), llvm::LandingPadInst::setCleanup(), shorter_filter(), llvm::SmallVectorBase< Size_T >::size(), llvm::Constant::stripPointerCasts(), and llvm::Value::stripPointerCasts().
Instruction * InstCombinerImpl::visitLoadInst | ( | LoadInst & | LI | ) |
Definition at line 1078 of file InstCombineLoadStoreAlloca.cpp.
References llvm::InstCombiner::AA, assert(), llvm::InstCombiner::Builder, canSimplifyNullLoadOrGEP(), combineLoadToOperationType(), llvm::combineMetadataForCSE(), llvm::Instruction::copyMetadata(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateBitOrPointerCast(), llvm::IRBuilderBase::CreateLoad(), CreateNonTerminatorUnreachable(), llvm::InstCombiner::DL, llvm::FindAvailableLoadedValue(), llvm::PoisonValue::get(), llvm::LoadInst::getAlign(), llvm::Instruction::getFunction(), llvm::Value::getName(), llvm::User::getOperand(), llvm::LoadInst::getOrdering(), llvm::LoadInst::getPointerAddressSpace(), llvm::LoadInst::getSyncScopeID(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::isSafeToLoadUnconditionally(), llvm::LoadInst::isUnordered(), llvm::NullPointerIsDefined(), llvm::Metadata::PoisonGeneratingIDs, replaceGEPIdxWithZero(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), llvm::LoadInst::setAlignment(), llvm::LoadInst::setAtomic(), llvm::simplifyLoadInst(), llvm::InstCombiner::SQ, and unpackLoadToAggregate().
Instruction * InstCombinerImpl::visitLShr | ( | BinaryOperator & | I | ) |
Definition at line 1278 of file InstCombineShifts.cpp.
References llvm::AllOnes, assert(), llvm::BitWidth, llvm::InstCombiner::Builder, llvm::CallingConv::C, commonShiftTransforms(), llvm::InstCombiner::computeKnownBits(), llvm::BinaryOperator::Create(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateAShr(), llvm::IRBuilderBase::CreateICmpEQ(), llvm::IRBuilderBase::CreateICmpSLT(), llvm::IRBuilderBase::CreateIsNotNeg(), llvm::IRBuilderBase::CreateIsNotNull(), llvm::IRBuilderBase::CreateIsNull(), llvm::IRBuilderBase::CreateLShr(), llvm::IRBuilderBase::CreateShl(), llvm::IRBuilderBase::CreateTrunc(), llvm::IRBuilderBase::CreateUnaryIntrinsic(), llvm::IRBuilderBase::CreateZExt(), llvm::APInt::eq(), foldVectorBinop(), llvm::APInt::getAllOnes(), llvm::Constant::getAllOnesValue(), llvm::APInt::getLowBitsSet(), llvm::Constant::getNullValue(), llvm::BinaryOperator::getOpcode(), llvm::Type::getScalarSizeInBits(), getScalarSizeInBits(), llvm::ConstantInt::getSigned(), llvm::Value::getType(), getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::APInt::getZExtValue(), llvm::Instruction::hasNoSignedWrap(), hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), hasNoUnsignedWrap(), llvm::Value::hasOneUse(), I, II, llvm::Type::isIntegerTy(), llvm::Type::isIntOrIntVectorTy(), llvm::InstCombiner::isKnownToBeAPowerOfTwo(), llvm::isPowerOf2_32(), llvm::Log2_32(), llvm::APInt::logBase2(), llvm::APInt::lshr(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_LShr(), llvm::MIPatternMatch::m_Neg(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_NSWMul(), llvm::PatternMatch::m_NSWSub(), llvm::PatternMatch::m_NUWMul(), llvm::PatternMatch::m_NUWShl(), llvm::PatternMatch::m_NUWSub(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_SpecificIntAllowPoison(), llvm::PatternMatch::m_SRem(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), RHS, setShiftFlags(), llvm::APInt::shl(), llvm::simplifyLShrInst(), llvm::InstCombiner::SQ, llvm::APInt::uge(), llvm::APInt::ugt(), llvm::APInt::ult(), X, and Y.
Instruction * InstCombinerImpl::visitMul | ( | BinaryOperator & | I | ) |
Definition at line 189 of file InstCombineMulDivRem.cpp.
References assert(), llvm::BitWidth, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::ConstantFoldBinaryOpOperands(), llvm::APInt::countr_zero(), llvm::CastInst::Create(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateBinaryIntrinsic(), llvm::IRBuilderBase::CreateBinOp(), llvm::BinaryOperator::CreateExact(), llvm::IRBuilderBase::CreateFreeze(), llvm::IRBuilderBase::CreateIsNeg(), llvm::IRBuilderBase::CreateLShr(), llvm::IRBuilderBase::CreateMul(), llvm::BinaryOperator::CreateNeg(), llvm::IRBuilderBase::CreateNeg(), llvm::IRBuilderBase::CreateNSWMul(), llvm::BinaryOperator::CreateNSWNeg(), llvm::IRBuilderBase::CreateTrunc(), llvm::IRBuilderBase::CreateZExt(), llvm::InstCombiner::DL, foldBinOpIntoSelectOrPhi(), foldBinOpOfSelectAndCastOfSelectCondition(), foldBinopWithPhiOperands(), foldMulSelectToNegate(), foldMulShl1(), foldUsingDistributiveLaws(), foldVectorBinop(), llvm::ConstantInt::getBool(), llvm::ConstantExpr::getExactLogBase2(), llvm::ConstantExpr::getNeg(), llvm::Constant::getNullValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::IRBuilderBase::getTrue(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::APInt::getZExtValue(), hasNoSignedWrap(), llvm::Value::hasOneUse(), I, llvm::APInt::isAllOnes(), llvm::Instruction::isExact(), llvm::isGuaranteedNotToBeUndef(), llvm::Type::isIntOrIntVectorTy(), llvm::Constant::isNotMinSignedValue(), llvm::APInt::isZero(), llvm::APInt::logBase2(), llvm::PatternMatch::m_AddLike(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_APIntAllowPoison(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_c_Mul(), llvm::PatternMatch::m_CheckedInt(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_Exact(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Mul(), llvm::MIPatternMatch::m_Neg(), llvm::PatternMatch::m_NegatedPower2(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_SDiv(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_SpecificIntAllowPoison(), llvm::PatternMatch::m_UDiv(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::CmpInst::makeCmpResultType(), llvm::PatternMatch::match(), llvm::Mul, N, llvm::Negator::Negate(), llvm::InstCombiner::replaceInstUsesWith(), llvm::APInt::sdivrem(), llvm::Instruction::setHasNoSignedWrap(), llvm::Instruction::setHasNoUnsignedWrap(), SimplifyAssociativeOrCommutative(), llvm::simplifyMulInst(), llvm::InstCombiner::SQ, llvm::Value::takeName(), tryGetLog2(), X, and Y.
Instruction * InstCombinerImpl::visitOr | ( | BinaryOperator & | I | ) |
Res, Overflow = xxx_with_overflow X, C1 Try to canonicalize the pattern "Overflow | icmp pred Res, C2" into "Overflow | icmp pred X, C2 +/- C1".
Definition at line 4002 of file InstCombineAndOrXor.cpp.
References A, llvm::AllOnes, B, llvm::InstCombiner::Builder, llvm::CallingConv::C, canonicalizeCondSignextOfHighBitExtractToSignextHighBitExtract(), canonicalizeLogicFirst(), llvm::InstCombiner::computeKnownBits(), Concat, llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateFNeg(), llvm::IRBuilderBase::CreateICmp(), llvm::IRBuilderBase::CreateICmpSGT(), llvm::IRBuilderBase::CreateIsNotNull(), llvm::BinaryOperator::CreateNot(), llvm::IRBuilderBase::CreateNot(), llvm::IRBuilderBase::CreateOr(), llvm::IRBuilderBase::CreateSub(), llvm::IRBuilderBase::CreateUnaryIntrinsic(), D, llvm::InstCombiner::DL, llvm::DominatorTree::dominates(), llvm::InstCombiner::DT, foldAddLikeCommutative(), foldBinOpIntoSelectOrPhi(), foldBinOpShiftWithShift(), foldBinopWithPhiOperands(), foldBitwiseLogicWithIntrinsics(), foldComplexAndOrPatterns(), foldIntegerPackFromVector(), foldOrOfInversions(), foldOrToXor(), foldOrUnsignedUMulOverflowICmp(), foldUsingDistributiveLaws(), foldVectorBinop(), llvm::Constant::getAllOnesValue(), llvm::BinaryOpIntrinsic::getBinaryOp(), llvm::Type::getFltSemantics(), llvm::IRBuilderBase::GetInsertBlock(), llvm::BinaryOpIntrinsic::getLHS(), llvm::Constant::getNullValue(), llvm::BasicBlock::getParent(), llvm::BinaryOpIntrinsic::getRHS(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::Function::hasFnAttribute(), llvm::Value::hasOneUse(), llvm::APFloatBase::hasSignBitInMSB(), I, llvm::CmpInst::ICMP_NE, llvm::APInt::isAllOnes(), llvm::ICmpInst::isEquality(), llvm::Type::isFloatingPointTy(), llvm::Type::isIntOrIntVectorTy(), llvm::CmpInst::isSigned(), llvm::BinaryOpIntrinsic::isSigned(), isZero(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_DisjointOr(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_c_Xor(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_ElementWiseBitCast(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_LogicalOr(), llvm::PatternMatch::m_Mul(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_NSWSub(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_SignMask(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificICmp(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_WithOverflowInst(), llvm::PatternMatch::m_Xor(), llvm::MIPatternMatch::m_ZeroInt(), llvm::InstCombiner::MaskedValueIsZero(), llvm::PatternMatch::match(), matchBSwapOrBitReverse(), matchDeMorgansLaws(), matchFunnelShift(), matchOrConcat(), llvm::matchSimpleRecurrence(), llvm::Mul, llvm::KnownBits::One, reassociateFCmps(), reassociateForUses(), llvm::InstCombiner::replaceInstUsesWith(), llvm::APInt::sadd_ov(), SimplifyAddWithRemainder(), simplifyAndOrWithOpReplaced(), SimplifyAssociativeOrCommutative(), SimplifyDemandedInstructionBits(), llvm::simplifyOrInst(), sinkNotIntoOtherHandOfLogicalOp(), llvm::InstCombiner::SQ, llvm::APInt::ssub_ov(), llvm::Sub, std::swap(), llvm::Value::takeName(), tryFoldInstWithCtpopWithNot(), llvm::APInt::uadd_ov(), llvm::APInt::usub_ov(), X, llvm::Xor, and Y.
Instruction * InstCombinerImpl::visitPHINode | ( | PHINode & | PN | ) |
Definition at line 1439 of file InstCombinePHI.cpp.
References llvm::all_of(), llvm::CastInst::CreatePointerCast(), foldDeadPhiWeb(), foldIntegerTypedPHI(), foldPHIArgIntToPtrToPHI(), foldPHIArgOpIntoPHI(), foldPHIArgZextsIntoPHI(), llvm::PoisonValue::get(), getAnyNonZeroConstInt(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), llvm::User::getOperand(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::InstCombiner::getSimplifyQuery(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::Value::hasNUsesOrMore(), llvm::Value::hasOneUse(), I, if(), llvm::PHINode::incoming_values(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::CmpInst::isEquality(), llvm::isKnownNonZero(), llvm::Type::isPointerTy(), IV, llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), llvm::simplifyInstruction(), llvm::InstCombiner::SQ, llvm::Value::stripPointerCasts(), llvm::Instruction::user_back(), and llvm::Value::users().
Instruction * InstCombinerImpl::visitPtrToInt | ( | PtrToIntInst & | CI | ) |
Definition at line 2138 of file InstCombineCasts.cpp.
References assert(), llvm::InstCombiner::Builder, commonCastTransforms(), llvm::InsertElementInst::Create(), llvm::CastInst::CreateIntegerCast(), llvm::IRBuilderBase::CreatePtrToInt(), llvm::InstCombiner::DL, foldPtrToIntOfGEP(), llvm::Value::getContext(), llvm::DataLayout::getIntPtrType(), llvm::PtrToIntInst::getPointerAddressSpace(), llvm::PtrToIntInst::getPointerOperand(), llvm::DataLayout::getPointerSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::Value::getType(), llvm::Type::getWithNewType(), llvm::PatternMatch::m_InsertElt(), llvm::PatternMatch::m_IntToPtr(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), P, Ptr, and llvm::InstCombiner::replaceInstUsesWith().
Instruction * InstCombinerImpl::visitReturnInst | ( | ReturnInst & | RI | ) |
Definition at line 3948 of file InstructionCombining.cpp.
References llvm::ReturnInst::Create(), F, llvm::fcNone, llvm::Value::getContext(), llvm::Instruction::getFunction(), llvm::ReturnInst::getReturnValue(), llvm::Value::getType(), llvm::AttributeFuncs::isNoFPClassCompatibleType(), llvm::NullPointerIsDefined(), llvm::InstCombiner::replaceOperand(), RetTy, and SimplifyDemandedUseFPClass().
Instruction * InstCombinerImpl::visitSDiv | ( | BinaryOperator & | I | ) |
Definition at line 1751 of file InstCombineMulDivRem.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, commonIDivTransforms(), llvm::InstCombiner::computeKnownBits(), Cond, llvm::KnownBits::countMinTrailingZeros(), llvm::APInt::countr_zero(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateAShr(), llvm::IRBuilderBase::CreateICmpEQ(), llvm::IRBuilderBase::CreateIsNotNeg(), llvm::IRBuilderBase::CreateLShr(), llvm::BinaryOperator::CreateNeg(), llvm::BinaryOperator::CreateNSWNeg(), llvm::IRBuilderBase::CreateSDiv(), foldVectorBinop(), llvm::Constant::getAllOnesValue(), llvm::ConstantExpr::getExactLogBase2(), llvm::ConstantExpr::getNeg(), llvm::Type::getScalarSizeInBits(), llvm::APInt::getSignedMinValue(), llvm::APInt::getSignificantBits(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), I, llvm::isKnownNegation(), llvm::isKnownNonNegative(), llvm::InstCombiner::isKnownToBeAPowerOfTwo(), llvm::APInt::isMinSignedValue(), llvm::KnownBits::isNonNegative(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_NegatedPower2(), llvm::PatternMatch::m_NonNegative(), llvm::PatternMatch::m_NSWNeg(), llvm::PatternMatch::m_NSWShl(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_SDiv(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_SignMask(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), llvm::Instruction::setIsExact(), llvm::simplifySDivInst(), llvm::InstCombiner::SQ, X, and Y.
Instruction * llvm::InstCombinerImpl::visitSelectInst | ( | SelectInst & | SI | ) |
Instruction * InstCombinerImpl::visitSExt | ( | SExtInst & | Sext | ) |
Definition at line 1482 of file InstCombineCasts.cpp.
References A, assert(), llvm::InstCombiner::Builder, canEvaluateSExtd(), commonCastTransforms(), llvm::InstCombiner::ComputeNumSignBits(), llvm::ConstantFoldCastOperand(), llvm::CastInst::Create(), llvm::IRBuilderBase::CreateAShr(), llvm::CastInst::CreateIntegerCast(), llvm::IRBuilderBase::CreateShl(), llvm::IRBuilderBase::CreateVScale(), llvm::dbgs(), llvm::InstCombiner::DL, EvaluateInDifferentType(), llvm::Function::getFnAttribute(), llvm::Instruction::getFunction(), llvm::Value::getName(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::ConstantExpr::getSub(), llvm::Value::getType(), llvm::Attribute::getVScaleRangeMax(), llvm::SimplifyQuery::getWithInstruction(), llvm::Function::hasFnAttribute(), llvm::Value::hasOneUse(), I, llvm::Constant::isElementWiseEqual(), llvm::isKnownNonNegative(), LLVM_DEBUG, llvm::Log2_32(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_LShr(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_SpecificIntAllowPoison(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_VScale(), llvm::PatternMatch::match(), llvm::Constant::mergeUndefsWith(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::SQ, llvm::Instruction::user_back(), X, and Y.
Instruction * InstCombinerImpl::visitShl | ( | BinaryOperator & | I | ) |
Definition at line 1041 of file InstCombineShifts.cpp.
References llvm::AllOnes, B, llvm::BitWidth, llvm::InstCombiner::Builder, llvm::CallingConv::C, commonShiftTransforms(), llvm::BinaryOperator::Create(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateBinOp(), llvm::IRBuilderBase::CreateNeg(), llvm::IRBuilderBase::CreateShl(), llvm::IRBuilderBase::CreateTrunc(), dropRedundantMaskingOfLeftShiftInput(), foldVectorBinop(), llvm::Constant::getAllOnesValue(), llvm::APInt::getHighBitsSet(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::BinaryOperator::getOpcode(), getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::APInt::getSignMask(), llvm::SimplifyQuery::getWithInstruction(), llvm::APInt::getZExtValue(), I, llvm::IRBuilderBase::Insert(), llvm::Instruction::isCommutative(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_Exact(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::InstCombiner::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), setShiftFlags(), llvm::APInt::shl(), llvm::simplifyShlInst(), llvm::InstCombiner::SQ, std::swap(), llvm::APInt::ult(), X, and Y.
Instruction * InstCombinerImpl::visitShuffleVectorInst | ( | ShuffleVectorInst & | SVI | ) |
Definition at line 2877 of file InstCombineVectorOps.cpp.
References assert(), llvm::InstCombiner::Builder, canEvaluateShuffled(), canonicalizeInsertSplat(), llvm::ShuffleVectorInst::commute(), llvm::CastInst::Create(), llvm::IRBuilderBase::CreateBitCast(), llvm::IRBuilderBase::CreateExtractElement(), llvm::IRBuilderBase::CreateShuffleVector(), llvm::createUnaryMask(), llvm::InstCombiner::DL, evaluateInDifferentElementOrder(), foldCastShuffle(), foldIdentityExtractShuffle(), foldIdentityPaddedShuffles(), foldOpIntoPhi(), FoldOpIntoSelect(), foldSelectShuffle(), foldShuffleOfUnaryOps(), foldShuffleWithInsert(), foldTruncShuffle(), llvm::FixedVectorType::get(), llvm::UndefValue::get(), llvm::PoisonValue::get(), llvm::APInt::getAllOnes(), llvm::Value::getName(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::ShuffleVectorInst::getShuffleMask(), llvm::ShuffleVectorInst::getType(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), llvm::SimplifyQuery::getWithInstruction(), llvm::Value::hasOneUse(), I, Idx, llvm::DataLayout::isBigEndian(), llvm::isGuaranteedNotToBePoison(), isShuffleExtractingFromLHS(), isSplat(), llvm::VectorType::isValidElementType(), LHS, llvm::PatternMatch::m_BitCast(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Poison(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), narrowVectorSelect(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), RHS, llvm::scaleShuffleMaskElts(), simplifyBinOpSplats(), SimplifyDemandedVectorElts(), llvm::simplifyShuffleVectorInst(), llvm::InstCombiner::SQ, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::try_emplace(), llvm::Value::users(), X, and Y.
Instruction * InstCombinerImpl::visitSIToFP | ( | CastInst & | CI | ) |
Definition at line 2050 of file InstCombineCasts.cpp.
References commonCastTransforms(), llvm::CastInst::Create(), llvm::User::getOperand(), llvm::Value::getType(), llvm::isKnownNonNegative(), and llvm::InstCombiner::SQ.
Instruction * InstCombinerImpl::visitSRem | ( | BinaryOperator & | I | ) |
Definition at line 2478 of file InstCombineMulDivRem.cpp.
References llvm::InstCombiner::Builder, llvm::CallingConv::C, commonIRemTransforms(), llvm::BinaryOperator::CreateNSWNeg(), llvm::IRBuilderBase::CreateSRem(), foldVectorBinop(), llvm::ConstantVector::get(), llvm::ConstantExpr::getNeg(), llvm::APInt::getSignMask(), llvm::SimplifyQuery::getWithInstruction(), I, llvm::PatternMatch::m_Negative(), llvm::PatternMatch::m_NSWNeg(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_SRem(), llvm::PatternMatch::m_Value(), llvm::InstCombiner::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceInstUsesWith(), llvm::InstCombiner::replaceOperand(), RHS, llvm::simplifySRemInst(), llvm::InstCombiner::SQ, X, and Y.
Instruction * InstCombinerImpl::visitStoreInst | ( | StoreInst & | SI | ) |
Definition at line 1409 of file InstCombineLoadStoreAlloca.cpp.
References llvm::InstCombiner::AA, assert(), canSimplifyNullStoreOrGEP(), combineStoreToValueType(), equivalentAddressValues(), eraseInstFromFunction(), GEP, llvm::PoisonValue::get(), llvm::AAResults::getModRefInfoMask(), llvm::Value::getType(), handlePotentiallyDeadBlocks(), handleUnreachableFrom(), llvm::isModSet(), llvm::NullPointerIsDefined(), Ptr, llvm::InstructionWorklist::push(), removeInstructionsBeforeUnreachable(), replaceGEPIdxWithZero(), llvm::InstCombiner::replaceOperand(), unpackStoreToAggregate(), and llvm::InstCombiner::Worklist.
Instruction * InstCombinerImpl::visitSub | ( | BinaryOperator & | I | ) |
Definition at line 2257 of file InstCombineAddSub.cpp.
References A, llvm::Add, llvm::InstCombiner::AddOne(), assert(), B, llvm::BitWidth, llvm::InstCombiner::Builder, llvm::CallingConv::C, canonicalizeCondSignextOfHighBitExtractToSignextHighBitExtract(), llvm::computeKnownBits(), Cond, llvm::ConstantFoldBinaryInstruction(), llvm::Instruction::copyMetadata(), llvm::APInt::countr_zero(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateBinaryIntrinsic(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateIsNeg(), llvm::IRBuilderBase::CreateMul(), llvm::BinaryOperator::CreateNeg(), llvm::IRBuilderBase::CreateNeg(), llvm::BinaryOperator::CreateNot(), llvm::IRBuilderBase::CreateNot(), llvm::IRBuilderBase::CreateSExt(), llvm::IRBuilderBase::CreateSub(), llvm::IRBuilderBase::CreateXor(), llvm::IRBuilderBase::CreateZExt(), llvm::InstCombiner::DL, factorizeMathWithShlOps(), foldBinOpOfSelectAndCastOfSelectCondition(), foldBinopWithPhiOperands(), foldOpIntoPhi(), FoldOpIntoSelect(), foldSubOfMinMax(), foldUsingDistributiveLaws(), foldVectorBinop(), GEP, llvm::Constant::getAllOnesValue(), llvm::InstCombiner::getFreelyInverted(), llvm::APInt::getHighBitsSet(), llvm::Constant::getNullValue(), llvm::Type::getScalarSizeInBits(), llvm::ConstantExpr::getSub(), llvm::IRBuilderBase::getTrue(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::SimplifyQuery::getWithoutDomCondCache(), llvm::OverflowingBinaryOperator::hasNoSignedWrap(), llvm::OverflowingBinaryOperator::hasNoUnsignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Value::hasNUsesOrMore(), llvm::Value::hasOneUse(), I, llvm::Constant::isElementWiseEqual(), llvm::InstCombiner::isFreeToInvert(), llvm::APInt::isMask(), llvm::APInt::isNegatedPowerOf2(), llvm::APInt::isSubsetOf(), isZero(), LHS, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AddLike(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_MaxOrMin(), llvm::PatternMatch::m_c_NSWAdd(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_c_SMax(), llvm::PatternMatch::m_c_SMin(), llvm::PatternMatch::m_c_UMax(), llvm::PatternMatch::m_c_UMin(), llvm::PatternMatch::m_c_Xor(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_Mul(), llvm::MIPatternMatch::m_Neg(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_NSWAdd(), llvm::PatternMatch::m_NSWAddLike(), llvm::PatternMatch::m_NUWAddLike(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_PtrToIntSameSize(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_SExtLike(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::MIPatternMatch::m_ZeroInt(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::m_ZExtOrSelf(), llvm::PatternMatch::match(), llvm::Mul, llvm::Negator::Negate(), llvm::none_of(), llvm::Offset, OptimizePointerDifference(), llvm::InstCombiner::replaceInstUsesWith(), RHS, Select, llvm::Instruction::setHasNoSignedWrap(), llvm::Instruction::setHasNoUnsignedWrap(), llvm::simplifySubInst(), llvm::InstCombiner::SQ, llvm::Sub, llvm::InstCombiner::SubOne(), tryFoldInstWithCtpopWithNot(), X, Y, and llvm::KnownBits::Zero.
Instruction * InstCombinerImpl::visitSwitchInst | ( | SwitchInst & | SI | ) |
Definition at line 4229 of file InstructionCombining.cpp.
References llvm::all_of(), llvm::APInt::ashr(), assert(), llvm::BitWidth, llvm::InstCombiner::Builder, llvm::CallingConv::C, llvm::InstCombiner::computeKnownBits(), Cond, llvm::KnownBits::countMinLeadingOnes(), llvm::KnownBits::countMinLeadingZeros(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateTrunc(), llvm::IntegerType::get(), llvm::KnownBits::getBitWidth(), llvm::APInt::getLowBitsSet(), llvm::Type::getScalarSizeInBits(), getScalarSizeInBits(), llvm::ConstantExpr::getSub(), llvm::Value::getType(), getType(), handlePotentiallyDeadSuccessors(), llvm::OverflowingBinaryOperator::hasNoSignedWrap(), llvm::OverflowingBinaryOperator::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), llvm::APInt::lshr(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::PatternMatch::match(), llvm::InstCombiner::replaceOperand(), Select, llvm::IRBuilderBase::SetInsertPoint(), simplifySwitchOnSelectUsingRanges(), and llvm::APInt::trunc().
Instruction * InstCombinerImpl::visitTrunc | ( | TruncInst & | CI | ) |
Definition at line 757 of file InstCombineCasts.cpp.
References A, assert(), B, llvm::InstCombiner::Builder, llvm::CallingConv::C, canEvaluateTruncated(), commonCastTransforms(), llvm::InstCombiner::ComputeMaxSignificantBits(), llvm::ConstantFoldCastOperand(), llvm::ConstantFoldCompareInstOperands(), llvm::ConstantFoldSelectInstruction(), llvm::BinaryOperator::Create(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateAShr(), llvm::CastInst::CreateIntegerCast(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateOr(), llvm::IRBuilderBase::CreateShl(), llvm::IRBuilderBase::CreateTrunc(), llvm::IRBuilderBase::CreateVScale(), llvm::dbgs(), llvm::InstCombiner::DL, EvaluateInDifferentType(), llvm::APInt::exactLogBase2(), foldVecExtTruncToExtElt(), foldVecTruncToExtElt(), llvm::APInt::getBitsSetFrom(), llvm::Function::getFnAttribute(), llvm::Instruction::getFunction(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::ConstantExpr::getSub(), llvm::ConstantInt::getTrue(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::Attribute::getVScaleRangeMax(), llvm::SimplifyQuery::getWithInstruction(), llvm::Function::hasFnAttribute(), llvm::TruncInst::hasNoSignedWrap(), llvm::TruncInst::hasNoUnsignedWrap(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::isKnownNonZero(), llvm::Type::isVectorTy(), LLVM_DEBUG, llvm::Log2_32(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_LShr(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_SpecificInt_ICMP(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_VScale(), llvm::PatternMatch::m_Xor(), llvm::PatternMatch::m_ZExt(), llvm::InstCombiner::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::Constant::mergeUndefsWith(), llvm::InstCombiner::replaceInstUsesWith(), llvm::TruncInst::setHasNoSignedWrap(), llvm::TruncInst::setHasNoUnsignedWrap(), shrinkInsertElt(), shrinkSplatShuffle(), SimplifyDemandedInstructionBits(), llvm::InstCombiner::SQ, X, and Y.
Instruction * InstCombinerImpl::visitUDiv | ( | BinaryOperator & | I | ) |
Definition at line 1671 of file InstCombineMulDivRem.cpp.
References A, B, llvm::InstCombiner::Builder, commonIDivTransforms(), llvm::IRBuilderBase::CreateBinaryIntrinsic(), llvm::IRBuilderBase::CreateICmpEQ(), llvm::IRBuilderBase::CreateICmpUGE(), llvm::IRBuilderBase::CreateLShr(), llvm::CastInst::CreateZExtOrBitCast(), foldVectorBinop(), llvm::Constant::getAllOnesValue(), llvm::IRBuilderBase::getTrue(), llvm::SimplifyQuery::getWithInstruction(), I, llvm::InstCombiner::isKnownToBeAPowerOfTwo(), llvm::Log2(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Exact(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Negative(), llvm::PatternMatch::m_NUWMul(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), narrowUDivURem(), llvm::InstCombiner::replaceInstUsesWith(), llvm::Instruction::setIsExact(), llvm::simplifyUDivInst(), llvm::InstCombiner::SQ, tryGetLog2(), llvm::APInt::ushl_ov(), and X.
Instruction * InstCombinerImpl::visitUIToFP | ( | CastInst & | CI | ) |
Definition at line 2040 of file InstCombineCasts.cpp.
References commonCastTransforms(), llvm::User::getOperand(), llvm::Instruction::hasNonNeg(), llvm::isKnownNonNegative(), llvm::Instruction::setNonNeg(), and llvm::InstCombiner::SQ.
Instruction * InstCombinerImpl::visitUnconditionalBranchInst | ( | BranchInst & | BI | ) |
Definition at line 4015 of file InstructionCombining.cpp.
References assert(), llvm::BranchInst::isUnconditional(), and mergeStoreIntoSuccessor().
Referenced by visitBranchInst().
Instruction * InstCombinerImpl::visitUnreachableInst | ( | UnreachableInst & | I | ) |
Definition at line 4010 of file InstructionCombining.cpp.
References I, and removeInstructionsBeforeUnreachable().
Instruction * InstCombinerImpl::visitURem | ( | BinaryOperator & | I | ) |
Definition at line 2406 of file InstCombineMulDivRem.cpp.
References llvm::Add, llvm::InstCombiner::Builder, commonIRemTransforms(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateFreeze(), llvm::IRBuilderBase::CreateICmpEQ(), llvm::IRBuilderBase::CreateICmpNE(), llvm::IRBuilderBase::CreateICmpULT(), llvm::IRBuilderBase::CreateSub(), llvm::CastInst::CreateZExtOrBitCast(), foldVectorBinop(), llvm::Constant::getAllOnesValue(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::SimplifyQuery::getWithInstruction(), I, llvm::CmpInst::ICMP_ULT, llvm::isGuaranteedNotToBeUndef(), llvm::InstCombiner::isKnownToBeAPowerOfTwo(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_Negative(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), narrowUDivURem(), llvm::InstCombiner::replaceInstUsesWith(), llvm::simplifyICmpInst(), llvm::simplifyURemInst(), llvm::InstCombiner::SQ, llvm::Sub, and X.
Instruction * InstCombinerImpl::visitVAEndInst | ( | VAEndInst & | I | ) |
Definition at line 816 of file InstCombineCalls.cpp.
References I, II, and removeTriviallyEmptyRange().
Instruction * InstCombinerImpl::visitXor | ( | BinaryOperator & | I | ) |
Definition at line 5152 of file InstCombineAndOrXor.cpp.
References A, assert(), B, llvm::InstCombiner::Builder, llvm::CallingConv::C, canonicalizeAbs(), canonicalizeLogicFirst(), llvm::CallInst::Create(), llvm::SelectInst::Create(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateFNeg(), llvm::IRBuilderBase::CreateFreeze(), llvm::IRBuilderBase::CreateIsNotNeg(), llvm::IRBuilderBase::CreateLShr(), llvm::BinaryOperator::CreateNot(), llvm::IRBuilderBase::CreateNot(), llvm::IRBuilderBase::CreateOr(), llvm::IRBuilderBase::CreateXor(), D, F, foldBinOpIntoSelectOrPhi(), foldBinOpShiftWithShift(), foldBinopWithPhiOperands(), foldBitwiseLogicWithIntrinsics(), foldUsingDistributiveLaws(), foldVectorBinop(), foldXorToXor(), llvm::APInt::getAllOnes(), llvm::Constant::getAllOnesValue(), llvm::Type::getFltSemantics(), llvm::IRBuilderBase::GetInsertBlock(), llvm::ConstantExpr::getNot(), llvm::Intrinsic::getOrInsertDeclaration(), llvm::BasicBlock::getParent(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::IRBuilderBase::getTrue(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::SimplifyQuery::getWithInstruction(), llvm::ConstantExpr::getXor(), llvm::Function::hasFnAttribute(), llvm::Value::hasOneUse(), llvm::APFloatBase::hasSignBitInMSB(), I, II, llvm::Type::isFloatingPointTy(), llvm::isGuaranteedNotToBeUndef(), llvm::InstCombiner::isKnownToBeAPowerOfTwo(), llvm::APInt::isSignMask(), llvm::Constant::isZeroValue(), LHS, llvm::APInt::lshr(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_APIntAllowPoison(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_c_Xor(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ConstantExpr(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_DisjointOr(), llvm::PatternMatch::m_ElementWiseBitCast(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_LogicalAnd(), llvm::PatternMatch::m_LogicalOr(), llvm::PatternMatch::m_LShr(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_One(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_SignMask(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_TruncOrSelf(), llvm::PatternMatch::m_Unless(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::InstCombiner::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::Constant::mergeUndefsWith(), reassociateForUses(), llvm::InstCombiner::replaceInstUsesWith(), llvm::Constant::replaceUndefsWith(), RHS, llvm::APInt::shl(), SimplifyAssociativeOrCommutative(), SimplifyDemandedInstructionBits(), llvm::simplifyXorInst(), llvm::InstCombiner::SQ, std::swap(), llvm::Value::takeName(), visitMaskedMerge(), X, llvm::Xor, and Y.
Instruction * InstCombinerImpl::visitZExt | ( | ZExtInst & | Zext | ) |
Definition at line 1195 of file InstCombineCasts.cpp.
References A, assert(), llvm::InstCombiner::Builder, llvm::CallingConv::C, canEvaluateZExtd(), commonCastTransforms(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateTrunc(), llvm::IRBuilderBase::CreateVScale(), llvm::IRBuilderBase::CreateZExt(), llvm::dbgs(), llvm::InstCombiner::DT, EvaluateInDifferentType(), llvm::Function::getFnAttribute(), llvm::Instruction::getFunction(), llvm::APInt::getHighBitsSet(), llvm::APInt::getLowBitsSet(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), getScalarSizeInBits(), llvm::Value::getType(), llvm::Attribute::getVScaleRangeMax(), llvm::SimplifyQuery::getWithInstruction(), llvm::Function::hasFnAttribute(), llvm::Instruction::hasNonNeg(), llvm::Value::hasOneUse(), llvm::Type::isIntOrIntVectorTy(), llvm::isKnownNonNegative(), LLVM_DEBUG, llvm::Log2_32(), llvm::Log2_64_Ceil(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_Constant(), llvm::MIPatternMatch::m_OneUse(), llvm::PatternMatch::m_Shift(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_VScale(), llvm::PatternMatch::m_Xor(), llvm::InstCombiner::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::replaceAllDbgUsesWith(), llvm::InstCombiner::replaceInstUsesWith(), llvm::Instruction::setNonNeg(), llvm::InstCombiner::SQ, llvm::Instruction::user_back(), and X.