Thanks to visit codestin.com
Credit goes to llvm.org

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 &&
291 Level <= static_cast<unsigned>(Levels) + SameSDLevels &&
292 "isSameSD level out of range");
293 return DVSameSD[Level - Levels - 1];
294 }
295 }
296
297 /// getDirection - Returns the direction associated with a particular
298 /// common or SameSD level.
299 unsigned getDirection(unsigned Level, bool SameSD = false) const override;
300
301 /// getDistance - Returns the distance (or NULL) associated with a
302 /// particular common or SameSD level.
303 const SCEV *getDistance(unsigned Level, bool SameSD = false) const override;
304
305 /// Check if the direction vector is negative. A negative direction
306 /// vector means Src and Dst are reversed in the actual program.
307 bool isDirectionNegative() const override;
308
309 /// If the direction vector is negative, normalize the direction
310 /// vector to make it non-negative. Normalization is done by reversing
311 /// Src and Dst, plus reversing the dependence directions and distances
312 /// in the vector.
313 bool normalize(ScalarEvolution *SE) override;
314
315 /// isPeelFirst - Returns true if peeling the first iteration from
316 /// this regular or SameSD loop level will break this dependence.
317 bool isPeelFirst(unsigned Level, bool SameSD = false) const override;
318
319 /// isPeelLast - Returns true if peeling the last iteration from
320 /// this regular or SameSD loop level will break this dependence.
321 bool isPeelLast(unsigned Level, bool SameSD = false) const override;
322
323 /// isSplitable - Returns true if splitting the loop will break
324 /// the dependence.
325 bool isSplitable(unsigned Level, bool SameSD = false) const override;
326
327 /// inSameSDLoops - Returns true if this level is an SameSD level, i.e.,
328 /// performed across two separate loop nests that have the Same Iteration and
329 /// Depth.
330 bool inSameSDLoops(unsigned Level) const override;
331
332 /// isScalar - Returns true if a particular regular or SameSD level is
333 /// scalar; that is, if no subscript in the source or destination mention
334 /// the induction variable associated with the loop at this level.
335 bool isScalar(unsigned Level, bool SameSD = false) const override;
336
337private:
338 unsigned short Levels;
339 unsigned short SameSDLevels;
340 bool LoopIndependent;
341 bool Consistent; // Init to true, then refine.
342 std::unique_ptr<DVEntry[]> DV;
343 std::unique_ptr<DVEntry[]> DVSameSD; // DV entries on SameSD levels
344 friend class DependenceInfo;
345};
346
347/// DependenceInfo - This class is the main dependence-analysis driver.
349public:
351 : AA(AA), SE(SE), LI(LI), F(F) {}
352
353 /// Handle transitive invalidation when the cached analysis results go away.
355 FunctionAnalysisManager::Invalidator &Inv);
356
357 /// depends - Tests for a dependence between the Src and Dst instructions.
358 /// Returns NULL if no dependence; otherwise, returns a Dependence (or a
359 /// FullDependence) with as much information as can be gleaned. By default,
360 /// the dependence test collects a set of runtime assumptions that cannot be
361 /// solved at compilation time. By default UnderRuntimeAssumptions is false
362 /// for a safe approximation of the dependence relation that does not
363 /// require runtime checks.
364 LLVM_ABI std::unique_ptr<Dependence>
366 bool UnderRuntimeAssumptions = false);
367
368 /// getSplitIteration - Give a dependence that's splittable at some
369 /// particular level, return the iteration that should be used to split
370 /// the loop.
371 ///
372 /// Generally, the dependence analyzer will be used to build
373 /// a dependence graph for a function (basically a map from instructions
374 /// to dependences). Looking for cycles in the graph shows us loops
375 /// that cannot be trivially vectorized/parallelized.
376 ///
377 /// We can try to improve the situation by examining all the dependences
378 /// that make up the cycle, looking for ones we can break.
379 /// Sometimes, peeling the first or last iteration of a loop will break
380 /// dependences, and there are flags for those possibilities.
381 /// Sometimes, splitting a loop at some other iteration will do the trick,
382 /// and we've got a flag for that case. Rather than waste the space to
383 /// record the exact iteration (since we rarely know), we provide
384 /// a method that calculates the iteration. It's a drag that it must work
385 /// from scratch, but wonderful in that it's possible.
386 ///
387 /// Here's an example:
388 ///
389 /// for (i = 0; i < 10; i++)
390 /// A[i] = ...
391 /// ... = A[11 - i]
392 ///
393 /// There's a loop-carried flow dependence from the store to the load,
394 /// found by the weak-crossing SIV test. The dependence will have a flag,
395 /// indicating that the dependence can be broken by splitting the loop.
396 /// Calling getSplitIteration will return 5.
397 /// Splitting the loop breaks the dependence, like so:
398 ///
399 /// for (i = 0; i <= 5; i++)
400 /// A[i] = ...
401 /// ... = A[11 - i]
402 /// for (i = 6; i < 10; i++)
403 /// A[i] = ...
404 /// ... = A[11 - i]
405 ///
406 /// breaks the dependence and allows us to vectorize/parallelize
407 /// both loops.
408 LLVM_ABI const SCEV *getSplitIteration(const Dependence &Dep, unsigned Level);
409
410 Function *getFunction() const { return F; }
411
412 /// getRuntimeAssumptions - Returns all the runtime assumptions under which
413 /// the dependence test is valid.
415
416private:
417 AAResults *AA;
418 ScalarEvolution *SE;
419 LoopInfo *LI;
420 Function *F;
422
423 /// Subscript - This private struct represents a pair of subscripts from
424 /// a pair of potentially multi-dimensional array references. We use a
425 /// vector of them to guide subscript partitioning.
426 struct Subscript {
427 const SCEV *Src;
428 const SCEV *Dst;
429 enum ClassificationKind { ZIV, SIV, RDIV, MIV, NonLinear } Classification;
430 SmallBitVector Loops;
431 SmallBitVector GroupLoops;
432 SmallBitVector Group;
433 };
434
435 struct CoefficientInfo {
436 const SCEV *Coeff;
437 const SCEV *PosPart;
438 const SCEV *NegPart;
439 const SCEV *Iterations;
440 };
441
442 struct BoundInfo {
443 const SCEV *Iterations;
444 const SCEV *Upper[8];
445 const SCEV *Lower[8];
446 unsigned char Direction;
447 unsigned char DirSet;
448 };
449
450 /// Constraint - This private class represents a constraint, as defined
451 /// in the paper
452 ///
453 /// Practical Dependence Testing
454 /// Goff, Kennedy, Tseng
455 /// PLDI 1991
456 ///
457 /// There are 5 kinds of constraint, in a hierarchy.
458 /// 1) Any - indicates no constraint, any dependence is possible.
459 /// 2) Line - A line ax + by = c, where a, b, and c are parameters,
460 /// representing the dependence equation.
461 /// 3) Distance - The value d of the dependence distance;
462 /// 4) Point - A point <x, y> representing the dependence from
463 /// iteration x to iteration y.
464 /// 5) Empty - No dependence is possible.
465 class Constraint {
466 private:
467 enum ConstraintKind { Empty, Point, Distance, Line, Any } Kind;
468 ScalarEvolution *SE;
469 const SCEV *A;
470 const SCEV *B;
471 const SCEV *C;
472 const Loop *AssociatedSrcLoop;
473 const Loop *AssociatedDstLoop;
474
475 public:
476 /// isEmpty - Return true if the constraint is of kind Empty.
477 bool isEmpty() const { return Kind == Empty; }
478
479 /// isPoint - Return true if the constraint is of kind Point.
480 bool isPoint() const { return Kind == Point; }
481
482 /// isDistance - Return true if the constraint is of kind Distance.
483 bool isDistance() const { return Kind == Distance; }
484
485 /// isLine - Return true if the constraint is of kind Line.
486 /// Since Distance's can also be represented as Lines, we also return
487 /// true if the constraint is of kind Distance.
488 bool isLine() const { return Kind == Line || Kind == Distance; }
489
490 /// isAny - Return true if the constraint is of kind Any;
491 bool isAny() const { return Kind == Any; }
492
493 /// getX - If constraint is a point <X, Y>, returns X.
494 /// Otherwise assert.
495 LLVM_ABI const SCEV *getX() const;
496
497 /// getY - If constraint is a point <X, Y>, returns Y.
498 /// Otherwise assert.
499 LLVM_ABI const SCEV *getY() const;
500
501 /// getA - If constraint is a line AX + BY = C, returns A.
502 /// Otherwise assert.
503 LLVM_ABI const SCEV *getA() const;
504
505 /// getB - If constraint is a line AX + BY = C, returns B.
506 /// Otherwise assert.
507 LLVM_ABI const SCEV *getB() const;
508
509 /// getC - If constraint is a line AX + BY = C, returns C.
510 /// Otherwise assert.
511 LLVM_ABI const SCEV *getC() const;
512
513 /// getD - If constraint is a distance, returns D.
514 /// Otherwise assert.
515 LLVM_ABI const SCEV *getD() const;
516
517 /// getAssociatedSrcLoop - Returns the source loop associated with this
518 /// constraint.
519 LLVM_ABI const Loop *getAssociatedSrcLoop() const;
520
521 /// getAssociatedDstLoop - Returns the destination loop associated with
522 /// this constraint.
523 LLVM_ABI const Loop *getAssociatedDstLoop() const;
524
525 /// setPoint - Change a constraint to Point.
526 LLVM_ABI void setPoint(const SCEV *X, const SCEV *Y,
527 const Loop *CurrentSrcLoop,
528 const Loop *CurrentDstLoop);
529
530 /// setLine - Change a constraint to Line.
531 LLVM_ABI void setLine(const SCEV *A, const SCEV *B, const SCEV *C,
532 const Loop *CurrentSrcLoop,
533 const Loop *CurrentDstLoop);
534
535 /// setDistance - Change a constraint to Distance.
536 LLVM_ABI void setDistance(const SCEV *D, const Loop *CurrentSrcLoop,
537 const Loop *CurrentDstLoop);
538
539 /// setEmpty - Change a constraint to Empty.
540 LLVM_ABI void setEmpty();
541
542 /// setAny - Change a constraint to Any.
543 LLVM_ABI void setAny(ScalarEvolution *SE);
544
545 /// dump - For debugging purposes. Dumps the constraint
546 /// out to OS.
547 LLVM_ABI void dump(raw_ostream &OS) const;
548 };
549
550 /// Returns true if two loops have the Same iteration Space and Depth. To be
551 /// more specific, two loops have SameSD if they are in the same nesting
552 /// depth and have the same backedge count. SameSD stands for Same iteration
553 /// Space and Depth.
554 bool haveSameSD(const Loop *SrcLoop, const Loop *DstLoop) const;
555
556 /// establishNestingLevels - Examines the loop nesting of the Src and Dst
557 /// instructions and establishes their shared loops. Sets the variables
558 /// CommonLevels, SrcLevels, and MaxLevels.
559 /// The source and destination instructions needn't be contained in the same
560 /// loop. The routine establishNestingLevels finds the level of most deeply
561 /// nested loop that contains them both, CommonLevels. An instruction that's
562 /// not contained in a loop is at level = 0. MaxLevels is equal to the level
563 /// of the source plus the level of the destination, minus CommonLevels.
564 /// This lets us allocate vectors MaxLevels in length, with room for every
565 /// distinct loop referenced in both the source and destination subscripts.
566 /// The variable SrcLevels is the nesting depth of the source instruction.
567 /// It's used to help calculate distinct loops referenced by the destination.
568 /// Here's the map from loops to levels:
569 /// 0 - unused
570 /// 1 - outermost common loop
571 /// ... - other common loops
572 /// CommonLevels - innermost common loop
573 /// ... - loops containing Src but not Dst
574 /// SrcLevels - innermost loop containing Src but not Dst
575 /// ... - loops containing Dst but not Src
576 /// MaxLevels - innermost loop containing Dst but not Src
577 /// Consider the follow code fragment:
578 /// for (a = ...) {
579 /// for (b = ...) {
580 /// for (c = ...) {
581 /// for (d = ...) {
582 /// A[] = ...;
583 /// }
584 /// }
585 /// for (e = ...) {
586 /// for (f = ...) {
587 /// for (g = ...) {
588 /// ... = A[];
589 /// }
590 /// }
591 /// }
592 /// }
593 /// }
594 /// If we're looking at the possibility of a dependence between the store
595 /// to A (the Src) and the load from A (the Dst), we'll note that they
596 /// have 2 loops in common, so CommonLevels will equal 2 and the direction
597 /// vector for Result will have 2 entries. SrcLevels = 4 and MaxLevels = 7.
598 /// A map from loop names to level indices would look like
599 /// a - 1
600 /// b - 2 = CommonLevels
601 /// c - 3
602 /// d - 4 = SrcLevels
603 /// e - 5
604 /// f - 6
605 /// g - 7 = MaxLevels
606 /// SameSDLevels counts the number of levels after common levels that are
607 /// not common but have the same iteration space and depth. Internally this
608 /// is checked using haveSameSD. Assume that in this code fragment, levels c
609 /// and e have the same iteration space and depth, but levels d and f does
610 /// not. Then SameSDLevels is set to 1. In that case the level numbers for the
611 /// previous code look like
612 /// a - 1
613 /// b - 2
614 /// c,e - 3 = CommonLevels
615 /// d - 4 = SrcLevels
616 /// f - 5
617 /// g - 6 = MaxLevels
618 void establishNestingLevels(const Instruction *Src, const Instruction *Dst);
619
620 unsigned CommonLevels, SrcLevels, MaxLevels, SameSDLevels;
621
622 /// mapSrcLoop - Given one of the loops containing the source, return
623 /// its level index in our numbering scheme.
624 unsigned mapSrcLoop(const Loop *SrcLoop) const;
625
626 /// mapDstLoop - Given one of the loops containing the destination,
627 /// return its level index in our numbering scheme.
628 unsigned mapDstLoop(const Loop *DstLoop) const;
629
630 /// isLoopInvariant - Returns true if Expression is loop invariant
631 /// in LoopNest.
632 bool isLoopInvariant(const SCEV *Expression, const Loop *LoopNest) const;
633
634 /// Makes sure all subscript pairs share the same integer type by
635 /// sign-extending as necessary.
636 /// Sign-extending a subscript is safe because getelementptr assumes the
637 /// array subscripts are signed.
638 void unifySubscriptType(ArrayRef<Subscript *> Pairs);
639
640 /// removeMatchingExtensions - Examines a subscript pair.
641 /// If the source and destination are identically sign (or zero)
642 /// extended, it strips off the extension in an effort to
643 /// simplify the actual analysis.
644 void removeMatchingExtensions(Subscript *Pair);
645
646 /// collectCommonLoops - Finds the set of loops from the LoopNest that
647 /// have a level <= CommonLevels and are referred to by the SCEV Expression.
648 void collectCommonLoops(const SCEV *Expression, const Loop *LoopNest,
649 SmallBitVector &Loops) const;
650
651 /// checkSrcSubscript - Examines the SCEV Src, returning true iff it's
652 /// linear. Collect the set of loops mentioned by Src.
653 bool checkSrcSubscript(const SCEV *Src, const Loop *LoopNest,
654 SmallBitVector &Loops);
655
656 /// checkDstSubscript - Examines the SCEV Dst, returning true iff it's
657 /// linear. Collect the set of loops mentioned by Dst.
658 bool checkDstSubscript(const SCEV *Dst, const Loop *LoopNest,
659 SmallBitVector &Loops);
660
661 /// isKnownPredicate - Compare X and Y using the predicate Pred.
662 /// Basically a wrapper for SCEV::isKnownPredicate,
663 /// but tries harder, especially in the presence of sign and zero
664 /// extensions and symbolics.
665 bool isKnownPredicate(ICmpInst::Predicate Pred, const SCEV *X,
666 const SCEV *Y) const;
667
668 /// isKnownLessThan - Compare to see if S is less than Size
669 /// Another wrapper for isKnownNegative(S - max(Size, 1)) with some extra
670 /// checking if S is an AddRec and we can prove lessthan using the loop
671 /// bounds.
672 bool isKnownLessThan(const SCEV *S, const SCEV *Size) const;
673
674 /// isKnownNonNegative - Compare to see if S is known not to be negative
675 /// Uses the fact that S comes from Ptr, which may be an inbound GEP,
676 /// Proving there is no wrapping going on.
677 bool isKnownNonNegative(const SCEV *S, const Value *Ptr) const;
678
679 /// collectUpperBound - All subscripts are the same type (on my machine,
680 /// an i64). The loop bound may be a smaller type. collectUpperBound
681 /// find the bound, if available, and zero extends it to the Type T.
682 /// (I zero extend since the bound should always be >= 0.)
683 /// If no upper bound is available, return NULL.
684 const SCEV *collectUpperBound(const Loop *l, Type *T) const;
685
686 /// collectConstantUpperBound - Calls collectUpperBound(), then
687 /// attempts to cast it to SCEVConstant. If the cast fails,
688 /// returns NULL.
689 const SCEVConstant *collectConstantUpperBound(const Loop *l, Type *T) const;
690
691 /// classifyPair - Examines the subscript pair (the Src and Dst SCEVs)
692 /// and classifies it as either ZIV, SIV, RDIV, MIV, or Nonlinear.
693 /// Collects the associated loops in a set.
694 Subscript::ClassificationKind
695 classifyPair(const SCEV *Src, const Loop *SrcLoopNest, const SCEV *Dst,
696 const Loop *DstLoopNest, SmallBitVector &Loops);
697
698 /// testZIV - Tests the ZIV subscript pair (Src and Dst) for dependence.
699 /// Returns true if any possible dependence is disproved.
700 /// If there might be a dependence, returns false.
701 /// If the dependence isn't proven to exist,
702 /// marks the Result as inconsistent.
703 bool testZIV(const SCEV *Src, const SCEV *Dst, FullDependence &Result) const;
704
705 /// testSIV - Tests the SIV subscript pair (Src and Dst) for dependence.
706 /// Things of the form [c1 + a1*i] and [c2 + a2*j], where
707 /// i and j are induction variables, c1 and c2 are loop invariant,
708 /// and a1 and a2 are constant.
709 /// Returns true if any possible dependence is disproved.
710 /// If there might be a dependence, returns false.
711 /// Sets appropriate direction vector entry and, when possible,
712 /// the distance vector entry.
713 /// If the dependence isn't proven to exist,
714 /// marks the Result as inconsistent.
715 bool testSIV(const SCEV *Src, const SCEV *Dst, unsigned &Level,
716 FullDependence &Result, Constraint &NewConstraint,
717 const SCEV *&SplitIter) const;
718
719 /// testRDIV - Tests the RDIV subscript pair (Src and Dst) for dependence.
720 /// Things of the form [c1 + a1*i] and [c2 + a2*j]
721 /// where i and j are induction variables, c1 and c2 are loop invariant,
722 /// and a1 and a2 are constant.
723 /// With minor algebra, this test can also be used for things like
724 /// [c1 + a1*i + a2*j][c2].
725 /// Returns true if any possible dependence is disproved.
726 /// If there might be a dependence, returns false.
727 /// Marks the Result as inconsistent.
728 bool testRDIV(const SCEV *Src, const SCEV *Dst, FullDependence &Result) const;
729
730 /// testMIV - Tests the MIV subscript pair (Src and Dst) for dependence.
731 /// Returns true if dependence disproved.
732 /// Can sometimes refine direction vectors.
733 bool testMIV(const SCEV *Src, const SCEV *Dst, const SmallBitVector &Loops,
734 FullDependence &Result) const;
735
736 /// strongSIVtest - Tests the strong SIV subscript pair (Src and Dst)
737 /// for dependence.
738 /// Things of the form [c1 + a*i] and [c2 + a*i],
739 /// where i is an induction variable, c1 and c2 are loop invariant,
740 /// and a is a constant
741 /// Returns true if any possible dependence is disproved.
742 /// If there might be a dependence, returns false.
743 /// Sets appropriate direction and distance.
744 bool strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst,
745 const SCEV *DstConst, const Loop *CurrentSrcLoop,
746 const Loop *CurrentDstLoop, unsigned Level,
747 FullDependence &Result, Constraint &NewConstraint) const;
748
749 /// weakCrossingSIVtest - Tests the weak-crossing SIV subscript pair
750 /// (Src and Dst) for dependence.
751 /// Things of the form [c1 + a*i] and [c2 - a*i],
752 /// where i is an induction variable, c1 and c2 are loop invariant,
753 /// and a is a constant.
754 /// Returns true if any possible dependence is disproved.
755 /// If there might be a dependence, returns false.
756 /// Sets appropriate direction entry.
757 /// Set consistent to false.
758 /// Marks the dependence as splitable.
759 bool weakCrossingSIVtest(const SCEV *SrcCoeff, const SCEV *SrcConst,
760 const SCEV *DstConst, const Loop *CurrentSrcLoop,
761 const Loop *CurrentDstLoop, unsigned Level,
762 FullDependence &Result, Constraint &NewConstraint,
763 const SCEV *&SplitIter) const;
764
765 /// ExactSIVtest - Tests the SIV subscript pair
766 /// (Src and Dst) for dependence.
767 /// Things of the form [c1 + a1*i] and [c2 + a2*i],
768 /// where i is an induction variable, c1 and c2 are loop invariant,
769 /// and a1 and a2 are constant.
770 /// Returns true if any possible dependence is disproved.
771 /// If there might be a dependence, returns false.
772 /// Sets appropriate direction entry.
773 /// Set consistent to false.
774 bool exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
775 const SCEV *SrcConst, const SCEV *DstConst,
776 const Loop *CurrentSrcLoop, const Loop *CurrentDstLoop,
777 unsigned Level, FullDependence &Result,
778 Constraint &NewConstraint) const;
779
780 /// weakZeroSrcSIVtest - Tests the weak-zero SIV subscript pair
781 /// (Src and Dst) for dependence.
782 /// Things of the form [c1] and [c2 + a*i],
783 /// where i is an induction variable, c1 and c2 are loop invariant,
784 /// and a is a constant. See also weakZeroDstSIVtest.
785 /// Returns true if any possible dependence is disproved.
786 /// If there might be a dependence, returns false.
787 /// Sets appropriate direction entry.
788 /// Set consistent to false.
789 /// If loop peeling will break the dependence, mark appropriately.
790 bool weakZeroSrcSIVtest(const SCEV *DstCoeff, const SCEV *SrcConst,
791 const SCEV *DstConst, const Loop *CurrentSrcLoop,
792 const Loop *CurrentDstLoop, unsigned Level,
793 FullDependence &Result,
794 Constraint &NewConstraint) const;
795
796 /// weakZeroDstSIVtest - Tests the weak-zero SIV subscript pair
797 /// (Src and Dst) for dependence.
798 /// Things of the form [c1 + a*i] and [c2],
799 /// where i is an induction variable, c1 and c2 are loop invariant,
800 /// and a is a constant. See also weakZeroSrcSIVtest.
801 /// Returns true if any possible dependence is disproved.
802 /// If there might be a dependence, returns false.
803 /// Sets appropriate direction entry.
804 /// Set consistent to false.
805 /// If loop peeling will break the dependence, mark appropriately.
806 bool weakZeroDstSIVtest(const SCEV *SrcCoeff, const SCEV *SrcConst,
807 const SCEV *DstConst, const Loop *CurrentSrcLoop,
808 const Loop *CurrentDstLoop, unsigned Level,
809 FullDependence &Result,
810 Constraint &NewConstraint) const;
811
812 /// exactRDIVtest - Tests the RDIV subscript pair for dependence.
813 /// Things of the form [c1 + a*i] and [c2 + b*j],
814 /// where i and j are induction variable, c1 and c2 are loop invariant,
815 /// and a and b are constants.
816 /// Returns true if any possible dependence is disproved.
817 /// Marks the result as inconsistent.
818 /// Works in some cases that symbolicRDIVtest doesn't,
819 /// and vice versa.
820 bool exactRDIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
821 const SCEV *SrcConst, const SCEV *DstConst,
822 const Loop *SrcLoop, const Loop *DstLoop,
823 FullDependence &Result) const;
824
825 /// symbolicRDIVtest - Tests the RDIV subscript pair for dependence.
826 /// Things of the form [c1 + a*i] and [c2 + b*j],
827 /// where i and j are induction variable, c1 and c2 are loop invariant,
828 /// and a and b are constants.
829 /// Returns true if any possible dependence is disproved.
830 /// Marks the result as inconsistent.
831 /// Works in some cases that exactRDIVtest doesn't,
832 /// and vice versa. Can also be used as a backup for
833 /// ordinary SIV tests.
834 bool symbolicRDIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
835 const SCEV *SrcConst, const SCEV *DstConst,
836 const Loop *SrcLoop, const Loop *DstLoop) const;
837
838 /// gcdMIVtest - Tests an MIV subscript pair for dependence.
839 /// Returns true if any possible dependence is disproved.
840 /// Marks the result as inconsistent.
841 /// Can sometimes disprove the equal direction for 1 or more loops.
842 // Can handle some symbolics that even the SIV tests don't get,
843 /// so we use it as a backup for everything.
844 bool gcdMIVtest(const SCEV *Src, const SCEV *Dst,
845 FullDependence &Result) const;
846
847 /// banerjeeMIVtest - Tests an MIV subscript pair for dependence.
848 /// Returns true if any possible dependence is disproved.
849 /// Marks the result as inconsistent.
850 /// Computes directions.
851 bool banerjeeMIVtest(const SCEV *Src, const SCEV *Dst,
852 const SmallBitVector &Loops,
853 FullDependence &Result) const;
854
855 /// collectCoeffInfo - Walks through the subscript, collecting each
856 /// coefficient, the associated loop bounds, and recording its positive and
857 /// negative parts for later use.
858 CoefficientInfo *collectCoeffInfo(const SCEV *Subscript, bool SrcFlag,
859 const SCEV *&Constant) const;
860
861 /// Given \p Expr of the form
862 ///
863 /// c_0*X_0*i_0 + c_1*X_1*i_1 + ...c_n*X_n*i_n + C
864 ///
865 /// compute
866 ///
867 /// RunningGCD = gcd(RunningGCD, c_0, c_1, ..., c_n)
868 ///
869 /// where c_0, c_1, ..., and c_n are the constant values. The result is stored
870 /// in \p RunningGCD. Also, the initial value of \p RunningGCD affects the
871 /// result. If we find a term like (c_k * X_k * i_k), where i_k is the
872 /// induction variable of \p CurLoop, c_k is stored in \p CurLoopCoeff and not
873 /// included in the GCD computation. Returns false if we fail to find a
874 /// constant coefficient for some loop, e.g., when a term like (X+Y)*i is
875 /// present. Otherwise returns true.
876 bool accumulateCoefficientsGCD(const SCEV *Expr, const Loop *CurLoop,
877 const SCEV *&CurLoopCoeff,
878 APInt &RunningGCD) const;
879
880 /// getPositivePart - X^+ = max(X, 0).
881 const SCEV *getPositivePart(const SCEV *X) const;
882
883 /// getNegativePart - X^- = min(X, 0).
884 const SCEV *getNegativePart(const SCEV *X) const;
885
886 /// getLowerBound - Looks through all the bounds info and
887 /// computes the lower bound given the current direction settings
888 /// at each level.
889 const SCEV *getLowerBound(BoundInfo *Bound) const;
890
891 /// getUpperBound - Looks through all the bounds info and
892 /// computes the upper bound given the current direction settings
893 /// at each level.
894 const SCEV *getUpperBound(BoundInfo *Bound) const;
895
896 /// exploreDirections - Hierarchically expands the direction vector
897 /// search space, combining the directions of discovered dependences
898 /// in the DirSet field of Bound. Returns the number of distinct
899 /// dependences discovered. If the dependence is disproved,
900 /// it will return 0.
901 unsigned exploreDirections(unsigned Level, CoefficientInfo *A,
902 CoefficientInfo *B, BoundInfo *Bound,
903 const SmallBitVector &Loops,
904 unsigned &DepthExpanded, const SCEV *Delta) const;
905
906 /// testBounds - Returns true iff the current bounds are plausible.
907 bool testBounds(unsigned char DirKind, unsigned Level, BoundInfo *Bound,
908 const SCEV *Delta) const;
909
910 /// findBoundsALL - Computes the upper and lower bounds for level K
911 /// using the * direction. Records them in Bound.
912 void findBoundsALL(CoefficientInfo *A, CoefficientInfo *B, BoundInfo *Bound,
913 unsigned K) const;
914
915 /// findBoundsLT - Computes the upper and lower bounds for level K
916 /// using the < direction. Records them in Bound.
917 void findBoundsLT(CoefficientInfo *A, CoefficientInfo *B, BoundInfo *Bound,
918 unsigned K) const;
919
920 /// findBoundsGT - Computes the upper and lower bounds for level K
921 /// using the > direction. Records them in Bound.
922 void findBoundsGT(CoefficientInfo *A, CoefficientInfo *B, BoundInfo *Bound,
923 unsigned K) const;
924
925 /// findBoundsEQ - Computes the upper and lower bounds for level K
926 /// using the = direction. Records them in Bound.
927 void findBoundsEQ(CoefficientInfo *A, CoefficientInfo *B, BoundInfo *Bound,
928 unsigned K) const;
929
930 /// intersectConstraints - Updates X with the intersection
931 /// of the Constraints X and Y. Returns true if X has changed.
932 bool intersectConstraints(Constraint *X, const Constraint *Y);
933
934 /// propagate - Review the constraints, looking for opportunities
935 /// to simplify a subscript pair (Src and Dst).
936 /// Return true if some simplification occurs.
937 /// If the simplification isn't exact (that is, if it is conservative
938 /// in terms of dependence), set consistent to false.
939 bool propagate(const SCEV *&Src, const SCEV *&Dst, SmallBitVector &Loops,
940 SmallVectorImpl<Constraint> &Constraints, bool &Consistent);
941
942 /// propagateDistance - Attempt to propagate a distance
943 /// constraint into a subscript pair (Src and Dst).
944 /// Return true if some simplification occurs.
945 /// If the simplification isn't exact (that is, if it is conservative
946 /// in terms of dependence), set consistent to false.
947 bool propagateDistance(const SCEV *&Src, const SCEV *&Dst,
948 Constraint &CurConstraint, bool &Consistent);
949
950 /// propagatePoint - Attempt to propagate a point
951 /// constraint into a subscript pair (Src and Dst).
952 /// Return true if some simplification occurs.
953 bool propagatePoint(const SCEV *&Src, const SCEV *&Dst,
954 Constraint &CurConstraint);
955
956 /// propagateLine - Attempt to propagate a line
957 /// constraint into a subscript pair (Src and Dst).
958 /// Return true if some simplification occurs.
959 /// If the simplification isn't exact (that is, if it is conservative
960 /// in terms of dependence), set consistent to false.
961 bool propagateLine(const SCEV *&Src, const SCEV *&Dst,
962 Constraint &CurConstraint, bool &Consistent);
963
964 /// findCoefficient - Given a linear SCEV,
965 /// return the coefficient corresponding to specified loop.
966 /// If there isn't one, return the SCEV constant 0.
967 /// For example, given a*i + b*j + c*k, returning the coefficient
968 /// corresponding to the j loop would yield b.
969 const SCEV *findCoefficient(const SCEV *Expr, const Loop *TargetLoop) const;
970
971 /// zeroCoefficient - Given a linear SCEV,
972 /// return the SCEV given by zeroing out the coefficient
973 /// corresponding to the specified loop.
974 /// For example, given a*i + b*j + c*k, zeroing the coefficient
975 /// corresponding to the j loop would yield a*i + c*k.
976 const SCEV *zeroCoefficient(const SCEV *Expr, const Loop *TargetLoop) const;
977
978 /// addToCoefficient - Given a linear SCEV Expr,
979 /// return the SCEV given by adding some Value to the
980 /// coefficient corresponding to the specified TargetLoop.
981 /// For example, given a*i + b*j + c*k, adding 1 to the coefficient
982 /// corresponding to the j loop would yield a*i + (b+1)*j + c*k.
983 const SCEV *addToCoefficient(const SCEV *Expr, const Loop *TargetLoop,
984 const SCEV *Value) const;
985
986 /// updateDirection - Update direction vector entry
987 /// based on the current constraint.
988 void updateDirection(Dependence::DVEntry &Level,
989 const Constraint &CurConstraint) const;
990
991 /// Given a linear access function, tries to recover subscripts
992 /// for each dimension of the array element access.
993 bool tryDelinearize(Instruction *Src, Instruction *Dst,
994 SmallVectorImpl<Subscript> &Pair);
995
996 /// Tries to delinearize \p Src and \p Dst access functions for a fixed size
997 /// multi-dimensional array. Calls tryDelinearizeFixedSizeImpl() to
998 /// delinearize \p Src and \p Dst separately,
999 bool tryDelinearizeFixedSize(Instruction *Src, Instruction *Dst,
1000 const SCEV *SrcAccessFn, const SCEV *DstAccessFn,
1001 SmallVectorImpl<const SCEV *> &SrcSubscripts,
1002 SmallVectorImpl<const SCEV *> &DstSubscripts);
1003
1004 /// Tries to delinearize access function for a multi-dimensional array with
1005 /// symbolic runtime sizes.
1006 /// Returns true upon success and false otherwise.
1007 bool
1008 tryDelinearizeParametricSize(Instruction *Src, Instruction *Dst,
1009 const SCEV *SrcAccessFn, const SCEV *DstAccessFn,
1010 SmallVectorImpl<const SCEV *> &SrcSubscripts,
1011 SmallVectorImpl<const SCEV *> &DstSubscripts);
1012
1013 /// checkSubscript - Helper function for checkSrcSubscript and
1014 /// checkDstSubscript to avoid duplicate code
1015 bool checkSubscript(const SCEV *Expr, const Loop *LoopNest,
1016 SmallBitVector &Loops, bool IsSrc);
1017}; // class DependenceInfo
1018
1019/// AnalysisPass to compute dependence information in a function
1020class DependenceAnalysis : public AnalysisInfoMixin<DependenceAnalysis> {
1021public:
1024
1025private:
1028}; // class DependenceAnalysis
1029
1030/// Printer pass to dump DA results.
1032 : public PassInfoMixin<DependenceAnalysisPrinterPass> {
1033 DependenceAnalysisPrinterPass(raw_ostream &OS, bool NormalizeResults = false)
1034 : OS(OS), NormalizeResults(NormalizeResults) {}
1035
1037
1038 static bool isRequired() { return true; }
1039
1040private:
1041 raw_ostream &OS;
1042 bool NormalizeResults;
1043}; // class DependenceAnalysisPrinterPass
1044
1045/// Legacy pass manager pass to access dependence information
1047public:
1048 static char ID; // Class identification, replacement for typeinfo
1050
1051 bool runOnFunction(Function &F) override;
1052 void releaseMemory() override;
1053 void getAnalysisUsage(AnalysisUsage &) const override;
1054 void print(raw_ostream &, const Module * = nullptr) const override;
1055 DependenceInfo &getDI() const;
1056
1057private:
1058 std::unique_ptr<DependenceInfo> info;
1059}; // class DependenceAnalysisWrapperPass
1060
1061/// createDependenceAnalysisPass - This creates an instance of the
1062/// DependenceAnalysis wrapper pass.
1064
1065} // namespace llvm
1066
1067#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