|
LLVM
3.7.0
|
#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/ADT/SetVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/AliasAnalysis.h"#include "llvm/Analysis/ConstantFolding.h"#include "llvm/Analysis/MemoryBuiltins.h"#include "llvm/Analysis/ValueTracking.h"#include "llvm/Analysis/VectorUtils.h"#include "llvm/IR/ConstantRange.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/GetElementPtrTypeIterator.h"#include "llvm/IR/GlobalAlias.h"#include "llvm/IR/Operator.h"#include "llvm/IR/PatternMatch.h"#include "llvm/IR/ValueHandle.h"#include <algorithm>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "instsimplify" |
Enumerations | |
| enum | { RecursionLimit = 3 } |
Functions | |
| STATISTIC (NumExpand,"Number of expansions") | |
| STATISTIC (NumReassoc,"Number of reassociations") | |
| static Value * | SimplifyAndInst (Value *Op0, Value *Op1, const Query &Q, unsigned MaxRecurse) |
| SimplifyAndInst - Given operands for an And, see if we can fold the result. More... | |
| static Value * | SimplifyBinOp (unsigned Opcode, Value *LHS, Value *RHS, const Query &Q, unsigned MaxRecurse) |
| SimplifyBinOp - Given operands for a BinaryOperator, see if we can fold the result. More... | |
| static Value * | SimplifyFPBinOp (unsigned Opcode, Value *LHS, Value *RHS, const FastMathFlags &FMF, const Query &Q, unsigned MaxRecurse) |
| SimplifyFPBinOp - Given operands for a BinaryOperator, see if we can fold the result. More... | |
| static Value * | SimplifyCmpInst (unsigned Predicate, Value *LHS, Value *RHS, const Query &Q, unsigned MaxRecurse) |
| SimplifyCmpInst - Given operands for a CmpInst, see if we can fold the result. More... | |
| static Value * | SimplifyOrInst (Value *Op0, Value *Op1, const Query &Q, unsigned MaxRecurse) |
| SimplifyOrInst - Given operands for an Or, see if we can fold the result. More... | |
| static Value * | SimplifyXorInst (Value *Op0, Value *Op1, const Query &Q, unsigned MaxRecurse) |
| SimplifyXorInst - Given operands for a Xor, see if we can fold the result. More... | |
| static Value * | SimplifyTruncInst (Value *, Type *, const Query &, unsigned) |
| static Constant * | getFalse (Type *Ty) |
| getFalse - For a boolean type, or a vector of boolean type, return false, or a vector with every element false, as appropriate for the type. More... | |
| static Constant * | getTrue (Type *Ty) |
| getTrue - For a boolean type, or a vector of boolean type, return true, or a vector with every element true, as appropriate for the type. More... | |
| static bool | isSameCompare (Value *V, CmpInst::Predicate Pred, Value *LHS, Value *RHS) |
| isSameCompare - Is V equivalent to the comparison "LHS Pred RHS"? More... | |
| static bool | ValueDominatesPHI (Value *V, PHINode *P, const DominatorTree *DT) |
| ValueDominatesPHI - Does the given value dominate the specified phi node? More... | |
| static Value * | ExpandBinOp (unsigned Opcode, Value *LHS, Value *RHS, unsigned OpcToExpand, const Query &Q, unsigned MaxRecurse) |
| ExpandBinOp - Simplify "A op (B op' C)" by distributing op over op', turning it into "(A op B) op' (A op C)". More... | |
| static Value * | SimplifyAssociativeBinOp (unsigned Opc, Value *LHS, Value *RHS, const Query &Q, unsigned MaxRecurse) |
| SimplifyAssociativeBinOp - Generic simplifications for associative binary operations. More... | |
| static Value * | ThreadBinOpOverSelect (unsigned Opcode, Value *LHS, Value *RHS, const Query &Q, unsigned MaxRecurse) |
| ThreadBinOpOverSelect - In the case of a binary operation with a select instruction as an operand, try to simplify the binop by seeing whether evaluating it on both branches of the select results in the same value. More... | |
| static Value * | ThreadCmpOverSelect (CmpInst::Predicate Pred, Value *LHS, Value *RHS, const Query &Q, unsigned MaxRecurse) |
| ThreadCmpOverSelect - In the case of a comparison with a select instruction, try to simplify the comparison by seeing whether both branches of the select result in the same value. More... | |
| static Value * | ThreadBinOpOverPHI (unsigned Opcode, Value *LHS, Value *RHS, const Query &Q, unsigned MaxRecurse) |
| ThreadBinOpOverPHI - In the case of a binary operation with an operand that is a PHI instruction, try to simplify the binop by seeing whether evaluating it on the incoming phi values yields the same result for every value. More... | |
| static Value * | ThreadCmpOverPHI (CmpInst::Predicate Pred, Value *LHS, Value *RHS, const Query &Q, unsigned MaxRecurse) |
| ThreadCmpOverPHI - In the case of a comparison with a PHI instruction, try try to simplify the comparison by seeing whether comparing with all of the incoming phi values yields the same result every time. More... | |
| static Value * | SimplifyAddInst (Value *Op0, Value *Op1, bool isNSW, bool isNUW, const Query &Q, unsigned MaxRecurse) |
| SimplifyAddInst - Given operands for an Add, see if we can fold the result. More... | |
| static Constant * | stripAndComputeConstantOffsets (const DataLayout &DL, Value *&V, bool AllowNonInbounds=false) |
| Compute the base pointer and cumulative constant offsets for V. More... | |
| static Constant * | computePointerDifference (const DataLayout &DL, Value *LHS, Value *RHS) |
| Compute the constant difference between two pointer values. More... | |
| static Value * | SimplifySubInst (Value *Op0, Value *Op1, bool isNSW, bool isNUW, const Query &Q, unsigned MaxRecurse) |
| SimplifySubInst - Given operands for a Sub, see if we can fold the result. More... | |
| static Value * | SimplifyFAddInst (Value *Op0, Value *Op1, FastMathFlags FMF, const Query &Q, unsigned MaxRecurse) |
| Given operands for an FAdd, see if we can fold the result. More... | |
| static Value * | SimplifyFSubInst (Value *Op0, Value *Op1, FastMathFlags FMF, const Query &Q, unsigned MaxRecurse) |
| Given operands for an FSub, see if we can fold the result. More... | |
| static Value * | SimplifyFMulInst (Value *Op0, Value *Op1, FastMathFlags FMF, const Query &Q, unsigned MaxRecurse) |
| Given the operands for an FMul, see if we can fold the result. More... | |
| static Value * | SimplifyMulInst (Value *Op0, Value *Op1, const Query &Q, unsigned MaxRecurse) |
| SimplifyMulInst - Given operands for a Mul, see if we can fold the result. More... | |
| static Value * | SimplifyDiv (Instruction::BinaryOps Opcode, Value *Op0, Value *Op1, const Query &Q, unsigned MaxRecurse) |
| SimplifyDiv - Given operands for an SDiv or UDiv, see if we can fold the result. More... | |
| static Value * | SimplifySDivInst (Value *Op0, Value *Op1, const Query &Q, unsigned MaxRecurse) |
| SimplifySDivInst - Given operands for an SDiv, see if we can fold the result. More... | |
| static Value * | SimplifyUDivInst (Value *Op0, Value *Op1, const Query &Q, unsigned MaxRecurse) |
| SimplifyUDivInst - Given operands for a UDiv, see if we can fold the result. More... | |
| static Value * | SimplifyFDivInst (Value *Op0, Value *Op1, FastMathFlags FMF, const Query &Q, unsigned) |
| static Value * | SimplifyRem (Instruction::BinaryOps Opcode, Value *Op0, Value *Op1, const Query &Q, unsigned MaxRecurse) |
| SimplifyRem - Given operands for an SRem or URem, see if we can fold the result. More... | |
| static Value * | SimplifySRemInst (Value *Op0, Value *Op1, const Query &Q, unsigned MaxRecurse) |
| SimplifySRemInst - Given operands for an SRem, see if we can fold the result. More... | |
| static Value * | SimplifyURemInst (Value *Op0, Value *Op1, const Query &Q, unsigned MaxRecurse) |
| SimplifyURemInst - Given operands for a URem, see if we can fold the result. More... | |
| static Value * | SimplifyFRemInst (Value *Op0, Value *Op1, FastMathFlags FMF, const Query &, unsigned) |
| static bool | isUndefShift (Value *Amount) |
isUndefShift - Returns true if a shift by Amount always yields undef. More... | |
| static Value * | SimplifyShift (unsigned Opcode, Value *Op0, Value *Op1, const Query &Q, unsigned MaxRecurse) |
| SimplifyShift - Given operands for an Shl, LShr or AShr, see if we can fold the result. More... | |
| static Value * | SimplifyRightShift (unsigned Opcode, Value *Op0, Value *Op1, bool isExact, const Query &Q, unsigned MaxRecurse) |
| Given operands for an Shl, LShr or AShr, see if we can fold the result. More... | |
| static Value * | SimplifyShlInst (Value *Op0, Value *Op1, bool isNSW, bool isNUW, const Query &Q, unsigned MaxRecurse) |
| SimplifyShlInst - Given operands for an Shl, see if we can fold the result. More... | |
| static Value * | SimplifyLShrInst (Value *Op0, Value *Op1, bool isExact, const Query &Q, unsigned MaxRecurse) |
| SimplifyLShrInst - Given operands for an LShr, see if we can fold the result. More... | |
| static Value * | SimplifyAShrInst (Value *Op0, Value *Op1, bool isExact, const Query &Q, unsigned MaxRecurse) |
| SimplifyAShrInst - Given operands for an AShr, see if we can fold the result. More... | |
| static Value * | simplifyUnsignedRangeCheck (ICmpInst *ZeroICmp, ICmpInst *UnsignedICmp, bool IsAnd) |
| static Value * | SimplifyAndOfICmps (ICmpInst *Op0, ICmpInst *Op1) |
| static Value * | SimplifyOrOfICmps (ICmpInst *Op0, ICmpInst *Op1) |
| static Type * | GetCompareTy (Value *Op) |
| static Value * | ExtractEquivalentCondition (Value *V, CmpInst::Predicate Pred, Value *LHS, Value *RHS) |
| ExtractEquivalentCondition - Rummage around inside V looking for something equivalent to the comparison "LHS Pred RHS". More... | |
| static Constant * | computePointerICmp (const DataLayout &DL, const TargetLibraryInfo *TLI, CmpInst::Predicate Pred, Value *LHS, Value *RHS) |
| static Value * | SimplifyICmpInst (unsigned Predicate, Value *LHS, Value *RHS, const Query &Q, unsigned MaxRecurse) |
| SimplifyICmpInst - Given operands for an ICmpInst, see if we can fold the result. More... | |
| static Value * | SimplifyFCmpInst (unsigned Predicate, Value *LHS, Value *RHS, FastMathFlags FMF, const Query &Q, unsigned MaxRecurse) |
| SimplifyFCmpInst - Given operands for an FCmpInst, see if we can fold the result. More... | |
| static const Value * | SimplifyWithOpReplaced (Value *V, Value *Op, Value *RepOp, const Query &Q, unsigned MaxRecurse) |
| SimplifyWithOpReplaced - See if V simplifies when its operand Op is replaced with RepOp. More... | |
| static Value * | SimplifySelectInst (Value *CondVal, Value *TrueVal, Value *FalseVal, const Query &Q, unsigned MaxRecurse) |
| SimplifySelectInst - Given operands for a SelectInst, see if we can fold the result. More... | |
| static Value * | SimplifyGEPInst (Type *SrcTy, ArrayRef< Value * > Ops, const Query &Q, unsigned) |
| SimplifyGEPInst - Given operands for an GetElementPtrInst, see if we can fold the result. More... | |
| static Value * | SimplifyInsertValueInst (Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Query &Q, unsigned) |
| SimplifyInsertValueInst - Given operands for an InsertValueInst, see if we can fold the result. More... | |
| static Value * | SimplifyExtractValueInst (Value *Agg, ArrayRef< unsigned > Idxs, const Query &, unsigned) |
| SimplifyExtractValueInst - Given operands for an ExtractValueInst, see if we can fold the result. More... | |
| static Value * | SimplifyExtractElementInst (Value *Vec, Value *Idx, const Query &, unsigned) |
| SimplifyExtractElementInst - Given operands for an ExtractElementInst, see if we can fold the result. More... | |
| static Value * | SimplifyPHINode (PHINode *PN, const Query &Q) |
| SimplifyPHINode - See if we can fold the given phi. If not, returns null. More... | |
| static bool | IsIdempotent (Intrinsic::ID ID) |
| template<typename IterTy > | |
| static Value * | SimplifyIntrinsic (Function *F, IterTy ArgBegin, IterTy ArgEnd, const Query &Q, unsigned MaxRecurse) |
| template<typename IterTy > | |
| static Value * | SimplifyCall (Value *V, IterTy ArgBegin, IterTy ArgEnd, const Query &Q, unsigned MaxRecurse) |
| static bool | replaceAndRecursivelySimplifyImpl (Instruction *I, Value *SimpleV, const TargetLibraryInfo *TLI, const DominatorTree *DT, AssumptionCache *AC) |
| Implementation of recursive simplification through an instructions uses. More... | |
| #define DEBUG_TYPE "instsimplify" |
Definition at line 40 of file InstructionSimplify.cpp.
| anonymous enum |
| Enumerator | |
|---|---|
| RecursionLimit | |
Definition at line 42 of file InstructionSimplify.cpp.
|
static |
Compute the constant difference between two pointer values.
If the difference is not a constant, returns zero.
Definition at line 642 of file InstructionSimplify.cpp.
References llvm::ConstantExpr::getSub(), and stripAndComputeConstantOffsets().
Referenced by SimplifySubInst().
|
static |
Definition at line 1961 of file InstructionSimplify.cpp.
References llvm::ARM_PROC::A, llvm::all_of(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ConstantExpr::getAdd(), GetCompareTy(), llvm::ConstantExpr::getICmp(), llvm::getObjectSize(), llvm::ICmpInst::getSignedPredicate(), llvm::Value::getType(), llvm::GetUnderlyingObjects(), llvm::ConstantInt::getValue(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::isKnownNonNull(), llvm::APInt::isNegative(), llvm::isNoAliasCall(), llvm::Constant::isNullValue(), llvm::CmpInst::isTrueWhenEqual(), stripAndComputeConstantOffsets(), llvm::Value::stripPointerCasts(), and llvm::APInt::ult().
Referenced by SimplifyICmpInst().
|
static |
ExpandBinOp - Simplify "A op (B op' C)" by distributing op over op', turning it into "(A op B) op' (A op C)".
Here "op" is given by Opcode and "op'" is given by OpcodeToExpand, while "A" corresponds to LHS and "B op' C" to RHS. Also performs the transform "(A op' B) op C" -> "(A op C) op' (B op C)". Returns the simplified value, or null if no simplification was performed.
Definition at line 139 of file InstructionSimplify.cpp.
References llvm::ARM_PROC::A, llvm::Instruction::isCommutative(), and llvm::SimplifyBinOp().
Referenced by SimplifyAndInst(), SimplifyMulInst(), and SimplifyOrInst().
|
static |
ExtractEquivalentCondition - Rummage around inside V looking for something equivalent to the comparison "LHS Pred RHS".
Return such a value if found, otherwise return null. Helper function for analyzing max/min idioms.
Definition at line 1916 of file InstructionSimplify.cpp.
References llvm::dyn_cast(), llvm::SelectInst::getCondition(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::CmpInst::getSwappedPredicate(), and SI.
Referenced by SimplifyICmpInst().
Definition at line 1909 of file InstructionSimplify.cpp.
References llvm::Value::getType(), and llvm::CmpInst::makeCmpResultType().
Referenced by computePointerICmp(), SimplifyFCmpInst(), and SimplifyICmpInst().
getFalse - For a boolean type, or a vector of boolean type, return false, or a vector with every element false, as appropriate for the type.
Definition at line 75 of file InstructionSimplify.cpp.
References llvm::Constant::getNullValue(), llvm::Type::getScalarType(), and llvm::Type::isIntegerTy().
Referenced by reuseTableCompare(), SimplifyAndOfICmps(), SimplifyICmpInst(), simplifyUnsignedRangeCheck(), and ThreadCmpOverSelect().
getTrue - For a boolean type, or a vector of boolean type, return true, or a vector with every element true, as appropriate for the type.
Definition at line 83 of file InstructionSimplify.cpp.
References llvm::Constant::getAllOnesValue(), llvm::Type::getScalarType(), and llvm::Type::isIntegerTy().
Referenced by reuseTableCompare(), SimplifyICmpInst(), SimplifyOrOfICmps(), simplifyUnsignedRangeCheck(), and ThreadCmpOverSelect().
|
static |
Definition at line 3761 of file InstructionSimplify.cpp.
Referenced by SimplifyIntrinsic().
|
static |
isSameCompare - Is V equivalent to the comparison "LHS Pred RHS"?
Definition at line 90 of file InstructionSimplify.cpp.
References llvm::dyn_cast(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), and llvm::CmpInst::getSwappedPredicate().
Referenced by ThreadCmpOverSelect().
isUndefShift - Returns true if a shift by Amount always yields undef.
Definition at line 1283 of file InstructionSimplify.cpp.
References llvm::dyn_cast(), llvm::Constant::getAggregateElement(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), and I.
Referenced by SimplifyShift().
|
static |
Implementation of recursive simplification through an instructions uses.
This is the common implementation of the recursive simplification routines. If we have a pre-simplified value in 'SimpleV', that is forcibly used to replace the instruction 'I'. Otherwise, we simply add 'I' to the list of instructions to process and attempt to simplify it using InstructionSimplify.
This routine returns 'true' only when it simplifies something. The passed in simplified value does not count toward this.
Definition at line 4044 of file InstructionSimplify.cpp.
References llvm::DL, llvm::Instruction::eraseFromParent(), llvm::Module::getDataLayout(), llvm::Instruction::getModule(), llvm::Instruction::getParent(), llvm::SetVector< T, SmallVector< T, N >, SmallSet< T, N > >::insert(), llvm::Value::replaceAllUsesWith(), llvm::JumpTable::Simplified, llvm::SimplifyInstruction(), llvm::SetVector< T, SmallVector< T, N >, SmallSet< T, N > >::size(), and llvm::Value::users().
Referenced by llvm::recursivelySimplifyInstruction(), and llvm::replaceAndRecursivelySimplify().
|
static |
SimplifyAddInst - Given operands for an Add, see if we can fold the result.
If not, this returns null.
i1 add -> xor.
Definition at line 529 of file InstructionSimplify.cpp.
References llvm::ConstantFoldInstOperands(), llvm::Constant::getAllOnesValue(), llvm::Value::getType(), llvm::Type::isIntegerTy(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), SimplifyAssociativeBinOp(), llvm::SimplifyXorInst(), std::swap(), and Y.
Referenced by llvm::SimplifyAddInst().
|
static |
SimplifyAndInst - Given operands for an And, see if we can fold the result.
If not, this returns null.
Definition at line 1559 of file InstructionSimplify.cpp.
References llvm::ARM_PROC::A, llvm::APIntOps::And(), llvm::ConstantFoldInstOperands(), ExpandBinOp(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::isKnownToBeAPowerOfTwo(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_Neg(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::APIntOps::Or(), SimplifyAndOfICmps(), SimplifyAssociativeBinOp(), std::swap(), ThreadBinOpOverPHI(), ThreadBinOpOverSelect(), and llvm::APIntOps::Xor().
Referenced by llvm::SimplifyAndInst().
Definition at line 1507 of file InstructionSimplify.cpp.
References getFalse(), llvm::User::getOperand(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), simplifyUnsignedRangeCheck(), and X.
Referenced by SimplifyAndInst().
|
static |
SimplifyAShrInst - Given operands for an AShr, see if we can fold the result.
If not, this returns null.
Definition at line 1432 of file InstructionSimplify.cpp.
References llvm::ComputeNumSignBits(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_NSWShl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), SimplifyRightShift(), and X.
Referenced by llvm::SimplifyAShrInst().
|
static |
SimplifyAssociativeBinOp - Generic simplifications for associative binary operations.
Returns the simpler value, or null if none was found.
Definition at line 198 of file InstructionSimplify.cpp.
References llvm::ARM_PROC::A, llvm::dyn_cast(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Instruction::isAssociative(), llvm::Instruction::isCommutative(), and llvm::SimplifyBinOp().
Referenced by SimplifyAddInst(), SimplifyAndInst(), SimplifyBinOp(), SimplifyMulInst(), SimplifyOrInst(), and SimplifyXorInst().
|
static |
SimplifyBinOp - Given operands for a BinaryOperator, see if we can fold the result.
If not, this returns null.
Definition at line 3643 of file InstructionSimplify.cpp.
References llvm::APIntOps::And(), llvm::ConstantFoldInstOperands(), llvm::Value::getType(), llvm::Instruction::isAssociative(), llvm::APIntOps::Or(), llvm::SimplifyAddInst(), llvm::SimplifyAndInst(), llvm::SimplifyAShrInst(), SimplifyAssociativeBinOp(), llvm::SimplifyFAddInst(), llvm::SimplifyFDivInst(), llvm::SimplifyFMulInst(), llvm::SimplifyFRemInst(), llvm::SimplifyFSubInst(), llvm::SimplifyLShrInst(), llvm::SimplifyMulInst(), llvm::SimplifyOrInst(), llvm::SimplifySDivInst(), llvm::SimplifyShlInst(), llvm::SimplifySRemInst(), llvm::SimplifySubInst(), llvm::SimplifyUDivInst(), llvm::SimplifyURemInst(), llvm::SimplifyXorInst(), ThreadBinOpOverPHI(), ThreadBinOpOverSelect(), and llvm::APIntOps::Xor().
Referenced by llvm::SimplifyBinOp().
|
static |
Definition at line 3833 of file InstructionSimplify.cpp.
References llvm::canConstantFoldCallTo(), llvm::ConstantFoldCall(), llvm::dyn_cast(), F(), llvm::UndefValue::get(), llvm::FunctionType::getReturnType(), llvm::Value::getType(), I, llvm::Function::isIntrinsic(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SmallVectorImpl< T >::reserve(), llvm::MipsISD::Ret, and SimplifyIntrinsic().
Referenced by llvm::SimplifyCall().
|
static |
SimplifyCmpInst - Given operands for a CmpInst, see if we can fold the result.
Definition at line 3746 of file InstructionSimplify.cpp.
References llvm::CmpInst::isIntPredicate(), llvm::SimplifyFCmpInst(), and llvm::SimplifyICmpInst().
Referenced by llvm::SimplifyCmpInst().
|
static |
SimplifyDiv - Given operands for an SDiv or UDiv, see if we can fold the result.
If not, this returns null.
Definition at line 994 of file InstructionSimplify.cpp.
References llvm::ConstantFoldInstOperands(), llvm::ConstantInt::get(), llvm::UndefValue::get(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::OverflowingBinaryOperator::hasNoSignedWrap(), llvm::OverflowingBinaryOperator::hasNoUnsignedWrap(), llvm::Type::isIntegerTy(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SRem(), llvm::PatternMatch::m_UDiv(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_URem(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), std::swap(), ThreadBinOpOverPHI(), ThreadBinOpOverSelect(), llvm::APInt::umul_ov(), X, and Y.
Referenced by SimplifySDivInst(), and SimplifyUDivInst().
|
static |
SimplifyExtractElementInst - Given operands for an ExtractElementInst, see if we can fold the result.
If not, this returns null.
Definition at line 3561 of file InstructionSimplify.cpp.
References llvm::ConstantFoldExtractElementInstruction(), llvm::findScalarElement(), llvm::UndefValue::get(), llvm::Value::getType(), and llvm::Type::getVectorElementType().
Referenced by llvm::SimplifyExtractElementInst().
|
static |
SimplifyExtractValueInst - Given operands for an ExtractValueInst, see if we can fold the result.
If not, this returns null.
Definition at line 3526 of file InstructionSimplify.cpp.
References llvm::ConstantFoldExtractValueInstruction(), llvm::dyn_cast(), fuzzer::min(), llvm::ArrayRef< T >::size(), and llvm::ArrayRef< T >::slice().
Referenced by llvm::SimplifyExtractValueInst().
|
static |
Given operands for an FAdd, see if we can fold the result.
If not, this returns null.
Definition at line 788 of file InstructionSimplify.cpp.
References llvm::CannotBeNegativeZero(), llvm::ConstantFoldInstOperands(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::Instruction::hasNoInfs(), llvm::Instruction::hasNoNaNs(), llvm::PatternMatch::m_AnyZero(), llvm::PatternMatch::m_FSub(), llvm::PatternMatch::m_NegZero(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::FastMathFlags::noInfs(), llvm::FastMathFlags::noNaNs(), llvm::FastMathFlags::noSignedZeros(), and std::swap().
Referenced by llvm::SimplifyFAddInst().
|
static |
SimplifyFCmpInst - Given operands for an FCmpInst, see if we can fold the result.
If not, this returns null.
Definition at line 3049 of file InstructionSimplify.cpp.
References llvm::CannotBeOrderedLessThanZero(), llvm::ConstantFoldCompareInstOperands(), llvm::CmpInst::FCMP_FALSE, llvm::CmpInst::FCMP_OGT, llvm::CmpInst::FCMP_OLT, llvm::CmpInst::FCMP_ORD, llvm::CmpInst::FCMP_TRUE, llvm::CmpInst::FCMP_UGE, llvm::CmpInst::FCMP_ULE, llvm::CmpInst::FCMP_UNO, llvm::ConstantInt::get(), GetCompareTy(), llvm::ConstantInt::getFalse(), llvm::CmpInst::getSwappedPredicate(), llvm::ConstantInt::getTrue(), llvm::CmpInst::isFalseWhenEqual(), llvm::CmpInst::isFPPredicate(), llvm::CmpInst::isOrdered(), llvm::CmpInst::isTrueWhenEqual(), llvm::CmpInst::isUnordered(), llvm::FastMathFlags::noNaNs(), std::swap(), ThreadCmpOverPHI(), and ThreadCmpOverSelect().
Referenced by llvm::SimplifyFCmpInst().
|
static |
Definition at line 1114 of file InstructionSimplify.cpp.
References llvm::ConstantFP::get(), llvm::BinaryOperator::getFNegArgument(), llvm::Value::getType(), llvm::BinaryOperator::isFNeg(), llvm::PatternMatch::m_AnyZero(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::match(), llvm::FastMathFlags::noNaNs(), and llvm::FastMathFlags::noSignedZeros().
Referenced by llvm::SimplifyFDivInst().
|
static |
Given the operands for an FMul, see if we can fold the result.
Definition at line 866 of file InstructionSimplify.cpp.
References llvm::ConstantFoldInstOperands(), llvm::PatternMatch::m_AnyZero(), llvm::PatternMatch::m_FPOne(), llvm::PatternMatch::match(), llvm::FastMathFlags::noNaNs(), llvm::FastMathFlags::noSignedZeros(), and std::swap().
Referenced by llvm::SimplifyFMulInst().
|
static |
SimplifyFPBinOp - Given operands for a BinaryOperator, see if we can fold the result.
If not, this returns null. In contrast to SimplifyBinOp, try to use FastMathFlag when folding the result. In case we don't need FastMathFlags, simply fall to SimplifyBinOp.
Definition at line 3712 of file InstructionSimplify.cpp.
References llvm::SimplifyBinOp(), llvm::SimplifyFAddInst(), llvm::SimplifyFMulInst(), and llvm::SimplifyFSubInst().
Referenced by llvm::SimplifyFPBinOp().
|
static |
Definition at line 1254 of file InstructionSimplify.cpp.
References llvm::PatternMatch::m_AnyZero(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::match(), llvm::FastMathFlags::noNaNs(), and llvm::FastMathFlags::noSignedZeros().
Referenced by llvm::SimplifyFRemInst().
|
static |
Given operands for an FSub, see if we can fold the result.
If not, this returns null.
Definition at line 830 of file InstructionSimplify.cpp.
References llvm::CannotBeNegativeZero(), llvm::ConstantFoldInstOperands(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::PatternMatch::m_AnyZero(), llvm::PatternMatch::m_FSub(), llvm::PatternMatch::m_NegZero(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::FastMathFlags::noNaNs(), llvm::FastMathFlags::noSignedZeros(), and X.
Referenced by llvm::SimplifyFSubInst().
|
static |
SimplifyGEPInst - Given operands for an GetElementPtrInst, see if we can fold the result.
If not, this returns null.
Definition at line 3396 of file InstructionSimplify.cpp.
References llvm::VectorType::get(), llvm::PointerType::get(), llvm::UndefValue::get(), llvm::ConstantExpr::getGetElementPtr(), llvm::GetElementPtrInst::getIndexedType(), llvm::Constant::getNullValue(), llvm::Intrinsic::getType(), llvm::Value::getType(), llvm::Type::isSized(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_SDiv(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), P, llvm::ArrayRef< T >::size(), and llvm::ArrayRef< T >::slice().
Referenced by llvm::SimplifyGEPInst().
|
static |
SimplifyICmpInst - Given operands for an ICmpInst, see if we can fold the result.
If not, this returns null.
Definition at line 2133 of file InstructionSimplify.cpp.
References llvm::ARM_PROC::A, llvm::APInt::abs(), llvm::APInt::ashr(), llvm::CmpInst::BAD_ICMP_PREDICATE, llvm::computeKnownBits(), computePointerICmp(), llvm::ComputeSignBit(), llvm::ConstantFoldCompareInstOperands(), llvm::ConstantRange::contains(), llvm::APInt::countLeadingOnes(), llvm::APInt::countLeadingZeros(), llvm::APInt::countTrailingZeros(), llvm::dyn_cast(), ExtractEquivalentCondition(), llvm::ConstantInt::get(), llvm::APInt::getAllOnesValue(), llvm::ConstantInt::getBitWidth(), llvm::ConstantExpr::getCast(), GetCompareTy(), llvm::Value::getContext(), llvm::ConstantInt::getFalse(), getFalse(), llvm::ConstantExpr::getGetElementPtr(), llvm::ConstantExpr::getICmp(), llvm::ConstantExpr::getIntToPtr(), llvm::CmpInst::getInversePredicate(), llvm::Constant::getNullValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarType(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), llvm::ICmpInst::getSignedPredicate(), llvm::CmpInst::getSwappedPredicate(), llvm::ConstantInt::getTrue(), getTrue(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::ICmpInst::getUnsignedPredicate(), llvm::ConstantInt::getValue(), llvm::BinaryOperator::hasNoSignedWrap(), llvm::BinaryOperator::hasNoUnsignedWrap(), 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::ConstantRange::inverse(), llvm::APInt::isAllOnesValue(), llvm::ConstantRange::isEmptySet(), llvm::ICmpInst::isEquality(), llvm::BinaryOperator::isExact(), llvm::ConstantRange::isFullSet(), llvm::Type::isIntegerTy(), llvm::CmpInst::isIntPredicate(), llvm::isKnownNonZero(), llvm::Constant::isMinSignedValue(), llvm::ConstantInt::isNegative(), llvm::Type::isPointerTy(), llvm::APInt::isPowerOf2(), llvm::APInt::isSignBit(), llvm::CmpInst::isSigned(), llvm::CmpInst::isTrueWhenEqual(), llvm::CmpInst::isUnsigned(), llvm::ConstantInt::isZero(), llvm_unreachable, llvm::APInt::lshr(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_CombineOr(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Neg(), llvm::PatternMatch::m_NSWShl(), llvm::PatternMatch::m_NUWShl(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_SDiv(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_SMax(), llvm::PatternMatch::m_SMin(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SRem(), llvm::PatternMatch::m_UDiv(), llvm::PatternMatch::m_UMax(), llvm::PatternMatch::m_UMin(), llvm::PatternMatch::m_URem(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::m_ZExt(), llvm::ICmpInst::makeConstantRange(), llvm::PatternMatch::match(), llvm::Null, P, llvm::APInt::sdiv(), llvm::APInt::sgt(), llvm::APInt::shl(), llvm::SimplifyICmpInst(), std::swap(), ThreadCmpOverPHI(), ThreadCmpOverSelect(), llvm::APInt::udiv(), llvm::APInt::ult(), and Y.
Referenced by llvm::SimplifyICmpInst().
|
static |
SimplifyInsertValueInst - Given operands for an InsertValueInst, see if we can fold the result.
If not, this returns null.
Definition at line 3489 of file InstructionSimplify.cpp.
References llvm::ConstantFoldInsertValueInstruction(), llvm::Value::getType(), llvm::PatternMatch::m_Undef(), and llvm::PatternMatch::match().
Referenced by llvm::SimplifyInsertValueInst().
|
static |
Definition at line 3778 of file InstructionSimplify.cpp.
References llvm::UndefValue::get(), llvm::Function::getIntrinsicID(), llvm::Constant::getNullValue(), llvm::Function::getReturnType(), IsIdempotent(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Zero(), and llvm::PatternMatch::match().
Referenced by SimplifyCall().
|
static |
SimplifyLShrInst - Given operands for an LShr, see if we can fold the result.
If not, this returns null.
Definition at line 1407 of file InstructionSimplify.cpp.
References llvm::PatternMatch::m_NUWShl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), SimplifyRightShift(), and X.
Referenced by llvm::SimplifyLShrInst().
|
static |
SimplifyMulInst - Given operands for a Mul, see if we can fold the result.
If not, this returns null.
Definition at line 894 of file InstructionSimplify.cpp.
References llvm::ConstantFoldInstOperands(), ExpandBinOp(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::Type::isIntegerTy(), llvm::PatternMatch::m_Exact(), llvm::PatternMatch::m_IDiv(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::SimplifyAndInst(), SimplifyAssociativeBinOp(), std::swap(), ThreadBinOpOverPHI(), ThreadBinOpOverSelect(), and X.
Referenced by llvm::SimplifyMulInst().
|
static |
SimplifyOrInst - Given operands for an Or, see if we can fold the result.
If not, this returns null.
Definition at line 1718 of file InstructionSimplify.cpp.
References llvm::ARM_PROC::A, llvm::APIntOps::And(), llvm::ConstantFoldInstOperands(), llvm::dyn_cast(), ExpandBinOp(), llvm::Constant::getAllOnesValue(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::APIntOps::Or(), SimplifyAssociativeBinOp(), SimplifyOrOfICmps(), std::swap(), ThreadBinOpOverPHI(), ThreadBinOpOverSelect(), and llvm::NVPTX::PTXLdStInstCode::V2.
Referenced by llvm::SimplifyOrInst().
Definition at line 1666 of file InstructionSimplify.cpp.
References llvm::User::getOperand(), getTrue(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), simplifyUnsignedRangeCheck(), and X.
Referenced by SimplifyOrInst().
SimplifyPHINode - See if we can fold the given phi. If not, returns null.
Definition at line 3592 of file InstructionSimplify.cpp.
References llvm::UndefValue::get(), llvm::Value::getType(), llvm::PHINode::incoming_values(), and ValueDominatesPHI().
Referenced by llvm::SimplifyInstruction().
|
static |
SimplifyRem - Given operands for an SRem or URem, see if we can fold the result.
If not, this returns null.
Definition at line 1159 of file InstructionSimplify.cpp.
References llvm::ConstantFoldInstOperands(), llvm::UndefValue::get(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::Type::isIntegerTy(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SRem(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_URem(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), ThreadBinOpOverPHI(), and ThreadBinOpOverSelect().
Referenced by SimplifySRemInst(), and SimplifyURemInst().
|
static |
Given operands for an Shl, LShr or AShr, see if we can fold the result.
If not, this returns null.
Definition at line 1349 of file InstructionSimplify.cpp.
References llvm::computeKnownBits(), llvm::Constant::getNullValue(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::match(), and SimplifyShift().
Referenced by SimplifyAShrInst(), and SimplifyLShrInst().
|
static |
SimplifySDivInst - Given operands for an SDiv, see if we can fold the result.
If not, this returns null.
Definition at line 1080 of file InstructionSimplify.cpp.
References SimplifyDiv().
Referenced by llvm::SimplifySDivInst().
|
static |
SimplifySelectInst - Given operands for a SelectInst, see if we can fold the result.
If not, this returns null.
Definition at line 3258 of file InstructionSimplify.cpp.
References llvm::APInt::getSignBit(), llvm::Value::getType(), 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::APInt::isMaxSignedValue(), llvm::APInt::isMaxValue(), llvm::APInt::isMinSignedValue(), llvm::APInt::isMinValue(), llvm::APInt::isPowerOf2(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), SimplifyWithOpReplaced(), X, and Y.
Referenced by llvm::SimplifySelectInst().
|
static |
SimplifyShift - Given operands for an Shl, LShr or AShr, see if we can fold the result.
If not, this returns null.
Definition at line 1311 of file InstructionSimplify.cpp.
References llvm::ConstantFoldInstOperands(), llvm::UndefValue::get(), llvm::Value::getType(), isUndefShift(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), ThreadBinOpOverPHI(), and ThreadBinOpOverSelect().
Referenced by SimplifyRightShift(), and SimplifyShlInst().
|
static |
SimplifyShlInst - Given operands for an Shl, see if we can fold the result.
If not, this returns null.
Definition at line 1380 of file InstructionSimplify.cpp.
References llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::PatternMatch::m_Exact(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), SimplifyShift(), and X.
Referenced by llvm::SimplifyShlInst().
|
static |
SimplifySRemInst - Given operands for an SRem, see if we can fold the result.
If not, this returns null.
Definition at line 1220 of file InstructionSimplify.cpp.
References SimplifyRem().
Referenced by llvm::SimplifySRemInst().
|
static |
SimplifySubInst - Given operands for a Sub, see if we can fold the result.
If not, this returns null.
Definition at line 661 of file InstructionSimplify.cpp.
References computePointerDifference(), llvm::ConstantFoldInstOperands(), llvm::UndefValue::get(), llvm::ConstantExpr::getIntegerCast(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::Type::isIntegerTy(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::SimplifyBinOp(), llvm::SimplifyTruncInst(), llvm::SimplifyXorInst(), X, and Y.
Referenced by llvm::SimplifySubInst().
Definition at line 3624 of file InstructionSimplify.cpp.
References llvm::ConstantFoldInstOperands().
Referenced by llvm::SimplifyTruncInst().
|
static |
SimplifyUDivInst - Given operands for a UDiv, see if we can fold the result.
If not, this returns null.
Definition at line 1098 of file InstructionSimplify.cpp.
References SimplifyDiv().
Referenced by llvm::SimplifyUDivInst().
|
static |
Definition at line 1464 of file InstructionSimplify.cpp.
References getFalse(), llvm::CmpInst::getSwappedPredicate(), getTrue(), llvm::Value::getType(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_ULT, llvm::ICmpInst::isEquality(), llvm::CmpInst::isUnsigned(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), X, and Y.
Referenced by SimplifyAndOfICmps(), and SimplifyOrOfICmps().
|
static |
SimplifyURemInst - Given operands for a URem, see if we can fold the result.
If not, this returns null.
Definition at line 1238 of file InstructionSimplify.cpp.
References SimplifyRem().
Referenced by llvm::SimplifyURemInst().
|
static |
SimplifyWithOpReplaced - See if V simplifies when its operand Op is replaced with RepOp.
Definition at line 3174 of file InstructionSimplify.cpp.
References llvm::ConstantFoldCompareInstOperands(), llvm::ConstantFoldInstOperands(), llvm::ConstantFoldLoadFromConstPtr(), llvm::dyn_cast(), I, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SimplifyBinOp(), llvm::SimplifyCmpInst(), and llvm::SmallVectorTemplateCommon< T >::size().
Referenced by SimplifySelectInst().
|
static |
SimplifyXorInst - Given operands for a Xor, see if we can fold the result.
If not, this returns null.
Definition at line 1854 of file InstructionSimplify.cpp.
References llvm::ConstantFoldInstOperands(), llvm::Constant::getAllOnesValue(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), SimplifyAssociativeBinOp(), std::swap(), and llvm::APIntOps::Xor().
Referenced by llvm::SimplifyXorInst().
| STATISTIC | ( | NumExpand | , |
| "Number of expansions" | |||
| ) |
| STATISTIC | ( | NumReassoc | , |
| "Number of reassociations" | |||
| ) |
|
static |
Compute the base pointer and cumulative constant offsets for V.
This strips all constant offsets off of V, leaving it the base pointer, and accumulates the total constant offset applied in the returned constant. It returns 0 if V is not a pointer, and returns the constant '0' if there are no constant offsets applied.
This is very similar to GetPointerBaseWithConstantOffset except it doesn't follow non-inbounds geps. This allows it to remain usable for icmp ult/etc. folding.
Definition at line 603 of file InstructionSimplify.cpp.
References GEP, llvm::ConstantInt::get(), llvm::DataLayout::getIntPtrType(), llvm::APInt::getNullValue(), llvm::Operator::getOpcode(), llvm::Type::getScalarType(), llvm::ConstantVector::getSplat(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::Type::isPointerTy(), and llvm::Type::isVectorTy().
Referenced by computePointerDifference(), and computePointerICmp().
|
static |
ThreadBinOpOverPHI - In the case of a binary operation with an operand that is a PHI instruction, try to simplify the binop by seeing whether evaluating it on the incoming phi values yields the same result for every value.
If so returns the common value, otherwise returns null.
Definition at line 451 of file InstructionSimplify.cpp.
References llvm::PHINode::incoming_values(), llvm::SimplifyBinOp(), and ValueDominatesPHI().
Referenced by SimplifyAndInst(), SimplifyBinOp(), SimplifyDiv(), SimplifyMulInst(), SimplifyOrInst(), SimplifyRem(), and SimplifyShift().
|
static |
ThreadBinOpOverSelect - In the case of a binary operation with a select instruction as an operand, try to simplify the binop by seeing whether evaluating it on both branches of the select results in the same value.
Returns the common value if so, otherwise returns null.
Definition at line 297 of file InstructionSimplify.cpp.
References llvm::dyn_cast(), llvm::SelectInst::getFalseValue(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::SelectInst::getTrueValue(), llvm::Instruction::isCommutative(), SI, llvm::JumpTable::Simplified, and llvm::SimplifyBinOp().
Referenced by SimplifyAndInst(), SimplifyBinOp(), SimplifyDiv(), SimplifyMulInst(), SimplifyOrInst(), SimplifyRem(), and SimplifyShift().
|
static |
ThreadCmpOverPHI - In the case of a comparison with a PHI instruction, try try to simplify the comparison by seeing whether comparing with all of the incoming phi values yields the same result every time.
If so returns the common result, otherwise returns null.
Definition at line 493 of file InstructionSimplify.cpp.
References llvm::CmpInst::getSwappedPredicate(), llvm::PHINode::incoming_values(), llvm::SimplifyCmpInst(), std::swap(), and ValueDominatesPHI().
Referenced by SimplifyFCmpInst(), and SimplifyICmpInst().
|
static |
ThreadCmpOverSelect - In the case of a comparison with a select instruction, try to simplify the comparison by seeing whether both branches of the select result in the same value.
Returns the common value if so, otherwise returns null.
Definition at line 369 of file InstructionSimplify.cpp.
References llvm::Constant::getAllOnesValue(), llvm::SelectInst::getCondition(), getFalse(), llvm::SelectInst::getFalseValue(), llvm::CmpInst::getSwappedPredicate(), getTrue(), llvm::SelectInst::getTrueValue(), llvm::Value::getType(), isSameCompare(), llvm::Type::isVectorTy(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), SI, llvm::SimplifyAndInst(), llvm::SimplifyCmpInst(), llvm::SimplifyOrInst(), llvm::SimplifyXorInst(), and std::swap().
Referenced by SimplifyFCmpInst(), and SimplifyICmpInst().
|
static |
ValueDominatesPHI - Does the given value dominate the specified phi node?
Definition at line 104 of file InstructionSimplify.cpp.
References llvm::DominatorTree::dominates(), llvm::dyn_cast(), llvm::Function::getEntryBlock(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), I, and llvm::DominatorTree::isReachableFromEntry().
Referenced by SimplifyPHINode(), ThreadBinOpOverPHI(), and ThreadCmpOverPHI().
1.8.6