LLVM 22.0.0git
DependenceAnalysis.h
Go to the documentation of this file.
1//===-- llvm/Analysis/DependenceAnalysis.h -------------------- -*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// DependenceAnalysis is an LLVM pass that analyses dependences between memory
10// accesses. Currently, it is an implementation of the approach described in
11//
12// Practical Dependence Testing
13// Goff, Kennedy, Tseng
14// PLDI 1991
15//
16// There's a single entry point that analyzes the dependence between a pair
17// of memory references in a function, returning either NULL, for no dependence,
18// or a more-or-less detailed description of the dependence between them.
19//
20// This pass exists to support the DependenceGraph pass. There are two separate
21// passes because there's a useful separation of concerns. A dependence exists
22// if two conditions are met:
23//
24// 1) Two instructions reference the same memory location, and
25// 2) There is a flow of control leading from one instruction to the other.
26//
27// DependenceAnalysis attacks the first condition; DependenceGraph will attack
28// the second (it's not yet ready).
29//
30// Please note that this is work in progress and the interface is subject to
31// change.
32//
33// Plausible changes:
34// Return a set of more precise dependences instead of just one dependence
35// summarizing all.
36//
37//===----------------------------------------------------------------------===//
38
39#ifndef LLVM_ANALYSIS_DEPENDENCEANALYSIS_H
40#define LLVM_ANALYSIS_DEPENDENCEANALYSIS_H
41
45#include "llvm/IR/PassManager.h"
46#include "llvm/Pass.h"
48
49namespace llvm {
50class AAResults;
51template <typename T> class ArrayRef;
52class Loop;
53class LoopInfo;
54class SCEVConstant;
55class raw_ostream;
56
57/// Dependence - This class represents a dependence between two memory
58/// memory references in a function. It contains minimal information and
59/// is used in the very common situation where the compiler is unable to
60/// determine anything beyond the existence of a dependence; that is, it
61/// represents a confused dependence (see also FullDependence). In most
62/// cases (for output, flow, and anti dependences), the dependence implies
63/// an ordering, where the source must precede the destination; in contrast,
64/// input dependences are unordered.
65///
66/// When a dependence graph is built, each Dependence will be a member of
67/// the set of predecessor edges for its destination instruction and a set
68/// if successor edges for its source instruction. These sets are represented
69/// as singly-linked lists, with the "next" fields stored in the dependence
70/// itelf.
72protected:
73 Dependence(Dependence &&) = default;
75
76public:
77 Dependence(Instruction *Source, Instruction *Destination,
78 const SCEVUnionPredicate &A)
79 : Src(Source), Dst(Destination), Assumptions(A) {}
80 virtual ~Dependence() = default;
81
82 /// Dependence::DVEntry - Each level in the distance/direction vector
83 /// has a direction (or perhaps a union of several directions), and
84 /// perhaps a distance.
85 /// The dependency information could be across a single loop level or across
86 /// two separate levels that have the same trip count and nesting depth,
87 /// which helps to provide information for loop fusion candidation.
88 /// For example, loops b and c have the same iteration count and depth:
89 /// for (a = ...) {
90 /// for (b = 0; b < 10; b++) {
91 /// }
92 /// for (c = 0; c < 10; c++) {
93 /// }
94 /// }
95 struct DVEntry {
96 enum : unsigned char {
97 NONE = 0,
98 LT = 1,
99 EQ = 2,
100 LE = 3,
101 GT = 4,
102 NE = 5,
103 GE = 6,
104 ALL = 7
105 };
106 unsigned char Direction : 3; // Init to ALL, then refine.
107 bool Scalar : 1; // Init to true.
108 bool PeelFirst : 1; // Peeling the first iteration will break dependence.
109 bool PeelLast : 1; // Peeling the last iteration will break the dependence.
110 bool Splitable : 1; // Splitting the loop will break dependence.
111 const SCEV *Distance = nullptr; // NULL implies no distance available.
115 };
116
117 /// getSrc - Returns the source instruction for this dependence.
118 Instruction *getSrc() const { return Src; }
119
120 /// getDst - Returns the destination instruction for this dependence.
121 Instruction *getDst() const { return Dst; }
122
123 /// isInput - Returns true if this is an input dependence.
124 bool isInput() const;
125
126 /// isOutput - Returns true if this is an output dependence.
127 bool isOutput() const;
128
129 /// isFlow - Returns true if this is a flow (aka true) dependence.
130 bool isFlow() const;
131
132 /// isAnti - Returns true if this is an anti dependence.
133 bool isAnti() const;
134
135 /// isOrdered - Returns true if dependence is Output, Flow, or Anti
136 bool isOrdered() const { return isOutput() || isFlow() || isAnti(); }
137
138 /// isUnordered - Returns true if dependence is Input
139 bool isUnordered() const { return isInput(); }
140
141 /// isLoopIndependent - Returns true if this is a loop-independent
142 /// dependence.
143 virtual bool isLoopIndependent() const { return true; }
144
145 /// isConfused - Returns true if this dependence is confused
146 /// (the compiler understands nothing and makes worst-case assumptions).
147 virtual bool isConfused() const { return true; }
148
149 /// isConsistent - Returns true if this dependence is consistent
150 /// (occurs every time the source and destination are executed).
151 virtual bool isConsistent() const { return false; }
152
153 /// getLevels - Returns the number of common loops surrounding the
154 /// source and destination of the dependence.
155 virtual unsigned getLevels() const { return 0; }
156
157 /// getSameSDLevels - Returns the number of separate SameSD loops surrounding
158 /// the source and destination of the dependence.
159 virtual unsigned getSameSDLevels() const { return 0; }
160
161 /// getDVEntry - Returns the DV entry associated with a regular or a
162 /// SameSD level
163 DVEntry getDVEntry(unsigned Level, bool isSameSD) const;
164
165 /// getDirection - Returns the direction associated with a particular
166 /// common or SameSD level.
167 virtual unsigned getDirection(unsigned Level, bool SameSD = false) const {
168 return DVEntry::ALL;
169 }
170
171 /// getDistance - Returns the distance (or NULL) associated with a
172 /// particular common or SameSD level.
173 virtual const SCEV *getDistance(unsigned Level, bool SameSD = false) const {
174 return nullptr;
175 }
176
177 /// Check if the direction vector is negative. A negative direction
178 /// vector means Src and Dst are reversed in the actual program.
179 virtual bool isDirectionNegative() const { return false; }
180
181 /// If the direction vector is negative, normalize the direction
182 /// vector to make it non-negative. Normalization is done by reversing
183 /// Src and Dst, plus reversing the dependence directions and distances
184 /// in the vector.
185 virtual bool normalize(ScalarEvolution *SE) { return false; }
186
187 /// isPeelFirst - Returns true if peeling the first iteration from
188 /// this regular or SameSD loop level will break this dependence.
189 virtual bool isPeelFirst(unsigned Level, bool SameSD = false) const {
190 return false;
191 }
192
193 /// isPeelLast - Returns true if peeling the last iteration from
194 /// this regular or SameSD loop level will break this dependence.
195 virtual bool isPeelLast(unsigned Level, bool SameSD = false) const {
196 return false;
197 }
198
199 /// isSplitable - Returns true if splitting the loop will break
200 /// the dependence.
201 virtual bool isSplitable(unsigned Level, bool SameSD = false) const {
202 return false;
203 }
204
205 /// inSameSDLoops - Returns true if this level is an SameSD level, i.e.,
206 /// performed across two separate loop nests that have the Same Iteration and
207 /// Depth.
208 virtual bool inSameSDLoops(unsigned Level) const { return false; }
209
210 /// isScalar - Returns true if a particular regular or SameSD level is
211 /// scalar; that is, if no subscript in the source or destination mention
212 /// the induction variable associated with the loop at this level.
213 virtual bool isScalar(unsigned Level, bool SameSD = false) const;
214
215 /// getNextPredecessor - Returns the value of the NextPredecessor field.
216 const Dependence *getNextPredecessor() const { return NextPredecessor; }
217
218 /// getNextSuccessor - Returns the value of the NextSuccessor field.
219 const Dependence *getNextSuccessor() const { return NextSuccessor; }
220
221 /// setNextPredecessor - Sets the value of the NextPredecessor
222 /// field.
223 void setNextPredecessor(const Dependence *pred) { NextPredecessor = pred; }
224
225 /// setNextSuccessor - Sets the value of the NextSuccessor field.
226 void setNextSuccessor(const Dependence *succ) { NextSuccessor = succ; }
227
228 /// getRuntimeAssumptions - Returns the runtime assumptions under which this
229 /// Dependence relation is valid.
230 SCEVUnionPredicate getRuntimeAssumptions() const { return Assumptions; }
231
232 /// dump - For debugging purposes, dumps a dependence to OS.
233 void dump(raw_ostream &OS) const;
234
235 /// dumpImp - For debugging purposes. Dumps a dependence to OS with or
236 /// without considering the SameSD levels.
237 void dumpImp(raw_ostream &OS, bool SameSD = false) const;
238
239protected:
241
242private:
243 SCEVUnionPredicate Assumptions;
244 const Dependence *NextPredecessor = nullptr, *NextSuccessor = nullptr;
245 friend class DependenceInfo;
246};
247
248/// FullDependence - This class represents a dependence between two memory
249/// references in a function. It contains detailed information about the
250/// dependence (direction vectors, etc.) and is used when the compiler is
251/// able to accurately analyze the interaction of the references; that is,
252/// it is not a confused dependence (see Dependence). In most cases
253/// (for output, flow, and anti dependences), the dependence implies an
254/// ordering, where the source must precede the destination; in contrast,
255/// input dependences are unordered.
256class LLVM_ABI FullDependence final : public Dependence {
257public:
258 FullDependence(Instruction *Source, Instruction *Destination,
259 const SCEVUnionPredicate &Assumes,
260 bool PossiblyLoopIndependent, unsigned Levels);
261
262 /// isLoopIndependent - Returns true if this is a loop-independent
263 /// dependence.
264 bool isLoopIndependent() const override { return LoopIndependent; }
265
266 /// isConfused - Returns true if this dependence is confused
267 /// (the compiler understands nothing and makes worst-case
268 /// assumptions).
269 bool isConfused() const override { return false; }
270
271 /// isConsistent - Returns true if this dependence is consistent
272 /// (occurs every time the source and destination are executed).
273 bool isConsistent() const override { return Consistent; }
274
275 /// getLevels - Returns the number of common loops surrounding the
276 /// source and destination of the dependence.
277 unsigned getLevels() const override { return Levels; }
278
279 /// getSameSDLevels - Returns the number of separate SameSD loops surrounding
280 /// the source and destination of the dependence.
281 unsigned getSameSDLevels() const override { return SameSDLevels; }
282
283 /// getDVEntry - Returns the DV entry associated with a regular or a
284 /// SameSD level.
285 DVEntry getDVEntry(unsigned Level, bool isSameSD) const {
286 if (!isSameSD) {
287 assert(0 < Level && Level <= Levels && "Level out of range");
288 return DV[Level - 1];
289 } else {
290 assert(Levels < Level && Level <= Levels + SameSDLevels &&
291 "isSameSD level out of range");
292 return DVSameSD[Level - Levels - 1];
293 }
294 }
295
296 /// getDirection - Returns the direction associated with a particular
297 /// common or SameSD level.
298 unsigned getDirection(unsigned Level, bool SameSD = false) const override;
299
300 /// getDistance - Returns the distance (or NULL) associated with a
301 /// particular common or SameSD level.
302 const SCEV *getDistance(unsigned Level, bool SameSD = false) const override;
303
304 /// Check if the direction vector is negative. A negative direction
305 /// vector means Src and Dst are reversed in the actual program.
306 bool isDirectionNegative() const override;
307
308 /// If the direction vector is negative, normalize the direction
309 /// vector to make it non-negative. Normalization is done by reversing
310 /// Src and Dst, plus reversing the dependence directions and distances
311 /// in the vector.
312 bool normalize(ScalarEvolution *SE) override;
313
314 /// isPeelFirst - Returns true if peeling the first iteration from
315 /// this regular or SameSD loop level will break this dependence.
316 bool isPeelFirst(unsigned Level, bool SameSD = false) const override;
317
318 /// isPeelLast - Returns true if peeling the last iteration from
319 /// this regular or SameSD loop level will break this dependence.
320 bool isPeelLast(unsigned Level, bool SameSD = false) const override;
321
322 /// isSplitable - Returns true if splitting the loop will break
323 /// the dependence.
324 bool isSplitable(unsigned Level, bool SameSD = false) const override;
325
326 /// inSameSDLoops - Returns true if this level is an SameSD level, i.e.,
327 /// performed across two separate loop nests that have the Same Iteration and
328 /// Depth.
329 bool inSameSDLoops(unsigned Level) const override;
330
331 /// isScalar - Returns true if a particular regular or SameSD level is
332 /// scalar; that is, if no subscript in the source or destination mention
333 /// the induction variable associated with the loop at this level.
334 bool isScalar(unsigned Level, bool SameSD = false) const override;
335
336private:
337 unsigned short Levels;
338 unsigned short SameSDLevels;
339 bool LoopIndependent;
340 bool Consistent; // Init to true, then refine.
341 std::unique_ptr<DVEntry[]> DV;
342 std::unique_ptr<DVEntry[]> DVSameSD; // DV entries on SameSD levels
343 friend class DependenceInfo;
344};
345
346/// DependenceInfo - This class is the main dependence-analysis driver.
348public:
350 : AA(AA), SE(SE), LI(LI), F(F) {}
351
352 /// Handle transitive invalidation when the cached analysis results go away.
354 FunctionAnalysisManager::Invalidator &Inv);
355
356 /// depends - Tests for a dependence between the Src and Dst instructions.
357 /// Returns NULL if no dependence; otherwise, returns a Dependence (or a
358 /// FullDependence) with as much information as can be gleaned. By default,
359 /// the dependence test collects a set of runtime assumptions that cannot be
360 /// solved at compilation time. By default UnderRuntimeAssumptions is false
361 /// for a safe approximation of the dependence relation that does not
362 /// require runtime checks.
363 LLVM_ABI std::unique_ptr<Dependence>
365 bool UnderRuntimeAssumptions = false);
366
367 /// getSplitIteration - Give a dependence that's splittable at some
368 /// particular level, return the iteration that should be used to split
369 /// the loop.
370 ///
371 /// Generally, the dependence analyzer will be used to build
372 /// a dependence graph for a function (basically a map from instructions
373 /// to dependences). Looking for cycles in the graph shows us loops
374 /// that cannot be trivially vectorized/parallelized.
375 ///
376 /// We can try to improve the situation by examining all the dependences
377 /// that make up the cycle, looking for ones we can break.
378 /// Sometimes, peeling the first or last iteration of a loop will break
379 /// dependences, and there are flags for those possibilities.
380 /// Sometimes, splitting a loop at some other iteration will do the trick,
381 /// and we've got a flag for that case. Rather than waste the space to
382 /// record the exact iteration (since we rarely know), we provide
383 /// a method that calculates the iteration. It's a drag that it must work
384 /// from scratch, but wonderful in that it's possible.
385 ///
386 /// Here's an example:
387 ///
388 /// for (i = 0; i < 10; i++)
389 /// A[i] = ...
390 /// ... = A[11 - i]
391 ///
392 /// There's a loop-carried flow dependence from the store to the load,
393 /// found by the weak-crossing SIV test. The dependence will have a flag,
394 /// indicating that the dependence can be broken by splitting the loop.
395 /// Calling getSplitIteration will return 5.
396 /// Splitting the loop breaks the dependence, like so:
397 ///
398 /// for (i = 0; i <= 5; i++)
399 /// A[i] = ...
400 /// ... = A[11 - i]
401 /// for (i = 6; i < 10; i++)
402 /// A[i] = ...
403 /// ... = A[11 - i]
404 ///
405 /// breaks the dependence and allows us to vectorize/parallelize
406 /// both loops.
407 LLVM_ABI const SCEV *getSplitIteration(const Dependence &Dep, unsigned Level);
408
409 Function *getFunction() const { return F; }
410
411 /// getRuntimeAssumptions - Returns all the runtime assumptions under which
412 /// the dependence test is valid.
414
415private:
416 AAResults *AA;
417 ScalarEvolution *SE;
418 LoopInfo *LI;
419 Function *F;
421
422 /// Subscript - This private struct represents a pair of subscripts from
423 /// a pair of potentially multi-dimensional array references. We use a
424 /// vector of them to guide subscript partitioning.
425 struct Subscript {
426 const SCEV *Src;
427 const SCEV *Dst;
428 enum ClassificationKind { ZIV, SIV, RDIV, MIV, NonLinear } Classification;
429 SmallBitVector Loops;
430 SmallBitVector GroupLoops;
431 SmallBitVector Group;
432 };
433
434 struct CoefficientInfo {
435 const SCEV *Coeff;
436 const SCEV *PosPart;
437 const SCEV *NegPart;
438 const SCEV *Iterations;
439 };
440
441 struct BoundInfo {
442 const SCEV *Iterations;
443 const SCEV *Upper[8];
444 const SCEV *Lower[8];
445 unsigned char Direction;
446 unsigned char DirSet;
447 };
448
449 /// Constraint - This private class represents a constraint, as defined
450 /// in the paper
451 ///
452 /// Practical Dependence Testing
453 /// Goff, Kennedy, Tseng
454 /// PLDI 1991
455 ///
456 /// There are 5 kinds of constraint, in a hierarchy.
457 /// 1) Any - indicates no constraint, any dependence is possible.
458 /// 2) Line - A line ax + by = c, where a, b, and c are parameters,
459 /// representing the dependence equation.
460 /// 3) Distance - The value d of the dependence distance;
461 /// 4) Point - A point <x, y> representing the dependence from
462 /// iteration x to iteration y.
463 /// 5) Empty - No dependence is possible.
464 class Constraint {
465 private:
466 enum ConstraintKind { Empty, Point, Distance, Line, Any } Kind;
467 ScalarEvolution *SE;
468 const SCEV *A;
469 const SCEV *B;
470 const SCEV *C;
471 const Loop *AssociatedSrcLoop;
472 const Loop *AssociatedDstLoop;
473
474 public:
475 /// isEmpty - Return true if the constraint is of kind Empty.
476 bool isEmpty() const { return Kind == Empty; }
477
478 /// isPoint - Return true if the constraint is of kind Point.
479 bool isPoint() const { return Kind == Point; }
480
481 /// isDistance - Return true if the constraint is of kind Distance.
482 bool isDistance() const { return Kind == Distance; }
483
484 /// isLine - Return true if the constraint is of kind Line.
485 /// Since Distance's can also be represented as Lines, we also return
486 /// true if the constraint is of kind Distance.
487 bool isLine() const { return Kind == Line || Kind == Distance; }
488
489 /// isAny - Return true if the constraint is of kind Any;
490 bool isAny() const { return Kind == Any; }
491
492 /// getX - If constraint is a point <X, Y>, returns X.
493 /// Otherwise assert.
494 LLVM_ABI const SCEV *getX() const;
495
496 /// getY - If constraint is a point <X, Y>, returns Y.
497 /// Otherwise assert.
498 LLVM_ABI const SCEV *getY() const;
499
500 /// getA - If constraint is a line AX + BY = C, returns A.
501 /// Otherwise assert.
502 LLVM_ABI const SCEV *getA() const;
503
504 /// getB - If constraint is a line AX + BY = C, returns B.
505 /// Otherwise assert.
506 LLVM_ABI const SCEV *getB() const;
507
508 /// getC - If constraint is a line AX + BY = C, returns C.
509 /// Otherwise assert.
510 LLVM_ABI const SCEV *getC() const;
511
512 /// getD - If constraint is a distance, returns D.
513 /// Otherwise assert.
514 LLVM_ABI const SCEV *getD() const;
515
516 /// getAssociatedSrcLoop - Returns the source loop associated with this
517 /// constraint.
518 LLVM_ABI const Loop *getAssociatedSrcLoop() const;
519
520 /// getAssociatedDstLoop - Returns the destination loop associated with
521 /// this constraint.
522 LLVM_ABI const Loop *getAssociatedDstLoop() const;
523
524 /// setPoint - Change a constraint to Point.
525 LLVM_ABI void setPoint(const SCEV *X, const SCEV *Y,
526 const Loop *CurrentSrcLoop,
527 const Loop *CurrentDstLoop);
528
529 /// setLine - Change a constraint to Line.
530 LLVM_ABI void setLine(const SCEV *A, const SCEV *B, const SCEV *C,
531 const Loop *CurrentSrcLoop,
532 const Loop *CurrentDstLoop);
533
534 /// setDistance - Change a constraint to Distance.
535 LLVM_ABI void setDistance(const SCEV *D, const Loop *CurrentSrcLoop,
536 const Loop *CurrentDstLoop);
537
538 /// setEmpty - Change a constraint to Empty.
539 LLVM_ABI void setEmpty();
540
541 /// setAny - Change a constraint to Any.
542 LLVM_ABI void setAny(ScalarEvolution *SE);
543
544 /// dump - For debugging purposes. Dumps the constraint
545 /// out to OS.
546 LLVM_ABI void dump(raw_ostream &OS) const;
547 };
548
549 /// Returns true if two loops have the Same iteration Space and Depth. To be
550 /// more specific, two loops have SameSD if they are in the same nesting
551 /// depth and have the same backedge count. SameSD stands for Same iteration
552 /// Space and Depth.
553 bool haveSameSD(const Loop *SrcLoop, const Loop *DstLoop) const;
554
555 /// establishNestingLevels - Examines the loop nesting of the Src and Dst
556 /// instructions and establishes their shared loops. Sets the variables
557 /// CommonLevels, SrcLevels, and MaxLevels.
558 /// The source and destination instructions needn't be contained in the same
559 /// loop. The routine establishNestingLevels finds the level of most deeply
560 /// nested loop that contains them both, CommonLevels. An instruction that's
561 /// not contained in a loop is at level = 0. MaxLevels is equal to the level
562 /// of the source plus the level of the destination, minus CommonLevels.
563 /// This lets us allocate vectors MaxLevels in length, with room for every
564 /// distinct loop referenced in both the source and destination subscripts.
565 /// The variable SrcLevels is the nesting depth of the source instruction.
566 /// It's used to help calculate distinct loops referenced by the destination.
567 /// Here's the map from loops to levels:
568 /// 0 - unused
569 /// 1 - outermost common loop
570 /// ... - other common loops
571 /// CommonLevels - innermost common loop
572 /// ... - loops containing Src but not Dst
573 /// SrcLevels - innermost loop containing Src but not Dst
574 /// ... - loops containing Dst but not Src
575 /// MaxLevels - innermost loop containing Dst but not Src
576 /// Consider the follow code fragment:
577 /// for (a = ...) {
578 /// for (b = ...) {
579 /// for (c = ...) {
580 /// for (d = ...) {
581 /// A[] = ...;
582 /// }
583 /// }
584 /// for (e = ...) {
585 /// for (f = ...) {
586 /// for (g = ...) {
587 /// ... = A[];
588 /// }
589 /// }
590 /// }
591 /// }
592 /// }
593 /// If we're looking at the possibility of a dependence between the store
594 /// to A (the Src) and the load from A (the Dst), we'll note that they
595 /// have 2 loops in common, so CommonLevels will equal 2 and the direction
596 /// vector for Result will have 2 entries. SrcLevels = 4 and MaxLevels = 7.
597 /// A map from loop names to level indices would look like
598 /// a - 1
599 /// b - 2 = CommonLevels
600 /// c - 3
601 /// d - 4 = SrcLevels
602 /// e - 5
603 /// f - 6
604 /// g - 7 = MaxLevels
605 /// SameSDLevels counts the number of levels after common levels that are
606 /// not common but have the same iteration space and depth. Internally this
607 /// is checked using haveSameSD. Assume that in this code fragment, levels c
608 /// and e have the same iteration space and depth, but levels d and f does
609 /// not. Then SameSDLevels is set to 1. In that case the level numbers for the
610 /// previous code look like
611 /// a - 1
612 /// b - 2
613 /// c,e - 3 = CommonLevels
614 /// d - 4 = SrcLevels
615 /// f - 5
616 /// g - 6 = MaxLevels
617 void establishNestingLevels(const Instruction *Src, const Instruction *Dst);
618
619 unsigned CommonLevels, SrcLevels, MaxLevels, SameSDLevels;
620
621 /// mapSrcLoop - Given one of the loops containing the source, return
622 /// its level index in our numbering scheme.
623 unsigned mapSrcLoop(const Loop *SrcLoop) const;
624
625 /// mapDstLoop - Given one of the loops containing the destination,
626 /// return its level index in our numbering scheme.
627 unsigned mapDstLoop(const Loop *DstLoop) const;
628
629 /// isLoopInvariant - Returns true if Expression is loop invariant
630 /// in LoopNest.
631 bool isLoopInvariant(const SCEV *Expression, const Loop *LoopNest) const;
632
633 /// Makes sure all subscript pairs share the same integer type by
634 /// sign-extending as necessary.
635 /// Sign-extending a subscript is safe because getelementptr assumes the
636 /// array subscripts are signed.
637 void unifySubscriptType(ArrayRef<Subscript *> Pairs);
638
639 /// removeMatchingExtensions - Examines a subscript pair.
640 /// If the source and destination are identically sign (or zero)
641 /// extended, it strips off the extension in an effort to
642 /// simplify the actual analysis.
643 void removeMatchingExtensions(Subscript *Pair);
644
645 /// collectCommonLoops - Finds the set of loops from the LoopNest that
646 /// have a level <= CommonLevels and are referred to by the SCEV Expression.
647 void collectCommonLoops(const SCEV *Expression, const Loop *LoopNest,
648 SmallBitVector &Loops) const;
649
650 /// checkSrcSubscript - Examines the SCEV Src, returning true iff it's
651 /// linear. Collect the set of loops mentioned by Src.
652 bool checkSrcSubscript(const SCEV *Src, const Loop *LoopNest,
653 SmallBitVector &Loops);
654
655 /// checkDstSubscript - Examines the SCEV Dst, returning true iff it's
656 /// linear. Collect the set of loops mentioned by Dst.
657 bool checkDstSubscript(const SCEV *Dst, const Loop *LoopNest,
658 SmallBitVector &Loops);
659
660 /// isKnownPredicate - Compare X and Y using the predicate Pred.
661 /// Basically a wrapper for SCEV::isKnownPredicate,
662 /// but tries harder, especially in the presence of sign and zero
663 /// extensions and symbolics.
664 bool isKnownPredicate(ICmpInst::Predicate Pred, const SCEV *X,
665 const SCEV *Y) const;
666
667 /// isKnownLessThan - Compare to see if S is less than Size
668 /// Another wrapper for isKnownNegative(S - max(Size, 1)) with some extra
669 /// checking if S is an AddRec and we can prove lessthan using the loop
670 /// bounds.
671 bool isKnownLessThan(const SCEV *S, const SCEV *Size) const;
672
673 /// isKnownNonNegative - Compare to see if S is known not to be negative
674 /// Uses the fact that S comes from Ptr, which may be an inbound GEP,
675 /// Proving there is no wrapping going on.
676 bool isKnownNonNegative(const SCEV *S, const Value *Ptr) const;
677
678 /// collectUpperBound - All subscripts are the same type (on my machine,
679 /// an i64). The loop bound may be a smaller type. collectUpperBound
680 /// find the bound, if available, and zero extends it to the Type T.
681 /// (I zero extend since the bound should always be >= 0.)
682 /// If no upper bound is available, return NULL.
683 const SCEV *collectUpperBound(const Loop *l, Type *T) const;
684
685 /// collectConstantUpperBound - Calls collectUpperBound(), then
686 /// attempts to cast it to SCEVConstant. If the cast fails,
687 /// returns NULL.
688 const SCEVConstant *collectConstantUpperBound(const Loop *l, Type *T) const;
689
690 /// classifyPair - Examines the subscript pair (the Src and Dst SCEVs)
691 /// and classifies it as either ZIV, SIV, RDIV, MIV, or Nonlinear.
692 /// Collects the associated loops in a set.
693 Subscript::ClassificationKind
694 classifyPair(const SCEV *Src, const Loop *SrcLoopNest, const SCEV *Dst,
695 const Loop *DstLoopNest, SmallBitVector &Loops);
696
697 /// testZIV - Tests the ZIV subscript pair (Src and Dst) for dependence.
698 /// Returns true if any possible dependence is disproved.
699 /// If there might be a dependence, returns false.
700 /// If the dependence isn't proven to exist,
701 /// marks the Result as inconsistent.
702 bool testZIV(const SCEV *Src, const SCEV *Dst, FullDependence &Result) const;
703
704 /// testSIV - Tests the SIV subscript pair (Src and Dst) for dependence.
705 /// Things of the form [c1 + a1*i] and [c2 + a2*j], where
706 /// i and j are induction variables, c1 and c2 are loop invariant,
707 /// and a1 and a2 are constant.
708 /// Returns true if any possible dependence is disproved.
709 /// If there might be a dependence, returns false.
710 /// Sets appropriate direction vector entry and, when possible,
711 /// the distance vector entry.
712 /// If the dependence isn't proven to exist,
713 /// marks the Result as inconsistent.
714 bool testSIV(const SCEV *Src, const SCEV *Dst, unsigned &Level,
715 FullDependence &Result, Constraint &NewConstraint,
716 const SCEV *&SplitIter) const;
717
718 /// testRDIV - Tests the RDIV subscript pair (Src and Dst) for dependence.
719 /// Things of the form [c1 + a1*i] and [c2 + a2*j]
720 /// where i and j are induction variables, c1 and c2 are loop invariant,
721 /// and a1 and a2 are constant.
722 /// With minor algebra, this test can also be used for things like
723 /// [c1 + a1*i + a2*j][c2].
724 /// Returns true if any possible dependence is disproved.
725 /// If there might be a dependence, returns false.
726 /// Marks the Result as inconsistent.
727 bool testRDIV(const SCEV *Src, const SCEV *Dst, FullDependence &Result) const;
728
729 /// testMIV - Tests the MIV subscript pair (Src and Dst) for dependence.
730 /// Returns true if dependence disproved.
731 /// Can sometimes refine direction vectors.
732 bool testMIV(const SCEV *Src, const SCEV *Dst, const SmallBitVector &Loops,
733 FullDependence &Result) const;
734
735 /// strongSIVtest - Tests the strong SIV subscript pair (Src and Dst)
736 /// for dependence.
737 /// Things of the form [c1 + a*i] and [c2 + a*i],
738 /// where i is an induction variable, c1 and c2 are loop invariant,
739 /// and a is a constant
740 /// Returns true if any possible dependence is disproved.
741 /// If there might be a dependence, returns false.
742 /// Sets appropriate direction and distance.
743 bool strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst,
744 const SCEV *DstConst, const Loop *CurrentSrcLoop,
745 const Loop *CurrentDstLoop, unsigned Level,
746 FullDependence &Result, Constraint &NewConstraint) const;
747
748 /// weakCrossingSIVtest - Tests the weak-crossing SIV subscript pair
749 /// (Src and Dst) for dependence.
750 /// Things of the form [c1 + a*i] and [c2 - a*i],
751 /// where i is an induction variable, c1 and c2 are loop invariant,
752 /// and a is a constant.
753 /// Returns true if any possible dependence is disproved.
754 /// If there might be a dependence, returns false.
755 /// Sets appropriate direction entry.
756 /// Set consistent to false.
757 /// Marks the dependence as splitable.
758 bool weakCrossingSIVtest(const SCEV *SrcCoeff, const SCEV *SrcConst,
759 const SCEV *DstConst, const Loop *CurrentSrcLoop,
760 const Loop *CurrentDstLoop, unsigned Level,
761 FullDependence &Result, Constraint &NewConstraint,
762 const SCEV *&SplitIter) const;
763
764 /// ExactSIVtest - Tests the SIV subscript pair
765 /// (Src and Dst) for dependence.
766 /// Things of the form [c1 + a1*i] and [c2 + a2*i],
767 /// where i is an induction variable, c1 and c2 are loop invariant,
768 /// and a1 and a2 are constant.
769 /// Returns true if any possible dependence is disproved.
770 /// If there might be a dependence, returns false.
771 /// Sets appropriate direction entry.
772 /// Set consistent to false.
773 bool exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
774 const SCEV *SrcConst, const SCEV *DstConst,
775 const Loop *CurrentSrcLoop, const Loop *CurrentDstLoop,
776 unsigned Level, FullDependence &Result,
777 Constraint &NewConstraint) const;
778
779 /// weakZeroSrcSIVtest - Tests the weak-zero SIV subscript pair
780 /// (Src and Dst) for dependence.
781 /// Things of the form [c1] and [c2 + a*i],
782 /// where i is an induction variable, c1 and c2 are loop invariant,
783 /// and a is a constant. See also weakZeroDstSIVtest.
784 /// Returns true if any possible dependence is disproved.
785 /// If there might be a dependence, returns false.
786 /// Sets appropriate direction entry.
787 /// Set consistent to false.
788 /// If loop peeling will break the dependence, mark appropriately.
789 bool weakZeroSrcSIVtest(const SCEV *DstCoeff, const SCEV *SrcConst,
790 const SCEV *DstConst, const Loop *CurrentSrcLoop,
791 const Loop *CurrentDstLoop, unsigned Level,
792 FullDependence &Result,
793 Constraint &NewConstraint) const;
794
795 /// weakZeroDstSIVtest - Tests the weak-zero SIV subscript pair
796 /// (Src and Dst) for dependence.
797 /// Things of the form [c1 + a*i] and [c2],
798 /// where i is an induction variable, c1 and c2 are loop invariant,
799 /// and a is a constant. See also weakZeroSrcSIVtest.
800 /// Returns true if any possible dependence is disproved.
801 /// If there might be a dependence, returns false.
802 /// Sets appropriate direction entry.
803 /// Set consistent to false.
804 /// If loop peeling will break the dependence, mark appropriately.
805 bool weakZeroDstSIVtest(const SCEV *SrcCoeff, const SCEV *SrcConst,
806 const SCEV *DstConst, const Loop *CurrentSrcLoop,
807 const Loop *CurrentDstLoop, unsigned Level,
808 FullDependence &Result,
809 Constraint &NewConstraint) const;
810
811 /// exactRDIVtest - Tests the RDIV subscript pair for dependence.
812 /// Things of the form [c1 + a*i] and [c2 + b*j],
813 /// where i and j are induction variable, c1 and c2 are loop invariant,
814 /// and a and b are constants.
815 /// Returns true if any possible dependence is disproved.
816 /// Marks the result as inconsistent.
817 /// Works in some cases that symbolicRDIVtest doesn't,
818 /// and vice versa.
819 bool exactRDIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
820 const SCEV *SrcConst, const SCEV *DstConst,
821 const Loop *SrcLoop, const Loop *DstLoop,
822 FullDependence &Result) const;
823
824 /// symbolicRDIVtest - Tests the RDIV subscript pair for dependence.
825 /// Things of the form [c1 + a*i] and [c2 + b*j],
826 /// where i and j are induction variable, c1 and c2 are loop invariant,
827 /// and a and b are constants.
828 /// Returns true if any possible dependence is disproved.
829 /// Marks the result as inconsistent.
830 /// Works in some cases that exactRDIVtest doesn't,
831 /// and vice versa. Can also be used as a backup for
832 /// ordinary SIV tests.
833 bool symbolicRDIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
834 const SCEV *SrcConst, const SCEV *DstConst,
835 const Loop *SrcLoop, const Loop *DstLoop) const;
836
837 /// gcdMIVtest - Tests an MIV subscript pair for dependence.
838 /// Returns true if any possible dependence is disproved.
839 /// Marks the result as inconsistent.
840 /// Can sometimes disprove the equal direction for 1 or more loops.
841 // Can handle some symbolics that even the SIV tests don't get,
842 /// so we use it as a backup for everything.
843 bool gcdMIVtest(const SCEV *Src, const SCEV *Dst,
844 FullDependence &Result) const;
845
846 /// banerjeeMIVtest - Tests an MIV subscript pair for dependence.
847 /// Returns true if any possible dependence is disproved.
848 /// Marks the result as inconsistent.
849 /// Computes directions.
850 bool banerjeeMIVtest(const SCEV *Src, const SCEV *Dst,
851 const SmallBitVector &Loops,
852 FullDependence &Result) const;
853
854 /// collectCoeffInfo - Walks through the subscript, collecting each
855 /// coefficient, the associated loop bounds, and recording its positive and
856 /// negative parts for later use.
857 CoefficientInfo *collectCoeffInfo(const SCEV *Subscript, bool SrcFlag,
858 const SCEV *&Constant) const;
859
860 /// Given \p Expr of the form
861 ///
862 /// c_0*X_0*i_0 + c_1*X_1*i_1 + ...c_n*X_n*i_n + C
863 ///
864 /// compute
865 ///
866 /// RunningGCD = gcd(RunningGCD, c_0, c_1, ..., c_n)
867 ///
868 /// where c_0, c_1, ..., and c_n are the constant values. The result is stored
869 /// in \p RunningGCD. Also, the initial value of \p RunningGCD affects the
870 /// result. If we find a term like (c_k * X_k * i_k), where i_k is the
871 /// induction variable of \p CurLoop, c_k is stored in \p CurLoopCoeff and not
872 /// included in the GCD computation. Returns false if we fail to find a
873 /// constant coefficient for some loop, e.g., when a term like (X+Y)*i is
874 /// present. Otherwise returns true.
875 bool accumulateCoefficientsGCD(const SCEV *Expr, const Loop *CurLoop,
876 const SCEV *&CurLoopCoeff,
877 APInt &RunningGCD) const;
878
879 /// getPositivePart - X^+ = max(X, 0).
880 const SCEV *getPositivePart(const SCEV *X) const;
881
882 /// getNegativePart - X^- = min(X, 0).
883 const SCEV *getNegativePart(const SCEV *X) const;
884
885 /// getLowerBound - Looks through all the bounds info and
886 /// computes the lower bound given the current direction settings
887 /// at each level.
888 const SCEV *getLowerBound(BoundInfo *Bound) const;
889
890 /// getUpperBound - Looks through all the bounds info and
891 /// computes the upper bound given the current direction settings
892 /// at each level.
893 const SCEV *getUpperBound(BoundInfo *Bound) const;
894
895 /// exploreDirections - Hierarchically expands the direction vector
896 /// search space, combining the directions of discovered dependences
897 /// in the DirSet field of Bound. Returns the number of distinct
898 /// dependences discovered. If the dependence is disproved,
899 /// it will return 0.
900 unsigned exploreDirections(unsigned Level, CoefficientInfo *A,
901 CoefficientInfo *B, BoundInfo *Bound,
902 const SmallBitVector &Loops,
903 unsigned &DepthExpanded, const SCEV *Delta) const;
904
905 /// testBounds - Returns true iff the current bounds are plausible.
906 bool testBounds(unsigned char DirKind, unsigned Level, BoundInfo *Bound,
907 const SCEV *Delta) const;
908
909 /// findBoundsALL - Computes the upper and lower bounds for level K
910 /// using the * direction. Records them in Bound.
911 void findBoundsALL(CoefficientInfo *A, CoefficientInfo *B, BoundInfo *Bound,
912 unsigned K) const;
913
914 /// findBoundsLT - Computes the upper and lower bounds for level K
915 /// using the < direction. Records them in Bound.
916 void findBoundsLT(CoefficientInfo *A, CoefficientInfo *B, BoundInfo *Bound,
917 unsigned K) const;
918
919 /// findBoundsGT - Computes the upper and lower bounds for level K
920 /// using the > direction. Records them in Bound.
921 void findBoundsGT(CoefficientInfo *A, CoefficientInfo *B, BoundInfo *Bound,
922 unsigned K) const;
923
924 /// findBoundsEQ - Computes the upper and lower bounds for level K
925 /// using the = direction. Records them in Bound.
926 void findBoundsEQ(CoefficientInfo *A, CoefficientInfo *B, BoundInfo *Bound,
927 unsigned K) const;
928
929 /// intersectConstraints - Updates X with the intersection
930 /// of the Constraints X and Y. Returns true if X has changed.
931 bool intersectConstraints(Constraint *X, const Constraint *Y);
932
933 /// propagate - Review the constraints, looking for opportunities
934 /// to simplify a subscript pair (Src and Dst).
935 /// Return true if some simplification occurs.
936 /// If the simplification isn't exact (that is, if it is conservative
937 /// in terms of dependence), set consistent to false.
938 bool propagate(const SCEV *&Src, const SCEV *&Dst, SmallBitVector &Loops,
939 SmallVectorImpl<Constraint> &Constraints, bool &Consistent);
940
941 /// propagateDistance - Attempt to propagate a distance
942 /// constraint into a subscript pair (Src and Dst).
943 /// Return true if some simplification occurs.
944 /// If the simplification isn't exact (that is, if it is conservative
945 /// in terms of dependence), set consistent to false.
946 bool propagateDistance(const SCEV *&Src, const SCEV *&Dst,
947 Constraint &CurConstraint, bool &Consistent);
948
949 /// propagatePoint - Attempt to propagate a point
950 /// constraint into a subscript pair (Src and Dst).
951 /// Return true if some simplification occurs.
952 bool propagatePoint(const SCEV *&Src, const SCEV *&Dst,
953 Constraint &CurConstraint);
954
955 /// propagateLine - Attempt to propagate a line
956 /// constraint into a subscript pair (Src and Dst).
957 /// Return true if some simplification occurs.
958 /// If the simplification isn't exact (that is, if it is conservative
959 /// in terms of dependence), set consistent to false.
960 bool propagateLine(const SCEV *&Src, const SCEV *&Dst,
961 Constraint &CurConstraint, bool &Consistent);
962
963 /// findCoefficient - Given a linear SCEV,
964 /// return the coefficient corresponding to specified loop.
965 /// If there isn't one, return the SCEV constant 0.
966 /// For example, given a*i + b*j + c*k, returning the coefficient
967 /// corresponding to the j loop would yield b.
968 const SCEV *findCoefficient(const SCEV *Expr, const Loop *TargetLoop) const;
969
970 /// zeroCoefficient - Given a linear SCEV,
971 /// return the SCEV given by zeroing out the coefficient
972 /// corresponding to the specified loop.
973 /// For example, given a*i + b*j + c*k, zeroing the coefficient
974 /// corresponding to the j loop would yield a*i + c*k.
975 const SCEV *zeroCoefficient(const SCEV *Expr, const Loop *TargetLoop) const;
976
977 /// addToCoefficient - Given a linear SCEV Expr,
978 /// return the SCEV given by adding some Value to the
979 /// coefficient corresponding to the specified TargetLoop.
980 /// For example, given a*i + b*j + c*k, adding 1 to the coefficient
981 /// corresponding to the j loop would yield a*i + (b+1)*j + c*k.
982 const SCEV *addToCoefficient(const SCEV *Expr, const Loop *TargetLoop,
983 const SCEV *Value) const;
984
985 /// updateDirection - Update direction vector entry
986 /// based on the current constraint.
987 void updateDirection(Dependence::DVEntry &Level,
988 const Constraint &CurConstraint) const;
989
990 /// Given a linear access function, tries to recover subscripts
991 /// for each dimension of the array element access.
992 bool tryDelinearize(Instruction *Src, Instruction *Dst,
993 SmallVectorImpl<Subscript> &Pair);
994
995 /// Tries to delinearize \p Src and \p Dst access functions for a fixed size
996 /// multi-dimensional array. Calls tryDelinearizeFixedSizeImpl() to
997 /// delinearize \p Src and \p Dst separately,
998 bool tryDelinearizeFixedSize(Instruction *Src, Instruction *Dst,
999 const SCEV *SrcAccessFn, const SCEV *DstAccessFn,
1000 SmallVectorImpl<const SCEV *> &SrcSubscripts,
1001 SmallVectorImpl<const SCEV *> &DstSubscripts);
1002
1003 /// Tries to delinearize access function for a multi-dimensional array with
1004 /// symbolic runtime sizes.
1005 /// Returns true upon success and false otherwise.
1006 bool
1007 tryDelinearizeParametricSize(Instruction *Src, Instruction *Dst,
1008 const SCEV *SrcAccessFn, const SCEV *DstAccessFn,
1009 SmallVectorImpl<const SCEV *> &SrcSubscripts,
1010 SmallVectorImpl<const SCEV *> &DstSubscripts);
1011
1012 /// checkSubscript - Helper function for checkSrcSubscript and
1013 /// checkDstSubscript to avoid duplicate code
1014 bool checkSubscript(const SCEV *Expr, const Loop *LoopNest,
1015 SmallBitVector &Loops, bool IsSrc);
1016}; // class DependenceInfo
1017
1018/// AnalysisPass to compute dependence information in a function
1019class DependenceAnalysis : public AnalysisInfoMixin<DependenceAnalysis> {
1020public:
1023
1024private:
1027}; // class DependenceAnalysis
1028
1029/// Printer pass to dump DA results.
1031 : public PassInfoMixin<DependenceAnalysisPrinterPass> {
1032 DependenceAnalysisPrinterPass(raw_ostream &OS, bool NormalizeResults = false)
1033 : OS(OS), NormalizeResults(NormalizeResults) {}
1034
1036
1037 static bool isRequired() { return true; }
1038
1039private:
1040 raw_ostream &OS;
1041 bool NormalizeResults;
1042}; // class DependenceAnalysisPrinterPass
1043
1044/// Legacy pass manager pass to access dependence information
1046public:
1047 static char ID; // Class identification, replacement for typeinfo
1049
1050 bool runOnFunction(Function &F) override;
1051 void releaseMemory() override;
1052 void getAnalysisUsage(AnalysisUsage &) const override;
1053 void print(raw_ostream &, const Module * = nullptr) const override;
1054 DependenceInfo &getDI() const;
1055
1056private:
1057 std::unique_ptr<DependenceInfo> info;
1058}; // class DependenceAnalysisWrapperPass
1059
1060/// createDependenceAnalysisPass - This creates an instance of the
1061/// DependenceAnalysis wrapper pass.
1063
1064} // namespace llvm
1065
1066#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:213
static bool runOnFunction(Function &F, bool PostInlining)
Hexagon Hardware Loops
This header defines various interfaces for pass management in LLVM.
#define F(x, y, z)
Definition MD5.cpp:55
#define T
static bool isInput(const ArrayRef< StringRef > &Prefixes, StringRef Arg)
Definition OptTable.cpp:146
FunctionAnalysisManager FAM
This file implements the SmallBitVector class.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
Represent the analysis usage information of a pass.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:678
void getAnalysisUsage(AnalysisUsage &) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
AnalysisPass to compute dependence information in a function.
LLVM_ABI Result run(Function &F, FunctionAnalysisManager &FAM)
DependenceInfo - This class is the main dependence-analysis driver.
LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle transitive invalidation when the cached analysis results go away.
LLVM_ABI const SCEV * getSplitIteration(const Dependence &Dep, unsigned Level)
getSplitIteration - Give a dependence that's splittable at some particular level, return the iteratio...
Function * getFunction() const
LLVM_ABI SCEVUnionPredicate getRuntimeAssumptions() const
getRuntimeAssumptions - Returns all the runtime assumptions under which the dependence test is valid.
DependenceInfo(Function *F, AAResults *AA, ScalarEvolution *SE, LoopInfo *LI)
LLVM_ABI std::unique_ptr< Dependence > depends(Instruction *Src, Instruction *Dst, bool UnderRuntimeAssumptions=false)
depends - Tests for a dependence between the Src and Dst instructions.
Dependence - This class represents a dependence between two memory memory references in a function.
Instruction * getDst() const
getDst - Returns the destination instruction for this dependence.
Dependence & operator=(Dependence &&)=default
bool isOrdered() const
isOrdered - Returns true if dependence is Output, Flow, or Anti
void setNextSuccessor(const Dependence *succ)
setNextSuccessor - Sets the value of the NextSuccessor field.
friend class DependenceInfo
Dependence(Instruction *Source, Instruction *Destination, const SCEVUnionPredicate &A)
Dependence(Dependence &&)=default
bool isUnordered() const
isUnordered - Returns true if dependence is Input
SCEVUnionPredicate getRuntimeAssumptions() const
getRuntimeAssumptions - Returns the runtime assumptions under which this Dependence relation is valid...
virtual bool isConfused() const
isConfused - Returns true if this dependence is confused (the compiler understands nothing and makes ...
virtual unsigned getSameSDLevels() const
getSameSDLevels - Returns the number of separate SameSD loops surrounding the source and destination ...
virtual const SCEV * getDistance(unsigned Level, bool SameSD=false) const
getDistance - Returns the distance (or NULL) associated with a particular common or SameSD level.
virtual bool isPeelLast(unsigned Level, bool SameSD=false) const
isPeelLast - Returns true if peeling the last iteration from this regular or SameSD loop level will b...
virtual bool isConsistent() const
isConsistent - Returns true if this dependence is consistent (occurs every time the source and destin...
virtual unsigned getLevels() const
getLevels - Returns the number of common loops surrounding the source and destination of the dependen...
const Dependence * getNextPredecessor() const
getNextPredecessor - Returns the value of the NextPredecessor field.
virtual unsigned getDirection(unsigned Level, bool SameSD=false) const
getDirection - Returns the direction associated with a particular common or SameSD level.
DVEntry getDVEntry(unsigned Level, bool isSameSD) const
getDVEntry - Returns the DV entry associated with a regular or a SameSD level
bool isFlow() const
isFlow - Returns true if this is a flow (aka true) dependence.
virtual bool isPeelFirst(unsigned Level, bool SameSD=false) const
isPeelFirst - Returns true if peeling the first iteration from this regular or SameSD loop level will...
virtual ~Dependence()=default
virtual bool normalize(ScalarEvolution *SE)
If the direction vector is negative, normalize the direction vector to make it non-negative.
bool isAnti() const
isAnti - Returns true if this is an anti dependence.
virtual bool isSplitable(unsigned Level, bool SameSD=false) const
isSplitable - Returns true if splitting the loop will break the dependence.
const Dependence * getNextSuccessor() const
getNextSuccessor - Returns the value of the NextSuccessor field.
virtual bool isDirectionNegative() const
Check if the direction vector is negative.
Instruction * getSrc() const
getSrc - Returns the source instruction for this dependence.
virtual bool isLoopIndependent() const
isLoopIndependent - Returns true if this is a loop-independent dependence.
bool isOutput() const
isOutput - Returns true if this is an output dependence.
void setNextPredecessor(const Dependence *pred)
setNextPredecessor - Sets the value of the NextPredecessor field.
virtual bool inSameSDLoops(unsigned Level) const
inSameSDLoops - Returns true if this level is an SameSD level, i.e., performed across two separate lo...
FullDependence(Instruction *Source, Instruction *Destination, const SCEVUnionPredicate &Assumes, bool PossiblyLoopIndependent, unsigned Levels)
bool isConfused() const override
isConfused - Returns true if this dependence is confused (the compiler understands nothing and makes ...
bool isLoopIndependent() const override
isLoopIndependent - Returns true if this is a loop-independent dependence.
unsigned getSameSDLevels() const override
getSameSDLevels - Returns the number of separate SameSD loops surrounding the source and destination ...
unsigned getLevels() const override
getLevels - Returns the number of common loops surrounding the source and destination of the dependen...
DVEntry getDVEntry(unsigned Level, bool isSameSD) const
getDVEntry - Returns the DV entry associated with a regular or a SameSD level.
bool isConsistent() const override
isConsistent - Returns true if this dependence is consistent (occurs every time the source and destin...
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
FunctionPass(char &pid)
Definition Pass.h:316
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
This class represents a constant integer value.
This class represents a composition of other SCEV predicates, and is the class that most clients will...
This class represents an analyzed expression in the program.
The main scalar evolution driver.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
Abstract Attribute helper functions.
Definition Attributor.h:165
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
FunctionAddr VTableAddr Value
Definition InstrProf.h:137
ArrayRef(const T &OneElt) -> ArrayRef< T >
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI FunctionPass * createDependenceAnalysisWrapperPass()
createDependenceAnalysisPass - This creates an instance of the DependenceAnalysis wrapper pass.
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition PassManager.h:93
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29
DependenceAnalysisPrinterPass(raw_ostream &OS, bool NormalizeResults=false)
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
Dependence::DVEntry - Each level in the distance/direction vector has a direction (or perhaps a union...
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition PassManager.h:70