#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/CaptureTracking.h"
#include "llvm/Analysis/CmpInstAnalysis.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/InstSimplifyFolder.h"
#include "llvm/Analysis/LoopAnalysisManager.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/OverflowInstAnalysis.h"
#include "llvm/Analysis/TargetLibraryInfo.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/InstrTypes.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/Statepoint.h"
#include "llvm/Support/KnownBits.h"
#include <algorithm>
#include <optional>
usingnamespacellvm;
usingnamespacellvm::PatternMatch;
#define DEBUG_TYPE …
enum { … };
STATISTIC(NumExpand, "Number of expansions");
STATISTIC(NumReassoc, "Number of reassociations");
static Value *simplifyAndInst(Value *, Value *, const SimplifyQuery &,
unsigned);
static Value *simplifyUnOp(unsigned, Value *, const SimplifyQuery &, unsigned);
static Value *simplifyFPUnOp(unsigned, Value *, const FastMathFlags &,
const SimplifyQuery &, unsigned);
static Value *simplifyBinOp(unsigned, Value *, Value *, const SimplifyQuery &,
unsigned);
static Value *simplifyBinOp(unsigned, Value *, Value *, const FastMathFlags &,
const SimplifyQuery &, unsigned);
static Value *simplifyCmpInst(unsigned, Value *, Value *, const SimplifyQuery &,
unsigned);
static Value *simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
const SimplifyQuery &Q, unsigned MaxRecurse);
static Value *simplifyOrInst(Value *, Value *, const SimplifyQuery &, unsigned);
static Value *simplifyXorInst(Value *, Value *, const SimplifyQuery &,
unsigned);
static Value *simplifyCastInst(unsigned, Value *, Type *, const SimplifyQuery &,
unsigned);
static Value *simplifyGEPInst(Type *, Value *, ArrayRef<Value *>,
GEPNoWrapFlags, const SimplifyQuery &, unsigned);
static Value *simplifySelectInst(Value *, Value *, Value *,
const SimplifyQuery &, unsigned);
static Value *simplifyInstructionWithOperands(Instruction *I,
ArrayRef<Value *> NewOps,
const SimplifyQuery &SQ,
unsigned MaxRecurse);
static Value *foldSelectWithBinaryOp(Value *Cond, Value *TrueVal,
Value *FalseVal) { … }
static Constant *getFalse(Type *Ty) { … }
static Constant *getTrue(Type *Ty) { … }
static bool isSameCompare(Value *V, CmpInst::Predicate Pred, Value *LHS,
Value *RHS) { … }
static Value *simplifyCmpSelCase(CmpInst::Predicate Pred, Value *LHS,
Value *RHS, Value *Cond,
const SimplifyQuery &Q, unsigned MaxRecurse,
Constant *TrueOrFalse) { … }
static Value *simplifyCmpSelTrueCase(CmpInst::Predicate Pred, Value *LHS,
Value *RHS, Value *Cond,
const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *simplifyCmpSelFalseCase(CmpInst::Predicate Pred, Value *LHS,
Value *RHS, Value *Cond,
const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *handleOtherCmpSelSimplifications(Value *TCmp, Value *FCmp,
Value *Cond,
const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static bool valueDominatesPHI(Value *V, PHINode *P, const DominatorTree *DT) { … }
static Value *expandBinOp(Instruction::BinaryOps Opcode, Value *V,
Value *OtherOp, Instruction::BinaryOps OpcodeToExpand,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
static Value *expandCommutativeBinOp(Instruction::BinaryOps Opcode, Value *L,
Value *R,
Instruction::BinaryOps OpcodeToExpand,
const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *simplifyAssociativeBinOp(Instruction::BinaryOps Opcode,
Value *LHS, Value *RHS,
const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *threadBinOpOverSelect(Instruction::BinaryOps Opcode, Value *LHS,
Value *RHS, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *threadCmpOverSelect(CmpInst::Predicate Pred, Value *LHS,
Value *RHS, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *threadBinOpOverPHI(Instruction::BinaryOps Opcode, Value *LHS,
Value *RHS, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *threadCmpOverPHI(CmpInst::Predicate Pred, Value *LHS, Value *RHS,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
static Constant *foldOrCommuteConstant(Instruction::BinaryOps Opcode,
Value *&Op0, Value *&Op1,
const SimplifyQuery &Q) { … }
static Value *simplifyAddInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
Value *llvm::simplifyAddInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW,
const SimplifyQuery &Query) { … }
static APInt stripAndComputeConstantOffsets(const DataLayout &DL, Value *&V,
bool AllowNonInbounds = false) { … }
static Constant *computePointerDifference(const DataLayout &DL, Value *LHS,
Value *RHS) { … }
static Value *simplifyByDomEq(unsigned Opcode, Value *Op0, Value *Op1,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
static Value *simplifySubInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
Value *llvm::simplifySubInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW,
const SimplifyQuery &Q) { … }
static Value *simplifyMulInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
Value *llvm::simplifyMulInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW,
const SimplifyQuery &Q) { … }
static bool isICmpTrue(ICmpInst::Predicate Pred, Value *LHS, Value *RHS,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
static bool isDivZero(Value *X, Value *Y, const SimplifyQuery &Q,
unsigned MaxRecurse, bool IsSigned) { … }
static Value *simplifyDivRem(Instruction::BinaryOps Opcode, Value *Op0,
Value *Op1, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *simplifyDiv(Instruction::BinaryOps Opcode, Value *Op0, Value *Op1,
bool IsExact, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *simplifyRem(Instruction::BinaryOps Opcode, Value *Op0, Value *Op1,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
static Value *simplifySDivInst(Value *Op0, Value *Op1, bool IsExact,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
Value *llvm::simplifySDivInst(Value *Op0, Value *Op1, bool IsExact,
const SimplifyQuery &Q) { … }
static Value *simplifyUDivInst(Value *Op0, Value *Op1, bool IsExact,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
Value *llvm::simplifyUDivInst(Value *Op0, Value *Op1, bool IsExact,
const SimplifyQuery &Q) { … }
static Value *simplifySRemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
Value *llvm::simplifySRemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { … }
static Value *simplifyURemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
Value *llvm::simplifyURemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { … }
static bool isPoisonShift(Value *Amount, const SimplifyQuery &Q) { … }
static Value *simplifyShift(Instruction::BinaryOps Opcode, Value *Op0,
Value *Op1, bool IsNSW, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *simplifyRightShift(Instruction::BinaryOps Opcode, Value *Op0,
Value *Op1, bool IsExact,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
static Value *simplifyShlInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
Value *llvm::simplifyShlInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW,
const SimplifyQuery &Q) { … }
static Value *simplifyLShrInst(Value *Op0, Value *Op1, bool IsExact,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
Value *llvm::simplifyLShrInst(Value *Op0, Value *Op1, bool IsExact,
const SimplifyQuery &Q) { … }
static Value *simplifyAShrInst(Value *Op0, Value *Op1, bool IsExact,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
Value *llvm::simplifyAShrInst(Value *Op0, Value *Op1, bool IsExact,
const SimplifyQuery &Q) { … }
static Value *simplifyUnsignedRangeCheck(ICmpInst *ZeroICmp,
ICmpInst *UnsignedICmp, bool IsAnd,
const SimplifyQuery &Q) { … }
static Value *simplifyAndOrOfICmpsWithConstants(ICmpInst *Cmp0, ICmpInst *Cmp1,
bool IsAnd) { … }
static Value *simplifyAndOfICmpsWithAdd(ICmpInst *Op0, ICmpInst *Op1,
const InstrInfoQuery &IIQ) { … }
static Value *simplifyAndOrOfICmpsWithCtpop(ICmpInst *Cmp0, ICmpInst *Cmp1,
bool IsAnd) { … }
static Value *simplifyAndOfICmps(ICmpInst *Op0, ICmpInst *Op1,
const SimplifyQuery &Q) { … }
static Value *simplifyOrOfICmpsWithAdd(ICmpInst *Op0, ICmpInst *Op1,
const InstrInfoQuery &IIQ) { … }
static Value *simplifyOrOfICmps(ICmpInst *Op0, ICmpInst *Op1,
const SimplifyQuery &Q) { … }
static Value *simplifyAndOrOfFCmps(const SimplifyQuery &Q, FCmpInst *LHS,
FCmpInst *RHS, bool IsAnd) { … }
static Value *simplifyAndOrOfCmps(const SimplifyQuery &Q, Value *Op0,
Value *Op1, bool IsAnd) { … }
static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
const SimplifyQuery &Q,
bool AllowRefinement,
SmallVectorImpl<Instruction *> *DropFlags,
unsigned MaxRecurse);
static Value *simplifyAndOrWithICmpEq(unsigned Opcode, Value *Op0, Value *Op1,
const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *simplifyLogicOfAddSub(Value *Op0, Value *Op1,
Instruction::BinaryOps Opcode) { … }
static Value *simplifyAndCommutative(Value *Op0, Value *Op1,
const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
Value *llvm::simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { … }
static Value *simplifyOrLogic(Value *X, Value *Y) { … }
static Value *simplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
Value *llvm::simplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { … }
static Value *simplifyXorInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
Value *llvm::simplifyXorInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { … }
static Type *getCompareTy(Value *Op) { … }
static Value *extractEquivalentCondition(Value *V, CmpInst::Predicate Pred,
Value *LHS, Value *RHS) { … }
static bool isAllocDisjoint(const Value *V) { … }
static bool haveNonOverlappingStorage(const Value *V1, const Value *V2) { … }
static Constant *computePointerICmp(CmpInst::Predicate Pred, Value *LHS,
Value *RHS, const SimplifyQuery &Q) { … }
static Value *simplifyICmpOfBools(CmpInst::Predicate Pred, Value *LHS,
Value *RHS, const SimplifyQuery &Q) { … }
static Value *simplifyICmpWithZero(CmpInst::Predicate Pred, Value *LHS,
Value *RHS, const SimplifyQuery &Q) { … }
static Value *simplifyICmpWithConstant(CmpInst::Predicate Pred, Value *LHS,
Value *RHS, const InstrInfoQuery &IIQ) { … }
static Value *simplifyICmpWithBinOpOnLHS(CmpInst::Predicate Pred,
BinaryOperator *LBO, Value *RHS,
const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static bool trySimplifyICmpWithAdds(CmpInst::Predicate Pred, Value *LHS,
Value *RHS, const InstrInfoQuery &IIQ) { … }
static Value *simplifyICmpWithBinOp(CmpInst::Predicate Pred, Value *LHS,
Value *RHS, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *simplifyICmpWithMinMax(CmpInst::Predicate Pred, Value *LHS,
Value *RHS, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *simplifyICmpWithDominatingAssume(CmpInst::Predicate Predicate,
Value *LHS, Value *RHS,
const SimplifyQuery &Q) { … }
static Value *simplifyICmpWithIntrinsicOnLHS(CmpInst::Predicate Pred,
Value *LHS, Value *RHS) { … }
static std::optional<ConstantRange> getRange(Value *V,
const InstrInfoQuery &IIQ) { … }
static Value *simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
Value *llvm::simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
const SimplifyQuery &Q) { … }
static Value *simplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
FastMathFlags FMF, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
Value *llvm::simplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
FastMathFlags FMF, const SimplifyQuery &Q) { … }
static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
const SimplifyQuery &Q,
bool AllowRefinement,
SmallVectorImpl<Instruction *> *DropFlags,
unsigned MaxRecurse) { … }
Value *llvm::simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
const SimplifyQuery &Q,
bool AllowRefinement,
SmallVectorImpl<Instruction *> *DropFlags) { … }
static Value *simplifySelectBitTest(Value *TrueVal, Value *FalseVal, Value *X,
const APInt *Y, bool TrueWhenUnset) { … }
static Value *simplifyCmpSelOfMaxMin(Value *CmpLHS, Value *CmpRHS,
ICmpInst::Predicate Pred, Value *TVal,
Value *FVal) { … }
static Value *simplifySelectWithFakeICmpEq(Value *CmpLHS, Value *CmpRHS,
ICmpInst::Predicate Pred,
Value *TrueVal, Value *FalseVal) { … }
static Value *simplifySelectWithICmpEq(Value *CmpLHS, Value *CmpRHS,
Value *TrueVal, Value *FalseVal,
const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *simplifySelectWithICmpCond(Value *CondVal, Value *TrueVal,
Value *FalseVal,
const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *simplifySelectWithFCmp(Value *Cond, Value *T, Value *F,
const SimplifyQuery &Q) { … }
static Value *simplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
Value *llvm::simplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal,
const SimplifyQuery &Q) { … }
static Value *simplifyGEPInst(Type *SrcTy, Value *Ptr,
ArrayRef<Value *> Indices, GEPNoWrapFlags NW,
const SimplifyQuery &Q, unsigned) { … }
Value *llvm::simplifyGEPInst(Type *SrcTy, Value *Ptr, ArrayRef<Value *> Indices,
GEPNoWrapFlags NW, const SimplifyQuery &Q) { … }
static Value *simplifyInsertValueInst(Value *Agg, Value *Val,
ArrayRef<unsigned> Idxs,
const SimplifyQuery &Q, unsigned) { … }
Value *llvm::simplifyInsertValueInst(Value *Agg, Value *Val,
ArrayRef<unsigned> Idxs,
const SimplifyQuery &Q) { … }
Value *llvm::simplifyInsertElementInst(Value *Vec, Value *Val, Value *Idx,
const SimplifyQuery &Q) { … }
static Value *simplifyExtractValueInst(Value *Agg, ArrayRef<unsigned> Idxs,
const SimplifyQuery &, unsigned) { … }
Value *llvm::simplifyExtractValueInst(Value *Agg, ArrayRef<unsigned> Idxs,
const SimplifyQuery &Q) { … }
static Value *simplifyExtractElementInst(Value *Vec, Value *Idx,
const SimplifyQuery &Q, unsigned) { … }
Value *llvm::simplifyExtractElementInst(Value *Vec, Value *Idx,
const SimplifyQuery &Q) { … }
static Value *simplifyPHINode(PHINode *PN, ArrayRef<Value *> IncomingValues,
const SimplifyQuery &Q) { … }
static Value *simplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
Value *llvm::simplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty,
const SimplifyQuery &Q) { … }
static Value *foldIdentityShuffles(int DestElt, Value *Op0, Value *Op1,
int MaskVal, Value *RootVec,
unsigned MaxRecurse) { … }
static Value *simplifyShuffleVectorInst(Value *Op0, Value *Op1,
ArrayRef<int> Mask, Type *RetTy,
const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
Value *llvm::simplifyShuffleVectorInst(Value *Op0, Value *Op1,
ArrayRef<int> Mask, Type *RetTy,
const SimplifyQuery &Q) { … }
static Constant *foldConstant(Instruction::UnaryOps Opcode, Value *&Op,
const SimplifyQuery &Q) { … }
static Value *simplifyFNegInst(Value *Op, FastMathFlags FMF,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
Value *llvm::simplifyFNegInst(Value *Op, FastMathFlags FMF,
const SimplifyQuery &Q) { … }
static Constant *propagateNaN(Constant *In) { … }
static Constant *simplifyFPOp(ArrayRef<Value *> Ops, FastMathFlags FMF,
const SimplifyQuery &Q,
fp::ExceptionBehavior ExBehavior,
RoundingMode Rounding) { … }
static Value *
simplifyFAddInst(Value *Op0, Value *Op1, FastMathFlags FMF,
const SimplifyQuery &Q, unsigned MaxRecurse,
fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
RoundingMode Rounding = RoundingMode::NearestTiesToEven) { … }
static Value *
simplifyFSubInst(Value *Op0, Value *Op1, FastMathFlags FMF,
const SimplifyQuery &Q, unsigned MaxRecurse,
fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
RoundingMode Rounding = RoundingMode::NearestTiesToEven) { … }
static Value *simplifyFMAFMul(Value *Op0, Value *Op1, FastMathFlags FMF,
const SimplifyQuery &Q, unsigned MaxRecurse,
fp::ExceptionBehavior ExBehavior,
RoundingMode Rounding) { … }
static Value *
simplifyFMulInst(Value *Op0, Value *Op1, FastMathFlags FMF,
const SimplifyQuery &Q, unsigned MaxRecurse,
fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
RoundingMode Rounding = RoundingMode::NearestTiesToEven) { … }
Value *llvm::simplifyFAddInst(Value *Op0, Value *Op1, FastMathFlags FMF,
const SimplifyQuery &Q,
fp::ExceptionBehavior ExBehavior,
RoundingMode Rounding) { … }
Value *llvm::simplifyFSubInst(Value *Op0, Value *Op1, FastMathFlags FMF,
const SimplifyQuery &Q,
fp::ExceptionBehavior ExBehavior,
RoundingMode Rounding) { … }
Value *llvm::simplifyFMulInst(Value *Op0, Value *Op1, FastMathFlags FMF,
const SimplifyQuery &Q,
fp::ExceptionBehavior ExBehavior,
RoundingMode Rounding) { … }
Value *llvm::simplifyFMAFMul(Value *Op0, Value *Op1, FastMathFlags FMF,
const SimplifyQuery &Q,
fp::ExceptionBehavior ExBehavior,
RoundingMode Rounding) { … }
static Value *
simplifyFDivInst(Value *Op0, Value *Op1, FastMathFlags FMF,
const SimplifyQuery &Q, unsigned,
fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
RoundingMode Rounding = RoundingMode::NearestTiesToEven) { … }
Value *llvm::simplifyFDivInst(Value *Op0, Value *Op1, FastMathFlags FMF,
const SimplifyQuery &Q,
fp::ExceptionBehavior ExBehavior,
RoundingMode Rounding) { … }
static Value *
simplifyFRemInst(Value *Op0, Value *Op1, FastMathFlags FMF,
const SimplifyQuery &Q, unsigned,
fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
RoundingMode Rounding = RoundingMode::NearestTiesToEven) { … }
Value *llvm::simplifyFRemInst(Value *Op0, Value *Op1, FastMathFlags FMF,
const SimplifyQuery &Q,
fp::ExceptionBehavior ExBehavior,
RoundingMode Rounding) { … }
static Value *simplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
static Value *simplifyFPUnOp(unsigned Opcode, Value *Op,
const FastMathFlags &FMF, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
Value *llvm::simplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q) { … }
Value *llvm::simplifyUnOp(unsigned Opcode, Value *Op, FastMathFlags FMF,
const SimplifyQuery &Q) { … }
static Value *simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
static Value *simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS,
const FastMathFlags &FMF, const SimplifyQuery &Q,
unsigned MaxRecurse) { … }
Value *llvm::simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS,
const SimplifyQuery &Q) { … }
Value *llvm::simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS,
FastMathFlags FMF, const SimplifyQuery &Q) { … }
static Value *simplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
const SimplifyQuery &Q, unsigned MaxRecurse) { … }
Value *llvm::simplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
const SimplifyQuery &Q) { … }
static bool isIdempotent(Intrinsic::ID ID) { … }
static bool removesFPFraction(Intrinsic::ID ID) { … }
static Value *simplifyRelativeLoad(Constant *Ptr, Constant *Offset,
const DataLayout &DL) { … }
static Value *simplifyLdexp(Value *Op0, Value *Op1, const SimplifyQuery &Q,
bool IsStrict) { … }
static Value *simplifyUnaryIntrinsic(Function *F, Value *Op0,
const SimplifyQuery &Q,
const CallBase *Call) { … }
static Value *foldMinMaxSharedOp(Intrinsic::ID IID, Value *Op0, Value *Op1) { … }
static Value *foldMinimumMaximumSharedOp(Intrinsic::ID IID, Value *Op0,
Value *Op1) { … }
Value *llvm::simplifyBinaryIntrinsic(Intrinsic::ID IID, Type *ReturnType,
Value *Op0, Value *Op1,
const SimplifyQuery &Q,
const CallBase *Call) { … }
static Value *simplifyIntrinsic(CallBase *Call, Value *Callee,
ArrayRef<Value *> Args,
const SimplifyQuery &Q) { … }
static Value *tryConstantFoldCall(CallBase *Call, Value *Callee,
ArrayRef<Value *> Args,
const SimplifyQuery &Q) { … }
Value *llvm::simplifyCall(CallBase *Call, Value *Callee, ArrayRef<Value *> Args,
const SimplifyQuery &Q) { … }
Value *llvm::simplifyConstrainedFPCall(CallBase *Call, const SimplifyQuery &Q) { … }
static Value *simplifyFreezeInst(Value *Op0, const SimplifyQuery &Q) { … }
Value *llvm::simplifyFreezeInst(Value *Op0, const SimplifyQuery &Q) { … }
Value *llvm::simplifyLoadInst(LoadInst *LI, Value *PtrOp,
const SimplifyQuery &Q) { … }
static Value *simplifyInstructionWithOperands(Instruction *I,
ArrayRef<Value *> NewOps,
const SimplifyQuery &SQ,
unsigned MaxRecurse) { … }
Value *llvm::simplifyInstructionWithOperands(Instruction *I,
ArrayRef<Value *> NewOps,
const SimplifyQuery &SQ) { … }
Value *llvm::simplifyInstruction(Instruction *I, const SimplifyQuery &SQ) { … }
static bool replaceAndRecursivelySimplifyImpl(
Instruction *I, Value *SimpleV, const TargetLibraryInfo *TLI,
const DominatorTree *DT, AssumptionCache *AC,
SmallSetVector<Instruction *, 8> *UnsimplifiedUsers = nullptr) { … }
bool llvm::replaceAndRecursivelySimplify(
Instruction *I, Value *SimpleV, const TargetLibraryInfo *TLI,
const DominatorTree *DT, AssumptionCache *AC,
SmallSetVector<Instruction *, 8> *UnsimplifiedUsers) { … }
namespace llvm {
const SimplifyQuery getBestSimplifyQuery(Pass &P, Function &F) { … }
const SimplifyQuery getBestSimplifyQuery(LoopStandardAnalysisResults &AR,
const DataLayout &DL) { … }
template <class T, class... TArgs>
const SimplifyQuery getBestSimplifyQuery(AnalysisManager<T, TArgs...> &AM,
Function &F) { … }
template const SimplifyQuery getBestSimplifyQuery(AnalysisManager<Function> &,
Function &);
bool SimplifyQuery::isUndefValue(Value *V) const { … }
}
void InstSimplifyFolder::anchor() { … }