LLVM: include/llvm/Analysis/LoopNestAnalysis.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_ANALYSIS_LOOPNESTANALYSIS_H
15#define LLVM_ANALYSIS_LOOPNESTANALYSIS_H
16
20
21namespace llvm {
22
24
25class LPMUpdater;
26
27
29public:
31
32
34
36
37
38 static std::unique_ptr getLoopNest(Loop &Root, ScalarEvolution &SE);
39
40
41
42
43
44
45
46
47
48
49
50
51 static bool arePerfectlyNested(const Loop &OuterLoop, const Loop &InnerLoop,
53
54
55
56 static InstrVectorTy getInterveningInstructions(const Loop &OuterLoop,
57 const Loop &InnerLoop,
59
60
61
62
63
64
65
66
67
68
69 static unsigned getMaxPerfectDepth(const Loop &Root, ScalarEvolution &SE);
70
71
72
73
74
77 bool CheckUniquePred = false);
78
79
81
82
83
84
86 if (Loops.size() == 1)
87 return Loops.back();
88
89
90
91
93 auto SecondLastLoopIter = ++Loops.rbegin();
94 return (LastLoop->getLoopDepth() == (*SecondLastLoopIter)->getLoopDepth())
95 ? nullptr
96 : LastLoop;
97 }
98
99
103 }
104
105
107 for (unsigned I = 0; I < getNumLoops(); ++I)
108 if (getLoop(I) == &L)
109 return I;
111 }
112
113
115
116
118
119
122 Depth <= Loops.back()->getLoopDepth() && "Invalid depth");
124 for (unsigned I = 0; I < getNumLoops(); ++I) {
126 if (L->getLoopDepth() == Depth)
127 Result.push_back(L);
128 else if (L->getLoopDepth() > Depth)
129 break;
130 }
131 return Result;
132 }
133
134
135
136
137
138
139
140
141
142
143
145
146
147
148
149
150
151
152
153
154
156 int NestDepth =
157 Loops.back()->getLoopDepth() - Loops.front()->getLoopDepth() + 1;
158 assert(NestDepth > 0 && "Expecting NestDepth to be at least 1");
159 return NestDepth;
160 }
161
162
164
165
167 return all_of(Loops, [](const Loop *L) { return L->isLoopSimplifyForm(); });
168 }
169
170
172 return all_of(Loops, [](const Loop *L) { return L->isRotatedForm(); });
173 }
174
175
177 return Loops.front()->getHeader()->getParent();
178 }
179
181
182protected:
183 const unsigned MaxPerfectDepth;
185
186private:
187 enum LoopNestEnum {
188 PerfectLoopNest,
189 ImperfectLoopNest,
190 InvalidLoopStructure,
191 OuterLoopLowerBoundUnknown
192 };
193 static LoopNestEnum analyzeLoopNestForPerfectNest(const Loop &OuterLoop,
194 const Loop &InnerLoop,
196};
197
198raw_ostream &operator<<(raw_ostream &, const LoopNest &);
199
200
201
205
206public:
209};
210
211
214
215public:
217
220
222};
223
224}
225
226#endif
BlockVerifier::State From
This header provides classes for managing per-loop analyses.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A container for analyses that lazily runs them and caches their results.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
unsigned getLoopDepth() const
Return the nesting level of this loop.
This analysis provides information for a loop nest.
Result run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR)
Printer pass for the LoopNest results.
LoopNestPrinterPass(raw_ostream &OS)
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U)
This class represents a loop nest and can be used to query its properties.
StringRef getName() const
ArrayRef< Loop * > getLoops() const
Get the loops in the nest.
unsigned getNestDepth() const
Return the loop nest depth (i.e.
const unsigned MaxPerfectDepth
LoopVectorTy getLoopsAtDepth(unsigned Depth) const
Get the loops in the nest at the given Depth.
Loop * getLoop(unsigned Index) const
Return the loop at the given Index.
bool areAllLoopsRotatedForm() const
Return true if all loops in the loop nest are in rotated form.
unsigned getMaxPerfectDepth() const
Return the maximum perfect nesting depth.
Function * getParent() const
Return the function to which the loop-nest belongs.
unsigned getLoopIndex(const Loop &L) const
Get the loop index of the given loop L.
Loop & getOutermostLoop() const
Return the outermost loop in the loop nest.
bool areAllLoopsSimplifyForm() const
Return true if all loops in the loop nest are in simplify form.
size_t getNumLoops() const
Return the number of loops in the nest.
Loop * getInnermostLoop() const
Return the innermost loop in the loop nest if the nest has only one innermost loop,...
Represents a single loop in the control flow graph.
A set of analyses that are preserved following a run of a transformation pass.
The main scalar evolution driver.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
SmallVector< Loop *, 8 > LoopVectorTy
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
A CRTP mix-in to automatically provide informational APIs needed for passes.