14 #ifndef LLVM_ANALYSIS_IVDESCRIPTORS_H 15 #define LLVM_ANALYSIS_IVDESCRIPTORS_H 38 class AliasSetTracker;
43 class OptimizationRemarkEmitter;
44 class PredicatedScalarEvolution;
45 class PredIteratorCache;
46 class ScalarEvolution;
48 class TargetLibraryInfo;
49 class TargetTransformInfo;
95 : StartValue(Start), LoopExitInstr(Exit), Kind(K), MinMaxKind(MK),
96 UnsafeAlgebraInst(UAI), RecurrenceType(RT), IsSigned(Signed) {
97 CastInsts.insert(CI.
begin(), CI.
end());
104 : IsRecurrence(IsRecur), PatternLastInst(I), MinMaxKind(
MRK_Invalid),
105 UnsafeAlgebraInst(UAI) {}
108 : IsRecurrence(
true), PatternLastInst(I), MinMaxKind(K),
109 UnsafeAlgebraInst(UAI) {}
139 InstDesc &Prev,
bool HasFunNoNaNAttr);
144 unsigned MaxNumUses);
170 bool HasFunNoNaNAttr,
246 Type *RecurrenceType =
nullptr;
248 bool IsSigned =
false;
272 int getConsecutiveDirection()
const;
304 static bool isInductionPHI(
PHINode *Phi,
const Loop *L,
312 return InductionBinOp && !cast<FPMathOperator>(InductionBinOp)->isFast();
318 if (!InductionBinOp || cast<FPMathOperator>(InductionBinOp)->isFast())
320 return InductionBinOp;
325 return InductionBinOp ? InductionBinOp->getOpcode()
326 : Instruction::BinaryOpsEnd;
333 return RedundantCasts;
347 const SCEV *Step =
nullptr;
357 #endif // LLVM_ANALYSIS_IVDESCRIPTORS_H Bitwise or logical XOR of numbers.
static bool isArithmeticRecurrenceKind(RecurrenceKind Kind)
Returns true if the recurrence kind is an arithmetic kind.
BinaryOperator * getInductionBinOp() const
Instruction * getPatternInst()
This class represents lattice values for constants.
Instruction * getUnsafeAlgebraInst()
Returns first unsafe algebra instruction in the PHI node's use-chain.
Min/max implemented in terms of select(cmp()).
InstDesc(bool IsRecur, Instruction *I, Instruction *UAI=nullptr)
Instruction::BinaryOps getInductionOpcode() const
Returns binary opcode of the induction operator.
static bool AddReductionVar(PHINode *Phi, RecurrenceKind Kind, Loop *TheLoop, bool HasFunNoNaNAttr, RecurrenceDescriptor &RedDes, DemandedBits *DB=nullptr, AssumptionCache *AC=nullptr, DominatorTree *DT=nullptr)
Returns true if Phi is a reduction of type Kind and adds it to the RecurrenceDescriptor.
The main scalar evolution driver.
A cache of @llvm.assume calls within a function.
MinMaxRecurrenceKind getMinMaxRecurrenceKind()
InductionKind getKind() const
block Block Frequency true
Value * getStartValue() const
static InstDesc isRecurrenceInstr(Instruction *I, RecurrenceKind Kind, InstDesc &Prev, bool HasFunNoNaNAttr)
Returns a struct describing if the instruction 'I' can be a recurrence variable of type 'Kind'...
static bool hasMultipleUsesOf(Instruction *I, SmallPtrSetImpl< Instruction *> &Insts, unsigned MaxNumUses)
Returns true if instruction I has multiple uses in Insts.
bool isSigned()
Returns true if all source operands of the recurrence are SExtInsts.
bool hasUnsafeAlgebra()
Returns true if the recurrence has unsafe algebra which requires a relaxed floating-point model...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
static bool areAllUsesIn(Instruction *I, SmallPtrSetImpl< Instruction *> &Set)
Returns true if all uses of the instruction I is within the Set.
static InstDesc isMinMaxSelectCmpPattern(Instruction *I, InstDesc &Prev)
Returns a struct describing if the instruction if the instruction is a Select(ICmp(X, Y), X, Y) instruction pattern corresponding to a min(X, Y) or max(X, Y).
Contains a collection of routines for determining if a given instruction is guaranteed to execute if ...
Not an induction variable.
This POD struct holds information about a potential recurrence operation.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Bitwise or logical AND of numbers.
Pointer induction var. Step = C / sizeof(elem).
Integer induction variable. Step = C.
The instances of the Type class are immutable: once they are created, they are never changed...
Min/max implemented in terms of select(cmp()).
Value handle that tracks a Value across RAUW.
This is an important base class in LLVM.
Instruction * getUnsafeAlgebraInst()
Returns induction operator that does not have "fast-math" property and requires FP unsafe mode...
const SCEV * getStep() const
InstDesc(Instruction *I, MinMaxRecurrenceKind K, Instruction *UAI=nullptr)
Instruction * getUnsafeAlgebraInst()
static bool isReductionPHI(PHINode *Phi, Loop *TheLoop, RecurrenceDescriptor &RedDes, DemandedBits *DB=nullptr, AssumptionCache *AC=nullptr, DominatorTree *DT=nullptr)
Returns true if Phi is a reduction in TheLoop.
static InstDesc isConditionalRdxPattern(RecurrenceKind Kind, Instruction *I)
Returns a struct describing if the instruction is a Select(FCmp(X, Y), (Z = X op PHINode), PHINode) instruction pattern.
RecurrenceKind getRecurrenceKind()
static unsigned getRecurrenceBinOp(RecurrenceKind Kind)
Returns the opcode of binary operation corresponding to the RecurrenceKind.
static bool isFirstOrderRecurrence(PHINode *Phi, Loop *TheLoop, DenseMap< Instruction *, Instruction *> &SinkAfter, DominatorTree *DT)
Returns true if Phi is a first-order recurrence.
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
MinMaxRecurrenceKind getMinMaxKind()
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is the shared class of boolean and integer constants.
A struct for saving information about induction variables.
Bitwise or logical OR of numbers.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
RecurrenceDescriptor(Value *Start, Instruction *Exit, RecurrenceKind K, MinMaxRecurrenceKind MK, Instruction *UAI, Type *RT, bool Signed, SmallPtrSetImpl< Instruction *> &CI)
static bool isFloatingPointRecurrenceKind(RecurrenceKind Kind)
Returns true if the recurrence kind is a floating point kind.
An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of ...
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static Constant * getRecurrenceIdentity(RecurrenceKind K, Type *Tp)
Returns identity corresponding to the RecurrenceKind.
RecurrenceDescriptor()=default
bool hasUnsafeAlgebra()
Returns true if the induction type is FP and the binary operator does not have the "fast-math" proper...
const SmallVectorImpl< Instruction * > & getCastInsts() const
Returns a reference to the type cast instructions in the induction update chain, that are redundant w...
This class represents an analyzed expression in the program.
static bool isIntegerRecurrenceKind(RecurrenceKind Kind)
Returns true if the recurrence kind is an integer kind.
Instruction * getLoopExitInstr()
Represents a single loop in the control flow graph.
SmallPtrSet< Instruction *, 8 > & getCastInsts()
Returns a reference to the instructions used for type-promoting the recurrence.
LLVM Value Representation.
TrackingVH< Value > getRecurrenceStartValue()
InductionKind
This enum represents the kinds of inductions that we support.
RecurrenceKind
This enum represents the kinds of recurrences that we support.
Type * getRecurrenceType()
Returns the type of the recurrence.