40 #ifndef LLVM_ANALYSIS_DEPENDENCEANALYSIS_H
41 #define LLVM_ANALYSIS_DEPENDENCEANALYSIS_H
52 class ScalarEvolution;
77 NextPredecessor(nullptr),
78 NextSuccessor(nullptr) {}
180 return NextPredecessor;
186 return NextSuccessor;
192 NextPredecessor =
pred;
198 NextSuccessor = succ;
206 const Dependence *NextPredecessor, *NextSuccessor;
268 unsigned short Levels;
269 bool LoopIndependent;
290 bool PossiblyLoopIndependent);
346 enum ClassificationKind { ZIV, SIV, RDIV, MIV, NonLinear } Classification;
352 struct CoefficientInfo {
356 const SCEV *Iterations;
360 const SCEV *Iterations;
361 const SCEV *Upper[8];
362 const SCEV *Lower[8];
363 unsigned char Direction;
364 unsigned char DirSet;
384 enum ConstraintKind {
Empty, Point, Distance, Line,
Any } Kind;
389 const Loop *AssociatedLoop;
392 bool isEmpty()
const {
return Kind ==
Empty; }
395 bool isPoint()
const {
return Kind == Point; }
398 bool isDistance()
const {
return Kind == Distance; }
403 bool isLine()
const {
return Kind == Line || Kind == Distance; }
406 bool isAny()
const {
return Kind ==
Any; }
410 const SCEV *getX()
const;
414 const SCEV *getY()
const;
418 const SCEV *getA()
const;
422 const SCEV *getB()
const;
426 const SCEV *getC()
const;
430 const SCEV *getD()
const;
433 const Loop *getAssociatedLoop()
const;
436 void setPoint(
const SCEV *
X,
const SCEV *
Y,
const Loop *CurrentLoop);
439 void setLine(
const SCEV *
A,
const SCEV *B,
443 void setDistance(
const SCEV *D,
const Loop *CurrentLoop);
507 void establishNestingLevels(
const Instruction *Src,
510 unsigned CommonLevels, SrcLevels, MaxLevels;
514 unsigned mapSrcLoop(
const Loop *SrcLoop)
const;
518 unsigned mapDstLoop(
const Loop *DstLoop)
const;
522 bool isLoopInvariant(
const SCEV *Expression,
const Loop *LoopNest)
const;
534 void removeMatchingExtensions(Subscript *Pair);
538 void collectCommonLoops(
const SCEV *Expression,
539 const Loop *LoopNest,
544 bool checkSrcSubscript(
const SCEV *Src,
545 const Loop *LoopNest,
550 bool checkDstSubscript(
const SCEV *Dst,
551 const Loop *LoopNest,
560 const SCEV *
Y)
const;
577 Subscript::ClassificationKind classifyPair(
const SCEV *Src,
578 const Loop *SrcLoopNest,
580 const Loop *DstLoopNest,
588 bool testZIV(
const SCEV *Src,
602 bool testSIV(
const SCEV *Src,
606 Constraint &NewConstraint,
607 const SCEV *&SplitIter)
const;
618 bool testRDIV(
const SCEV *Src,
625 bool testMIV(
const SCEV *Src,
638 bool strongSIVtest(
const SCEV *Coeff,
639 const SCEV *SrcConst,
640 const SCEV *DstConst,
641 const Loop *CurrentLoop,
644 Constraint &NewConstraint)
const;
656 bool weakCrossingSIVtest(
const SCEV *SrcCoeff,
657 const SCEV *SrcConst,
658 const SCEV *DstConst,
659 const Loop *CurrentLoop,
662 Constraint &NewConstraint,
663 const SCEV *&SplitIter)
const;
674 bool exactSIVtest(
const SCEV *SrcCoeff,
675 const SCEV *DstCoeff,
676 const SCEV *SrcConst,
677 const SCEV *DstConst,
678 const Loop *CurrentLoop,
681 Constraint &NewConstraint)
const;
693 bool weakZeroSrcSIVtest(
const SCEV *DstCoeff,
694 const SCEV *SrcConst,
695 const SCEV *DstConst,
696 const Loop *CurrentLoop,
699 Constraint &NewConstraint)
const;
711 bool weakZeroDstSIVtest(
const SCEV *SrcCoeff,
712 const SCEV *SrcConst,
713 const SCEV *DstConst,
714 const Loop *CurrentLoop,
717 Constraint &NewConstraint)
const;
727 bool exactRDIVtest(
const SCEV *SrcCoeff,
728 const SCEV *DstCoeff,
729 const SCEV *SrcConst,
730 const SCEV *DstConst,
744 bool symbolicRDIVtest(
const SCEV *SrcCoeff,
745 const SCEV *DstCoeff,
746 const SCEV *SrcConst,
747 const SCEV *DstConst,
749 const Loop *DstLoop)
const;
757 bool gcdMIVtest(
const SCEV *Src,
765 bool banerjeeMIVtest(
const SCEV *Src,
773 CoefficientInfo *collectCoeffInfo(
const SCEV *Subscript,
779 const SCEV *getPositivePart(
const SCEV *X)
const;
783 const SCEV *getNegativePart(
const SCEV *X)
const;
788 const SCEV *getLowerBound(BoundInfo *Bound)
const;
793 const SCEV *getUpperBound(BoundInfo *Bound)
const;
800 unsigned exploreDirections(
unsigned Level,
805 unsigned &DepthExpanded,
806 const SCEV *Delta)
const;
810 bool testBounds(
unsigned char DirKind,
813 const SCEV *Delta)
const;
817 void findBoundsALL(CoefficientInfo *A,
824 void findBoundsLT(CoefficientInfo *A,
831 void findBoundsGT(CoefficientInfo *A,
838 void findBoundsEQ(CoefficientInfo *A,
845 bool intersectConstraints(Constraint *X,
846 const Constraint *Y);
853 bool propagate(
const SCEV *&Src,
864 bool propagateDistance(
const SCEV *&Src,
866 Constraint &CurConstraint,
872 bool propagatePoint(
const SCEV *&Src,
874 Constraint &CurConstraint);
881 bool propagateLine(
const SCEV *&Src,
883 Constraint &CurConstraint,
891 const SCEV *findCoefficient(
const SCEV *Expr,
892 const Loop *TargetLoop)
const;
899 const SCEV *zeroCoefficient(
const SCEV *Expr,
900 const Loop *TargetLoop)
const;
907 const SCEV *addToCoefficient(
const SCEV *Expr,
908 const Loop *TargetLoop,
914 const Constraint &CurConstraint)
const;
916 bool tryDelinearize(
const SCEV *SrcSCEV,
const SCEV *DstSCEV,
918 const SCEV *ElementSize);
void print(raw_ostream &, const Module *=nullptr) const override
print - Print out the internal state of the pass.
const SCEV * getDistance(unsigned Level) const override
getDistance - Returns the distance (or NULL) associated with a particular level.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
bool isAnti() const
isAnti - Returns true if this is an anti dependence.
virtual bool isConfused() const
isConfused - Returns true if this dependence is confused (the compiler understands nothing and makes ...
SmallBitVector - This is a 'bitvector' (really, a variable-sized bit array), optimized for the case w...
DependenceAnalysis - This class is the main dependence-analysis driver.
bool isOrdered() const
isOrdered - Returns true if dependence is Output, Flow, or Anti
A Module instance is used to store all the information related to an LLVM module. ...
virtual bool isPeelFirst(unsigned Level) const
isPeelFirst - Returns true if peeling the first iteration from this loop will break this dependence...
FunctionPass * createDependenceAnalysisPass()
createDependenceAnalysisPass - This creates an instance of the DependenceAnalysis pass...
ScalarEvolution - This class is the main scalar evolution driver.
bool isConsistent() const override
isConsistent - Returns true if this dependence is consistent (occurs every time the source and destin...
void getAnalysisUsage(AnalysisUsage &) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
bool isPeelLast(unsigned Level) const override
isPeelLast - Returns true if peeling the last iteration from this loop will break this dependence...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
virtual bool isSplitable(unsigned Level) const
isSplitable - Returns true if splitting this loop will break the dependence.
~FullDependence() override
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
unsigned getLevels() const override
getLevels - Returns the number of common loops surrounding the source and destination of the dependen...
bool isLoopIndependent() const override
isLoopIndependent - Returns true if this is a loop-independent dependence.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
void setNextPredecessor(const Dependence *pred)
setNextPredecessor - Sets the value of the NextPredecessor field.
unsigned getDirection(unsigned Level) const override
getDirection - Returns the direction associated with a particular level.
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
const Dependence * getNextSuccessor() const
getNextSuccessor - Returns the value of the NextSuccessor field.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important base class in LLVM.
virtual bool isScalar(unsigned Level) const
isScalar - Returns true if a particular level is scalar; that is, if no subscript in the source or de...
bool isConfused() const override
isConfused - Returns true if this dependence is confused (the compiler understands nothing and makes ...
bool isSplitable(unsigned Level) const override
isSplitable - Returns true if splitting the loop will break the dependence.
bool isFlow() const
isFlow - Returns true if this is a flow (aka true) dependence.
Represent the analysis usage information of a pass.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
FunctionPass class - This class is used to implement most global optimizations.
bool isPeelFirst(unsigned Level) const override
isPeelFirst - Returns true if peeling the first iteration from this loop will break this dependence...
virtual const SCEV * getDistance(unsigned Level) const
getDistance - Returns the distance (or NULL) associated with a particular level.
Instruction * getSrc() const
getSrc - Returns the source instruction for this dependence.
virtual unsigned getDirection(unsigned Level) const
getDirection - Returns the direction associated with a particular level.
virtual bool isConsistent() const
isConsistent - Returns true if this dependence is consistent (occurs every time the source and destin...
void initializeDependenceAnalysisPass(PassRegistry &)
const SCEV * getSplitIteration(const Dependence &Dep, unsigned Level)
getSplitIteration - Give a dependence that's splittable at some particular level, return the iteratio...
const Dependence * getNextPredecessor() const
getNextPredecessor - Returns the value of the NextPredecessor field.
virtual unsigned getLevels() const
getLevels - Returns the number of common loops surrounding the source and destination of the dependen...
virtual bool isPeelLast(unsigned Level) const
isPeelLast - Returns true if peeling the last iteration from this loop will break this dependence...
Dependence(Instruction *Source, Instruction *Destination)
FullDependence(Instruction *Src, Instruction *Dst, bool LoopIndependent, unsigned Levels)
bool isScalar(unsigned Level) const override
isScalar - Returns true if a particular level is scalar; that is, if no subscript in the source or de...
SCEV - This class represents an analyzed expression in the program.
virtual bool isLoopIndependent() const
isLoopIndependent - Returns true if this is a loop-independent dependence.
Instruction * getDst() const
getDst - Returns the destination instruction for this dependence.
void dump(raw_ostream &OS) const
dump - For debugging purposes, dumps a dependence to OS.
FullDependence - This class represents a dependence between two memory references in a function...
Dependence::DVEntry - Each level in the distance/direction vector has a direction (or perhaps a union...
bool isInput() const
isInput - Returns true if this is an input dependence.
bool isUnordered() const
isUnordered - Returns true if dependence is Input
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream...
std::unique_ptr< Dependence > depends(Instruction *Src, Instruction *Dst, bool PossiblyLoopIndependent)
depends - Tests for a dependence between the Src and Dst instructions.
bool isOutput() const
isOutput - Returns true if this is an output dependence.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
Dependence - This class represents a dependence between two memory memory references in a function...
void setNextSuccessor(const Dependence *succ)
setNextSuccessor - Sets the value of the NextSuccessor field.
SCEVConstant - This class represents a constant integer value.