14 #ifndef LLVM_TRANSFORMS_UTILS_LOOPUTILS_H
15 #define LLVM_TRANSFORMS_UTILS_LOOPUTILS_H
24 class AliasSetTracker;
25 class AssumptionCache;
32 class PredIteratorCache;
33 class ScalarEvolution;
34 class TargetLibraryInfo;
92 : StartValue(Start), LoopExitInstr(Exit), Kind(K), MinMaxKind(MK) {}
99 : IsRecurrence(IsRecur), PatternLastInst(I), MinMaxKind(
MRK_Invalid) {}
102 : IsRecurrence(
true), PatternLastInst(I), MinMaxKind(K) {}
126 InstDesc &Prev,
bool HasFunNoNaNAttr);
154 bool HasFunNoNaNAttr,
192 AssumptionCache *AC =
nullptr);
205 bool formLCSSA(Loop &L, DominatorTree &DT, LoopInfo *LI,
206 ScalarEvolution *SE =
nullptr);
218 ScalarEvolution *SE =
nullptr);
229 TargetLibraryInfo *, Loop *, AliasSetTracker *,
240 TargetLibraryInfo *, Loop *, AliasSetTracker *,
251 SmallVectorImpl<Instruction*> &,
252 PredIteratorCache &, LoopInfo *,
253 DominatorTree *, Loop *, AliasSetTracker *,
265 bool isInductionPHI(PHINode *, ScalarEvolution *, ConstantInt *&);
Bitwise or logical XOR of numbers.
void computeLICMSafetyInfo(LICMSafetyInfo *, Loop *)
Computes safety information for a loop checks loop body & header for the possiblity of may throw exce...
Instruction * getPatternInst()
bool sinkRegion(DomTreeNode *, AliasAnalysis *, LoopInfo *, DominatorTree *, TargetLibraryInfo *, Loop *, AliasSetTracker *, LICMSafetyInfo *)
Walk the specified region of the CFG (defined by all blocks dominated by the specified block...
Min/max implemented in terms of select(cmp()).
bool isInductionPHI(PHINode *, ScalarEvolution *, ConstantInt *&)
Checks if the given PHINode in a loop header is an induction variable.
bool hoistRegion(DomTreeNode *, AliasAnalysis *, LoopInfo *, DominatorTree *, TargetLibraryInfo *, Loop *, AliasSetTracker *, LICMSafetyInfo *)
Walk the specified region of the CFG (defined by all blocks dominated by the specified block...
static bool isReductionPHI(PHINode *Phi, Loop *TheLoop, RecurrenceDescriptor &RedDes)
Returns true if Phi is a reduction in TheLoop.
Captures loop safety information.
MinMaxRecurrenceKind getMinMaxRecurrenceKind()
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'...
bool formLCSSA(Loop &L, DominatorTree &DT, LoopInfo *LI, ScalarEvolution *SE=nullptr)
Put loop into LCSSA form.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
RecurrenceDescriptor(Value *Start, Instruction *Exit, RecurrenceKind K, MinMaxRecurrenceKind MK)
BasicBlock * InsertPreheaderForLoop(Loop *L, Pass *P)
InsertPreheaderForLoop - Once we discover that a loop doesn't have a preheader, this method is called...
bool simplifyLoop(Loop *L, DominatorTree *DT, LoopInfo *LI, Pass *PP, AliasAnalysis *AA=nullptr, ScalarEvolution *SE=nullptr, AssumptionCache *AC=nullptr)
Simplify each loop in a loop nest recursively.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
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).
bool promoteLoopAccessesToScalars(AliasSet &, SmallVectorImpl< BasicBlock * > &, SmallVectorImpl< Instruction * > &, PredIteratorCache &, LoopInfo *, DominatorTree *, Loop *, AliasSetTracker *, LICMSafetyInfo *)
Try to promote memory values to scalars by sinking stores out of the loop and moving loads to before ...
static bool areAllUsesIn(Instruction *I, SmallPtrSetImpl< Instruction * > &Set)
Returns true if all uses of the instruction I is within the Set.
This POD struct holds information about a potential recurrence operation.
Bitwise or logical AND of numbers.
static bool hasMultipleUsesOf(Instruction *I, SmallPtrSetImpl< Instruction * > &Insts)
Returns true if instuction I has multiple uses in Insts.
static bool AddReductionVar(PHINode *Phi, RecurrenceKind Kind, Loop *TheLoop, bool HasFunNoNaNAttr, RecurrenceDescriptor &RedDes)
Returns true if Phi is a reduction of type Kind and adds it to the RecurrenceDescriptor.
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.
RecurrenceKind getRecurrenceKind()
static unsigned getRecurrenceBinOp(RecurrenceKind Kind)
Returns the opcode of binary operation corresponding to the RecurrenceKind.
InstDesc(Instruction *I, MinMaxRecurrenceKind K)
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
MinMaxRecurrenceKind getMinMaxKind()
Bitwise or logical OR of numbers.
static Constant * getRecurrenceIdentity(RecurrenceKind K, Type *Tp)
Returns identity corresponding to the RecurrenceKind.
static Value * createMinMaxOp(IRBuilder<> &Builder, MinMaxRecurrenceKind RK, Value *Left, Value *Right)
Returns a Min/Max operation corresponding to MinMaxRecurrenceKind.
bool formLCSSARecursively(Loop &L, DominatorTree &DT, LoopInfo *LI, ScalarEvolution *SE=nullptr)
Put a loop nest into LCSSA form.
Instruction * getLoopExitInstr()
DomTreeNodeBase< BasicBlock > DomTreeNode
LLVM Value Representation.
TrackingVH< Value > getRecurrenceStartValue()
InstDesc(bool IsRecur, Instruction *I)
RecurrenceKind
This enum represents the kinds of recurrences that we support.