54 #define DEBUG_TYPE "da"
75 STATISTIC(TotalArrayPairs,
"Array pairs tested");
76 STATISTIC(SeparableSubscriptPairs,
"Separable subscript pairs");
77 STATISTIC(CoupledSubscriptPairs,
"Coupled subscript pairs");
78 STATISTIC(NonlinearSubscriptPairs,
"Nonlinear subscript pairs");
79 STATISTIC(ZIVapplications,
"ZIV applications");
80 STATISTIC(ZIVindependence,
"ZIV independence");
81 STATISTIC(StrongSIVapplications,
"Strong SIV applications");
82 STATISTIC(StrongSIVsuccesses,
"Strong SIV successes");
83 STATISTIC(StrongSIVindependence,
"Strong SIV independence");
84 STATISTIC(WeakCrossingSIVapplications,
"Weak-Crossing SIV applications");
85 STATISTIC(WeakCrossingSIVsuccesses,
"Weak-Crossing SIV successes");
86 STATISTIC(WeakCrossingSIVindependence,
"Weak-Crossing SIV independence");
87 STATISTIC(ExactSIVapplications,
"Exact SIV applications");
88 STATISTIC(ExactSIVsuccesses,
"Exact SIV successes");
89 STATISTIC(ExactSIVindependence,
"Exact SIV independence");
90 STATISTIC(WeakZeroSIVapplications,
"Weak-Zero SIV applications");
91 STATISTIC(WeakZeroSIVsuccesses,
"Weak-Zero SIV successes");
92 STATISTIC(WeakZeroSIVindependence,
"Weak-Zero SIV independence");
93 STATISTIC(ExactRDIVapplications,
"Exact RDIV applications");
94 STATISTIC(ExactRDIVindependence,
"Exact RDIV independence");
95 STATISTIC(SymbolicRDIVapplications,
"Symbolic RDIV applications");
96 STATISTIC(SymbolicRDIVindependence,
"Symbolic RDIV independence");
97 STATISTIC(DeltaApplications,
"Delta applications");
98 STATISTIC(DeltaSuccesses,
"Delta successes");
99 STATISTIC(DeltaIndependence,
"Delta independence");
100 STATISTIC(DeltaPropagations,
"Delta propagations");
101 STATISTIC(GCDapplications,
"GCD applications");
102 STATISTIC(GCDsuccesses,
"GCD successes");
103 STATISTIC(GCDindependence,
"GCD independence");
104 STATISTIC(BanerjeeApplications,
"Banerjee applications");
105 STATISTIC(BanerjeeIndependence,
"Banerjee independence");
106 STATISTIC(BanerjeeSuccesses,
"Banerjee successes");
110 cl::desc(
"Try to delinearize array references."));
116 "Dependence Analysis",
true,
true)
123 char DependenceAnalysis::
ID = 0;
127 return new DependenceAnalysis();
133 AA = &getAnalysis<AliasAnalysis>();
134 SE = &getAnalysis<ScalarEvolution>();
135 LI = &getAnalysis<LoopInfo>();
160 SrcI != SrcE; ++SrcI) {
161 if (isa<StoreInst>(*SrcI) || isa<LoadInst>(*SrcI)) {
163 DstI != DstE; ++DstI) {
164 if (isa<StoreInst>(*DstI) || isa<LoadInst>(*DstI)) {
165 OS <<
"da analyze - ";
169 if (D->isSplitable(
Level)) {
170 OS <<
"da analyze - split level = " <<
Level;
231 bool PossiblyLoopIndependent,
232 unsigned CommonLevels) :
234 Levels(CommonLevels),
235 LoopIndependent(PossiblyLoopIndependent) {
237 DV = CommonLevels ?
new DVEntry[CommonLevels] : NULL;
244 assert(0 < Level && Level <= Levels &&
"Level out of range");
251 assert(0 < Level && Level <= Levels &&
"Level out of range");
260 assert(0 < Level && Level <= Levels &&
"Level out of range");
261 return DV[Level - 1].
Scalar;
268 assert(0 < Level && Level <= Levels &&
"Level out of range");
276 assert(0 < Level && Level <= Levels &&
"Level out of range");
283 assert(0 < Level && Level <= Levels &&
"Level out of range");
293 const SCEV *DependenceAnalysis::Constraint::getX()
const {
294 assert(
Kind == Point &&
"Kind should be Point");
301 const SCEV *DependenceAnalysis::Constraint::getY()
const {
302 assert(
Kind == Point &&
"Kind should be Point");
309 const SCEV *DependenceAnalysis::Constraint::getA()
const {
310 assert((
Kind == Line ||
Kind == Distance) &&
311 "Kind should be Line (or Distance)");
318 const SCEV *DependenceAnalysis::Constraint::getB()
const {
319 assert((
Kind == Line ||
Kind == Distance) &&
320 "Kind should be Line (or Distance)");
327 const SCEV *DependenceAnalysis::Constraint::getC()
const {
328 assert((
Kind == Line ||
Kind == Distance) &&
329 "Kind should be Line (or Distance)");
336 const SCEV *DependenceAnalysis::Constraint::getD()
const {
337 assert(
Kind == Distance &&
"Kind should be Distance");
338 return SE->getNegativeSCEV(
C);
343 const Loop *DependenceAnalysis::Constraint::getAssociatedLoop()
const {
344 assert((
Kind == Distance ||
Kind == Line ||
Kind == Point) &&
345 "Kind should be Distance, Line, or Point");
346 return AssociatedLoop;
350 void DependenceAnalysis::Constraint::setPoint(
const SCEV *
X,
352 const Loop *CurLoop) {
356 AssociatedLoop = CurLoop;
360 void DependenceAnalysis::Constraint::setLine(
const SCEV *AA,
363 const Loop *CurLoop) {
368 AssociatedLoop = CurLoop;
372 void DependenceAnalysis::Constraint::setDistance(
const SCEV *D,
373 const Loop *CurLoop) {
375 A = SE->getConstant(D->
getType(), 1);
376 B = SE->getNegativeSCEV(
A);
377 C = SE->getNegativeSCEV(D);
378 AssociatedLoop = CurLoop;
382 void DependenceAnalysis::Constraint::setEmpty() {
400 OS <<
" Point is <" << *getX() <<
", " << *getY() <<
">\n";
401 else if (isDistance())
402 OS <<
" Distance is " << *getD() <<
403 " (" << *getA() <<
"*X + " << *getB() <<
"*Y = " << *getC() <<
")\n";
405 OS <<
" Line is " << *getA() <<
"*X + " <<
406 *getB() <<
"*Y = " << *getC() <<
"\n";
419 bool DependenceAnalysis::intersectConstraints(Constraint *
X,
420 const Constraint *
Y) {
422 DEBUG(
dbgs() <<
"\tintersect constraints\n");
425 assert(!Y->isPoint() &&
"Y must not be a Point");
439 if (X->isDistance() && Y->isDistance()) {
440 DEBUG(
dbgs() <<
"\t intersect 2 distances\n");
450 if (isa<SCEVConstant>(Y->getD())) {
463 assert(!(X->isPoint() && Y->isPoint()) &&
464 "We shouldn't ever see X->isPoint() && Y->isPoint()");
466 if (X->isLine() && Y->isLine()) {
467 DEBUG(
dbgs() <<
"\t intersect 2 lines\n");
486 DEBUG(
dbgs() <<
"\t\tdifferent slopes\n");
501 if (!C1B2_C2B1 || !C1A2_C2A1 ||
502 !A1B2_A2B1 || !A2B1_A1B2)
504 APInt Xtop = C1B2_C2B1->getValue()->getValue();
505 APInt Xbot = A1B2_A2B1->getValue()->getValue();
507 APInt Ybot = A2B1_A1B2->getValue()->getValue();
508 DEBUG(
dbgs() <<
"\t\tXtop = " << Xtop <<
"\n");
509 DEBUG(
dbgs() <<
"\t\tXbot = " << Xbot <<
"\n");
510 DEBUG(
dbgs() <<
"\t\tYtop = " << Ytop <<
"\n");
511 DEBUG(
dbgs() <<
"\t\tYbot = " << Ybot <<
"\n");
518 if (Xr != 0 || Yr != 0) {
523 DEBUG(
dbgs() <<
"\t\tX = " << Xq <<
", Y = " << Yq <<
"\n");
524 if (Xq.
slt(0) || Yq.
slt(0)) {
530 collectConstantUpperBound(X->getAssociatedLoop(), Prod1->
getType())) {
531 APInt UpperBound = CUB->getValue()->getValue();
532 DEBUG(
dbgs() <<
"\t\tupper bound = " << UpperBound <<
"\n");
533 if (Xq.
sgt(UpperBound) || Yq.
sgt(UpperBound)) {
541 X->getAssociatedLoop());
549 assert(!(X->isLine() && Y->isPoint()) &&
"This case should never occur");
551 if (X->isPoint() && Y->isLine()) {
552 DEBUG(
dbgs() <<
"\t intersect Point and Line\n");
576 bool Splitable =
false;
592 for (
unsigned II = 1; II <= Levels; ++II) {
646 if (
const LoadInst *
LI = dyn_cast<LoadInst>(I))
647 return LI->isUnordered();
648 else if (
const StoreInst *SI = dyn_cast<StoreInst>(I))
649 return SI->isUnordered();
657 return LI->getPointerOperand();
658 if (
StoreInst *SI = dyn_cast<StoreInst>(I))
659 return SI->getPointerOperand();
715 void DependenceAnalysis::establishNestingLevels(
const Instruction *Src,
719 unsigned SrcLevel =
LI->getLoopDepth(SrcBlock);
720 unsigned DstLevel =
LI->getLoopDepth(DstBlock);
721 const Loop *SrcLoop =
LI->getLoopFor(SrcBlock);
722 const Loop *DstLoop =
LI->getLoopFor(DstBlock);
723 SrcLevels = SrcLevel;
724 MaxLevels = SrcLevel + DstLevel;
725 while (SrcLevel > DstLevel) {
729 while (DstLevel > SrcLevel) {
733 while (SrcLoop != DstLoop) {
738 CommonLevels = SrcLevel;
739 MaxLevels -= CommonLevels;
745 unsigned DependenceAnalysis::mapSrcLoop(
const Loop *SrcLoop)
const {
752 unsigned DependenceAnalysis::mapDstLoop(
const Loop *DstLoop)
const {
754 if (D > CommonLevels)
755 return D - CommonLevels + SrcLevels;
763 const Loop *LoopNest)
const {
774 void DependenceAnalysis::collectCommonLoops(
const SCEV *Expression,
775 const Loop *LoopNest,
779 if (Level <= CommonLevels && !SE->
isLoopInvariant(Expression, LoopNest))
790 void DependenceAnalysis::removeMatchingExtensions(Subscript *Pair) {
791 const SCEV *Src = Pair->Src;
792 const SCEV *Dst = Pair->Dst;
793 if ((isa<SCEVZeroExtendExpr>(Src) && isa<SCEVZeroExtendExpr>(Dst)) ||
794 (isa<SCEVSignExtendExpr>(Src) && isa<SCEVSignExtendExpr>(Dst))) {
797 if (SrcCast->
getType() == DstCast->getType()) {
799 Pair->Dst = DstCast->getOperand();
807 bool DependenceAnalysis::checkSrcSubscript(
const SCEV *Src,
808 const Loop *LoopNest,
818 return checkSrcSubscript(Start, LoopNest, Loops);
825 bool DependenceAnalysis::checkDstSubscript(
const SCEV *Dst,
826 const Loop *LoopNest,
836 return checkDstSubscript(Start, LoopNest, Loops);
843 DependenceAnalysis::Subscript::ClassificationKind
844 DependenceAnalysis::classifyPair(
const SCEV *Src,
const Loop *SrcLoopNest,
845 const SCEV *Dst,
const Loop *DstLoopNest,
849 if (!checkSrcSubscript(Src, SrcLoopNest, SrcLoops))
850 return Subscript::NonLinear;
851 if (!checkDstSubscript(Dst, DstLoopNest, DstLoops))
852 return Subscript::NonLinear;
855 unsigned N = Loops.
count();
857 return Subscript::ZIV;
859 return Subscript::SIV;
860 if (N == 2 && (SrcLoops.count() == 0 ||
861 DstLoops.count() == 0 ||
862 (SrcLoops.count() == 1 && DstLoops.count() == 1)))
863 return Subscript::RDIV;
864 return Subscript::MIV;
880 const SCEV *Y)
const {
883 if ((isa<SCEVSignExtendExpr>(X) &&
884 isa<SCEVSignExtendExpr>(Y)) ||
885 (isa<SCEVZeroExtendExpr>(X) &&
886 isa<SCEVZeroExtendExpr>(Y))) {
890 const SCEV *Yop = CY->getOperand();
891 if (Xop->getType() == Yop->
getType()) {
929 const SCEV *DependenceAnalysis::collectUpperBound(
const Loop *L,
941 const SCEVConstant *DependenceAnalysis::collectConstantUpperBound(
const Loop *L,
944 if (
const SCEV *UB = collectUpperBound(L, T))
960 bool DependenceAnalysis::testZIV(
const SCEV *Src,
963 DEBUG(
dbgs() <<
" src = " << *Src <<
"\n");
964 DEBUG(
dbgs() <<
" dst = " << *Dst <<
"\n");
967 DEBUG(
dbgs() <<
" provably dependent\n");
971 DEBUG(
dbgs() <<
" provably independent\n");
975 DEBUG(
dbgs() <<
" possibly dependent\n");
976 Result.Consistent =
false;
1008 bool DependenceAnalysis::strongSIVtest(
const SCEV *Coeff,
1009 const SCEV *SrcConst,
1010 const SCEV *DstConst,
1011 const Loop *CurLoop,
1014 Constraint &NewConstraint)
const {
1016 DEBUG(
dbgs() <<
"\t Coeff = " << *Coeff);
1018 DEBUG(
dbgs() <<
"\t SrcConst = " << *SrcConst);
1020 DEBUG(
dbgs() <<
"\t DstConst = " << *DstConst);
1022 ++StrongSIVapplications;
1023 assert(0 < Level && Level <= CommonLevels &&
"level out of range");
1027 DEBUG(
dbgs() <<
"\t Delta = " << *Delta);
1031 if (
const SCEV *UpperBound = collectUpperBound(CurLoop, Delta->
getType())) {
1032 DEBUG(
dbgs() <<
"\t UpperBound = " << *UpperBound);
1033 DEBUG(
dbgs() <<
", " << *UpperBound->getType() <<
"\n");
1034 const SCEV *AbsDelta =
1036 const SCEV *AbsCoeff =
1041 ++StrongSIVindependence;
1042 ++StrongSIVsuccesses;
1048 if (isa<SCEVConstant>(Delta) && isa<SCEVConstant>(Coeff)) {
1049 APInt ConstDelta = cast<SCEVConstant>(Delta)->getValue()->getValue();
1050 APInt ConstCoeff = cast<SCEVConstant>(Coeff)->getValue()->getValue();
1051 APInt Distance = ConstDelta;
1052 APInt Remainder = ConstDelta;
1054 DEBUG(
dbgs() <<
"\t Distance = " << Distance <<
"\n");
1055 DEBUG(
dbgs() <<
"\t Remainder = " << Remainder <<
"\n");
1057 if (Remainder != 0) {
1059 ++StrongSIVindependence;
1060 ++StrongSIVsuccesses;
1064 NewConstraint.setDistance(SE->
getConstant(Distance), CurLoop);
1065 if (Distance.
sgt(0))
1067 else if (Distance.
slt(0))
1071 ++StrongSIVsuccesses;
1073 else if (Delta->
isZero()) {
1076 NewConstraint.setDistance(Delta, CurLoop);
1078 ++StrongSIVsuccesses;
1081 if (Coeff->
isOne()) {
1082 DEBUG(
dbgs() <<
"\t Distance = " << *Delta <<
"\n");
1084 NewConstraint.setDistance(Delta, CurLoop);
1087 Result.Consistent =
false;
1088 NewConstraint.setLine(Coeff,
1103 if ((DeltaMaybePositive && CoeffMaybePositive) ||
1104 (DeltaMaybeNegative && CoeffMaybeNegative))
1108 if ((DeltaMaybeNegative && CoeffMaybePositive) ||
1109 (DeltaMaybePositive && CoeffMaybeNegative))
1111 if (NewDirection < Result.DV[Level].
Direction)
1112 ++StrongSIVsuccesses;
1147 bool DependenceAnalysis::weakCrossingSIVtest(
const SCEV *Coeff,
1148 const SCEV *SrcConst,
1149 const SCEV *DstConst,
1150 const Loop *CurLoop,
1153 Constraint &NewConstraint,
1154 const SCEV *&SplitIter)
const {
1155 DEBUG(
dbgs() <<
"\tWeak-Crossing SIV test\n");
1156 DEBUG(
dbgs() <<
"\t Coeff = " << *Coeff <<
"\n");
1157 DEBUG(
dbgs() <<
"\t SrcConst = " << *SrcConst <<
"\n");
1158 DEBUG(
dbgs() <<
"\t DstConst = " << *DstConst <<
"\n");
1159 ++WeakCrossingSIVapplications;
1160 assert(0 < Level && Level <= CommonLevels &&
"Level out of range");
1162 Result.Consistent =
false;
1164 DEBUG(
dbgs() <<
"\t Delta = " << *Delta <<
"\n");
1165 NewConstraint.setLine(Coeff, Coeff, Delta, CurLoop);
1169 ++WeakCrossingSIVsuccesses;
1171 ++WeakCrossingSIVindependence;
1184 assert(ConstCoeff &&
1185 "dynamic cast of negative of ConstCoeff should yield constant");
1188 assert(SE->
isKnownPositive(ConstCoeff) &&
"ConstCoeff should be positive");
1196 DEBUG(
dbgs() <<
"\t Split iter = " << *SplitIter <<
"\n");
1204 DEBUG(
dbgs() <<
"\t Delta = " << *Delta <<
"\n");
1205 DEBUG(
dbgs() <<
"\t ConstCoeff = " << *ConstCoeff <<
"\n");
1208 ++WeakCrossingSIVindependence;
1209 ++WeakCrossingSIVsuccesses;
1215 if (
const SCEV *UpperBound = collectUpperBound(CurLoop, Delta->
getType())) {
1216 DEBUG(
dbgs() <<
"\t UpperBound = " << *UpperBound <<
"\n");
1220 DEBUG(
dbgs() <<
"\t ML = " << *ML <<
"\n");
1223 ++WeakCrossingSIVindependence;
1224 ++WeakCrossingSIVsuccesses;
1231 ++WeakCrossingSIVsuccesses;
1233 ++WeakCrossingSIVindependence;
1245 APInt Distance = APDelta;
1246 APInt Remainder = APDelta;
1248 DEBUG(
dbgs() <<
"\t Remainder = " << Remainder <<
"\n");
1249 if (Remainder != 0) {
1251 ++WeakCrossingSIVindependence;
1252 ++WeakCrossingSIVsuccesses;
1255 DEBUG(
dbgs() <<
"\t Distance = " << Distance <<
"\n");
1259 Remainder = Distance.
srem(Two);
1260 DEBUG(
dbgs() <<
"\t Remainder = " << Remainder <<
"\n");
1261 if (Remainder != 0) {
1264 ++WeakCrossingSIVsuccesses;
1283 APInt A0(Bits, 1,
true), A1(Bits, 0,
true);
1284 APInt B0(Bits, 0,
true), B1(Bits, 1,
true);
1291 APInt A2 = A0 - Q*A1; A0 = A1; A1 = A2;
1292 APInt B2 = B0 - Q*B1; B0 = B1; B1 = B2;
1297 DEBUG(
dbgs() <<
"\t GCD = " << G <<
"\n");
1298 X = AM.
slt(0) ? -A1 : A1;
1299 Y = BM.
slt(0) ? B1 : -B1;
1319 if ((A.
sgt(0) && B.
sgt(0)) ||
1334 if ((A.
sgt(0) && B.
sgt(0)) ||
1344 return A.
sgt(B) ? A : B;
1350 return A.
slt(B) ? A : B;
1369 bool DependenceAnalysis::exactSIVtest(
const SCEV *SrcCoeff,
1370 const SCEV *DstCoeff,
1371 const SCEV *SrcConst,
1372 const SCEV *DstConst,
1373 const Loop *CurLoop,
1376 Constraint &NewConstraint)
const {
1378 DEBUG(
dbgs() <<
"\t SrcCoeff = " << *SrcCoeff <<
" = AM\n");
1379 DEBUG(
dbgs() <<
"\t DstCoeff = " << *DstCoeff <<
" = BM\n");
1380 DEBUG(
dbgs() <<
"\t SrcConst = " << *SrcConst <<
"\n");
1381 DEBUG(
dbgs() <<
"\t DstConst = " << *DstConst <<
"\n");
1382 ++ExactSIVapplications;
1383 assert(0 < Level && Level <= CommonLevels &&
"Level out of range");
1385 Result.Consistent =
false;
1387 DEBUG(
dbgs() <<
"\t Delta = " << *Delta <<
"\n");
1393 if (!ConstDelta || !ConstSrcCoeff || !ConstDstCoeff)
1398 APInt AM = ConstSrcCoeff->getValue()->getValue();
1399 APInt BM = ConstDstCoeff->getValue()->getValue();
1403 ++ExactSIVindependence;
1404 ++ExactSIVsuccesses;
1408 DEBUG(
dbgs() <<
"\t X = " << X <<
", Y = " << Y <<
"\n");
1411 APInt UM(Bits, 1,
true);
1412 bool UMvalid =
false;
1415 collectConstantUpperBound(CurLoop, Delta->
getType())) {
1416 UM = CUB->getValue()->getValue();
1417 DEBUG(
dbgs() <<
"\t UM = " << UM <<
"\n");
1428 DEBUG(
dbgs() <<
"\t TL = " << TL <<
"\n");
1431 DEBUG(
dbgs() <<
"\t TU = " << TU <<
"\n");
1436 DEBUG(
dbgs() <<
"\t TU = " << TU <<
"\n");
1439 DEBUG(
dbgs() <<
"\t TL = " << TL <<
"\n");
1447 DEBUG(
dbgs() <<
"\t TL = " << TL <<
"\n");
1450 DEBUG(
dbgs() <<
"\t TU = " << TU <<
"\n");
1455 DEBUG(
dbgs() <<
"\t TU = " << TU <<
"\n");
1458 DEBUG(
dbgs() <<
"\t TL = " << TL <<
"\n");
1462 ++ExactSIVindependence;
1463 ++ExactSIVsuccesses;
1473 DEBUG(
dbgs() <<
"\t exploring LT direction\n");
1477 DEBUG(
dbgs() <<
"\t\t TL = " << TL <<
"\n");
1481 DEBUG(
dbgs() <<
"\t\t TU = " << TU <<
"\n");
1485 ++ExactSIVsuccesses;
1491 DEBUG(
dbgs() <<
"\t exploring EQ direction\n");
1494 DEBUG(
dbgs() <<
"\t\t TL = " << TL <<
"\n");
1498 DEBUG(
dbgs() <<
"\t\t TU = " << TU <<
"\n");
1503 DEBUG(
dbgs() <<
"\t\t TL = " << TL <<
"\n");
1507 DEBUG(
dbgs() <<
"\t\t TU = " << TU <<
"\n");
1511 ++ExactSIVsuccesses;
1517 DEBUG(
dbgs() <<
"\t exploring GT direction\n");
1520 DEBUG(
dbgs() <<
"\t\t TL = " << TL <<
"\n");
1524 DEBUG(
dbgs() <<
"\t\t TU = " << TU <<
"\n");
1528 ++ExactSIVsuccesses;
1534 ++ExactSIVindependence;
1546 return ConstDividend.
srem(ConstDivisor) == 0;
1581 bool DependenceAnalysis::weakZeroSrcSIVtest(
const SCEV *DstCoeff,
1582 const SCEV *SrcConst,
1583 const SCEV *DstConst,
1584 const Loop *CurLoop,
1587 Constraint &NewConstraint)
const {
1591 DEBUG(
dbgs() <<
"\tWeak-Zero (src) SIV test\n");
1592 DEBUG(
dbgs() <<
"\t DstCoeff = " << *DstCoeff <<
"\n");
1593 DEBUG(
dbgs() <<
"\t SrcConst = " << *SrcConst <<
"\n");
1594 DEBUG(
dbgs() <<
"\t DstConst = " << *DstConst <<
"\n");
1595 ++WeakZeroSIVapplications;
1596 assert(0 < Level && Level <= MaxLevels &&
"Level out of range");
1598 Result.Consistent =
false;
1601 DstCoeff, Delta, CurLoop);
1602 DEBUG(
dbgs() <<
"\t Delta = " << *Delta <<
"\n");
1604 if (Level < CommonLevels) {
1607 ++WeakZeroSIVsuccesses;
1614 const SCEV *AbsCoeff =
1617 const SCEV *NewDelta =
1622 if (
const SCEV *UpperBound = collectUpperBound(CurLoop, Delta->
getType())) {
1623 DEBUG(
dbgs() <<
"\t UpperBound = " << *UpperBound <<
"\n");
1626 ++WeakZeroSIVindependence;
1627 ++WeakZeroSIVsuccesses;
1632 if (Level < CommonLevels) {
1635 ++WeakZeroSIVsuccesses;
1645 ++WeakZeroSIVindependence;
1646 ++WeakZeroSIVsuccesses;
1651 if (isa<SCEVConstant>(Delta) &&
1653 ++WeakZeroSIVindependence;
1654 ++WeakZeroSIVsuccesses;
1692 bool DependenceAnalysis::weakZeroDstSIVtest(
const SCEV *SrcCoeff,
1693 const SCEV *SrcConst,
1694 const SCEV *DstConst,
1695 const Loop *CurLoop,
1698 Constraint &NewConstraint)
const {
1701 DEBUG(
dbgs() <<
"\tWeak-Zero (dst) SIV test\n");
1702 DEBUG(
dbgs() <<
"\t SrcCoeff = " << *SrcCoeff <<
"\n");
1703 DEBUG(
dbgs() <<
"\t SrcConst = " << *SrcConst <<
"\n");
1704 DEBUG(
dbgs() <<
"\t DstConst = " << *DstConst <<
"\n");
1705 ++WeakZeroSIVapplications;
1706 assert(0 < Level && Level <= SrcLevels &&
"Level out of range");
1708 Result.Consistent =
false;
1712 DEBUG(
dbgs() <<
"\t Delta = " << *Delta <<
"\n");
1714 if (Level < CommonLevels) {
1717 ++WeakZeroSIVsuccesses;
1724 const SCEV *AbsCoeff =
1727 const SCEV *NewDelta =
1732 if (
const SCEV *UpperBound = collectUpperBound(CurLoop, Delta->
getType())) {
1733 DEBUG(
dbgs() <<
"\t UpperBound = " << *UpperBound <<
"\n");
1736 ++WeakZeroSIVindependence;
1737 ++WeakZeroSIVsuccesses;
1742 if (Level < CommonLevels) {
1745 ++WeakZeroSIVsuccesses;
1755 ++WeakZeroSIVindependence;
1756 ++WeakZeroSIVsuccesses;
1761 if (isa<SCEVConstant>(Delta) &&
1763 ++WeakZeroSIVindependence;
1764 ++WeakZeroSIVsuccesses;
1778 bool DependenceAnalysis::exactRDIVtest(
const SCEV *SrcCoeff,
1779 const SCEV *DstCoeff,
1780 const SCEV *SrcConst,
1781 const SCEV *DstConst,
1782 const Loop *SrcLoop,
1783 const Loop *DstLoop,
1786 DEBUG(
dbgs() <<
"\t SrcCoeff = " << *SrcCoeff <<
" = AM\n");
1787 DEBUG(
dbgs() <<
"\t DstCoeff = " << *DstCoeff <<
" = BM\n");
1788 DEBUG(
dbgs() <<
"\t SrcConst = " << *SrcConst <<
"\n");
1789 DEBUG(
dbgs() <<
"\t DstConst = " << *DstConst <<
"\n");
1790 ++ExactRDIVapplications;
1791 Result.Consistent =
false;
1793 DEBUG(
dbgs() <<
"\t Delta = " << *Delta <<
"\n");
1797 if (!ConstDelta || !ConstSrcCoeff || !ConstDstCoeff)
1802 APInt AM = ConstSrcCoeff->getValue()->getValue();
1803 APInt BM = ConstDstCoeff->getValue()->getValue();
1807 ++ExactRDIVindependence;
1811 DEBUG(
dbgs() <<
"\t X = " << X <<
", Y = " << Y <<
"\n");
1814 APInt SrcUM(Bits, 1,
true);
1815 bool SrcUMvalid =
false;
1818 collectConstantUpperBound(SrcLoop, Delta->
getType())) {
1819 SrcUM = UpperBound->getValue()->getValue();
1820 DEBUG(
dbgs() <<
"\t SrcUM = " << SrcUM <<
"\n");
1824 APInt DstUM(Bits, 1,
true);
1825 bool DstUMvalid =
false;
1828 collectConstantUpperBound(DstLoop, Delta->
getType())) {
1829 DstUM = UpperBound->getValue()->getValue();
1830 DEBUG(
dbgs() <<
"\t DstUM = " << DstUM <<
"\n");
1841 DEBUG(
dbgs() <<
"\t TL = " << TL <<
"\n");
1844 DEBUG(
dbgs() <<
"\t TU = " << TU <<
"\n");
1849 DEBUG(
dbgs() <<
"\t TU = " << TU <<
"\n");
1852 DEBUG(
dbgs() <<
"\t TL = " << TL <<
"\n");
1860 DEBUG(
dbgs() <<
"\t TL = " << TL <<
"\n");
1863 DEBUG(
dbgs() <<
"\t TU = " << TU <<
"\n");
1868 DEBUG(
dbgs() <<
"\t TU = " << TU <<
"\n");
1871 DEBUG(
dbgs() <<
"\t TL = " << TL <<
"\n");
1875 ++ExactRDIVindependence;
1922 bool DependenceAnalysis::symbolicRDIVtest(
const SCEV *A1,
1927 const Loop *Loop2)
const {
1928 ++SymbolicRDIVapplications;
1929 DEBUG(
dbgs() <<
"\ttry symbolic RDIV test\n");
1932 DEBUG(
dbgs() <<
"\t A2 = " << *A2 <<
"\n");
1933 DEBUG(
dbgs() <<
"\t C1 = " << *C1 <<
"\n");
1934 DEBUG(
dbgs() <<
"\t C2 = " << *C2 <<
"\n");
1935 const SCEV *N1 = collectUpperBound(Loop1, A1->
getType());
1936 const SCEV *N2 = collectUpperBound(Loop2, A1->
getType());
1937 DEBUG(
if (N1)
dbgs() <<
"\t N1 = " << *N1 <<
"\n");
1938 DEBUG(
if (N2)
dbgs() <<
"\t N2 = " << *N2 <<
"\n");
1941 DEBUG(
dbgs() <<
"\t C2 - C1 = " << *C2_C1 <<
"\n");
1942 DEBUG(
dbgs() <<
"\t C1 - C2 = " << *C1_C2 <<
"\n");
1949 DEBUG(
dbgs() <<
"\t A1*N1 = " << *A1N1 <<
"\n");
1951 ++SymbolicRDIVindependence;
1958 DEBUG(
dbgs() <<
"\t A2*N2 = " << *A2N2 <<
"\n");
1960 ++SymbolicRDIVindependence;
1972 DEBUG(
dbgs() <<
"\t A1*N1 - A2*N2 = " << *A1N1_A2N2 <<
"\n");
1974 ++SymbolicRDIVindependence;
1980 ++SymbolicRDIVindependence;
1993 DEBUG(
dbgs() <<
"\t A1*N1 - A2*N2 = " << *A1N1_A2N2 <<
"\n");
1995 ++SymbolicRDIVindependence;
2001 ++SymbolicRDIVindependence;
2010 DEBUG(
dbgs() <<
"\t A1*N1 = " << *A1N1 <<
"\n");
2012 ++SymbolicRDIVindependence;
2019 DEBUG(
dbgs() <<
"\t A2*N2 = " << *A2N2 <<
"\n");
2021 ++SymbolicRDIVindependence;
2039 bool DependenceAnalysis::testSIV(
const SCEV *Src,
2043 Constraint &NewConstraint,
2044 const SCEV *&SplitIter)
const {
2045 DEBUG(
dbgs() <<
" src = " << *Src <<
"\n");
2046 DEBUG(
dbgs() <<
" dst = " << *Dst <<
"\n");
2049 if (SrcAddRec && DstAddRec) {
2051 const SCEV *DstConst = DstAddRec->getStart();
2053 const SCEV *DstCoeff = DstAddRec->getStepRecurrence(*SE);
2055 assert(CurLoop == DstAddRec->getLoop() &&
2056 "both loops in SIV should be same");
2057 Level = mapSrcLoop(CurLoop);
2059 if (SrcCoeff == DstCoeff)
2060 disproven = strongSIVtest(SrcCoeff, SrcConst, DstConst, CurLoop,
2061 Level, Result, NewConstraint);
2063 disproven = weakCrossingSIVtest(SrcCoeff, SrcConst, DstConst, CurLoop,
2064 Level, Result, NewConstraint, SplitIter);
2066 disproven = exactSIVtest(SrcCoeff, DstCoeff, SrcConst, DstConst, CurLoop,
2067 Level, Result, NewConstraint);
2069 gcdMIVtest(Src, Dst, Result) ||
2070 symbolicRDIVtest(SrcCoeff, DstCoeff, SrcConst, DstConst, CurLoop, CurLoop);
2075 const SCEV *DstConst = Dst;
2077 Level = mapSrcLoop(CurLoop);
2078 return weakZeroDstSIVtest(SrcCoeff, SrcConst, DstConst, CurLoop,
2079 Level, Result, NewConstraint) ||
2080 gcdMIVtest(Src, Dst, Result);
2083 const SCEV *DstConst = DstAddRec->getStart();
2084 const SCEV *DstCoeff = DstAddRec->getStepRecurrence(*SE);
2085 const SCEV *SrcConst = Src;
2086 const Loop *CurLoop = DstAddRec->getLoop();
2087 Level = mapDstLoop(CurLoop);
2088 return weakZeroSrcSIVtest(DstCoeff, SrcConst, DstConst,
2089 CurLoop, Level, Result, NewConstraint) ||
2090 gcdMIVtest(Src, Dst, Result);
2110 bool DependenceAnalysis::testRDIV(
const SCEV *Src,
2119 const SCEV *SrcConst, *DstConst;
2120 const SCEV *SrcCoeff, *DstCoeff;
2121 const Loop *SrcLoop, *DstLoop;
2123 DEBUG(
dbgs() <<
" src = " << *Src <<
"\n");
2124 DEBUG(
dbgs() <<
" dst = " << *Dst <<
"\n");
2127 if (SrcAddRec && DstAddRec) {
2130 SrcLoop = SrcAddRec->
getLoop();
2131 DstConst = DstAddRec->getStart();
2132 DstCoeff = DstAddRec->getStepRecurrence(*SE);
2133 DstLoop = DstAddRec->getLoop();
2135 else if (SrcAddRec) {
2137 dyn_cast<SCEVAddRecExpr>(SrcAddRec->
getStart())) {
2138 SrcConst = tmpAddRec->getStart();
2139 SrcCoeff = tmpAddRec->getStepRecurrence(*SE);
2140 SrcLoop = tmpAddRec->getLoop();
2143 DstLoop = SrcAddRec->
getLoop();
2148 else if (DstAddRec) {
2150 dyn_cast<SCEVAddRecExpr>(DstAddRec->getStart())) {
2151 DstConst = tmpAddRec->getStart();
2152 DstCoeff = tmpAddRec->getStepRecurrence(*SE);
2153 DstLoop = tmpAddRec->getLoop();
2156 SrcLoop = DstAddRec->getLoop();
2163 return exactRDIVtest(SrcCoeff, DstCoeff,
2167 gcdMIVtest(Src, Dst, Result) ||
2168 symbolicRDIVtest(SrcCoeff, DstCoeff,
2177 bool DependenceAnalysis::testMIV(
const SCEV *Src,
2181 DEBUG(
dbgs() <<
" src = " << *Src <<
"\n");
2182 DEBUG(
dbgs() <<
" dst = " << *Dst <<
"\n");
2183 Result.Consistent =
false;
2184 return gcdMIVtest(Src, Dst, Result) ||
2185 banerjeeMIVtest(Src, Dst, Loops, Result);
2193 for (
unsigned Op = 0, Ops = Product->
getNumOperands(); Op < Ops; Op++) {
2219 bool DependenceAnalysis::gcdMIVtest(
const SCEV *Src,
2231 const SCEV *Coefficients = Src;
2233 dyn_cast<SCEVAddRecExpr>(Coefficients)) {
2236 if (
const SCEVMulExpr *Product = dyn_cast<SCEVMulExpr>(Coeff))
2246 const SCEV *SrcConst = Coefficients;
2254 dyn_cast<SCEVAddRecExpr>(Coefficients)) {
2257 if (
const SCEVMulExpr *Product = dyn_cast<SCEVMulExpr>(Coeff))
2267 const SCEV *DstConst = Coefficients;
2271 DEBUG(
dbgs() <<
" Delta = " << *Delta <<
"\n");
2273 if (
const SCEVAddExpr *Sum = dyn_cast<SCEVAddExpr>(Delta)) {
2275 for (
unsigned Op = 0, Ops = Sum->getNumOperands(); Op < Ops; Op++) {
2276 const SCEV *Operand = Sum->getOperand(Op);
2277 if (isa<SCEVConstant>(Operand)) {
2278 assert(!Constant &&
"Surprised to find multiple constants");
2279 Constant = cast<SCEVConstant>(Operand);
2281 else if (
const SCEVMulExpr *Product = dyn_cast<SCEVMulExpr>(Operand)) {
2289 ConstOpValue.
abs());
2298 DEBUG(
dbgs() <<
" ConstDelta = " << ConstDelta <<
"\n");
2299 if (ConstDelta == 0)
2302 DEBUG(
dbgs() <<
" RunningGCD = " << RunningGCD <<
"\n");
2303 APInt Remainder = ConstDelta.
srem(RunningGCD);
2304 if (Remainder != 0) {
2321 DEBUG(
dbgs() <<
" ExtraGCD = " << ExtraGCD <<
'\n');
2323 bool Improved =
false;
2326 dyn_cast<SCEVAddRecExpr>(Coefficients)) {
2329 RunningGCD = ExtraGCD;
2332 const SCEV *Inner = Src;
2333 while (RunningGCD != 1 && isa<SCEVAddRecExpr>(Inner)) {
2334 AddRec = cast<SCEVAddRecExpr>(Inner);
2336 if (CurLoop == AddRec->
getLoop())
2339 if (
const SCEVMulExpr *Product = dyn_cast<SCEVMulExpr>(Coeff))
2344 Constant = cast<SCEVConstant>(Coeff);
2351 while (RunningGCD != 1 && isa<SCEVAddRecExpr>(Inner)) {
2352 AddRec = cast<SCEVAddRecExpr>(Inner);
2354 if (CurLoop == AddRec->
getLoop())
2357 if (
const SCEVMulExpr *Product = dyn_cast<SCEVMulExpr>(Coeff))
2362 Constant = cast<SCEVConstant>(Coeff);
2369 if (
const SCEVMulExpr *Product = dyn_cast<SCEVMulExpr>(Delta))
2373 else if (isa<SCEVConstant>(Delta))
2374 Constant = cast<SCEVConstant>(Delta);
2382 DEBUG(
dbgs() <<
"\tRunningGCD = " << RunningGCD <<
"\n");
2383 if (RunningGCD != 0) {
2384 Remainder = ConstDelta.
srem(RunningGCD);
2385 DEBUG(
dbgs() <<
"\tRemainder = " << Remainder <<
"\n");
2386 if (Remainder != 0) {
2387 unsigned Level = mapSrcLoop(CurLoop);
2433 bool DependenceAnalysis::banerjeeMIVtest(
const SCEV *Src,
2438 ++BanerjeeApplications;
2439 DEBUG(
dbgs() <<
" Src = " << *Src <<
'\n');
2441 CoefficientInfo *
A = collectCoeffInfo(Src,
true, A0);
2442 DEBUG(
dbgs() <<
" Dst = " << *Dst <<
'\n');
2444 CoefficientInfo *B = collectCoeffInfo(Dst,
false, B0);
2445 BoundInfo *Bound =
new BoundInfo[MaxLevels + 1];
2447 DEBUG(
dbgs() <<
"\tDelta = " << *Delta <<
'\n');
2451 for (
unsigned K = 1; K <= MaxLevels; ++K) {
2452 Bound[K].Iterations = A[K].Iterations ? A[K].Iterations : B[K].Iterations;
2455 findBoundsALL(A, B, Bound, K);
2459 DEBUG(
dbgs() << *Bound[K].Lower[Dependence::DVEntry::ALL] <<
'\t');
2462 if (Bound[K].Upper[Dependence::DVEntry::ALL])
2463 DEBUG(
dbgs() << *Bound[K].Upper[Dependence::DVEntry::ALL] <<
'\n');
2470 bool Disproved =
false;
2471 if (testBounds(Dependence::DVEntry::ALL, 0, Bound, Delta)) {
2473 unsigned DepthExpanded = 0;
2474 unsigned NewDeps = exploreDirections(1, A, B, Bound,
2475 Loops, DepthExpanded, Delta);
2477 bool Improved =
false;
2478 for (
unsigned K = 1; K <= CommonLevels; ++K) {
2480 unsigned Old = Result.DV[K - 1].
Direction;
2481 Result.DV[K - 1].
Direction = Old & Bound[K].DirSet;
2482 Improved |= Old != Result.DV[K - 1].
Direction;
2491 ++BanerjeeSuccesses;
2494 ++BanerjeeIndependence;
2499 ++BanerjeeIndependence;
2514 unsigned DependenceAnalysis::exploreDirections(
unsigned Level,
2519 unsigned &DepthExpanded,
2520 const SCEV *Delta)
const {
2521 if (Level > CommonLevels) {
2524 for (
unsigned K = 1; K <= CommonLevels; ++K) {
2526 Bound[K].DirSet |= Bound[K].Direction;
2528 switch (Bound[K].Direction) {
2538 case Dependence::DVEntry::ALL:
2551 if (Level > DepthExpanded) {
2552 DepthExpanded =
Level;
2554 findBoundsLT(A, B, Bound, Level);
2555 findBoundsGT(A, B, Bound, Level);
2556 findBoundsEQ(A, B, Bound, Level);
2558 DEBUG(
dbgs() <<
"\tBound for level = " << Level <<
'\n');
2561 DEBUG(
dbgs() << *Bound[Level].Lower[Dependence::DVEntry::LT] <<
'\t');
2564 if (Bound[Level].Upper[Dependence::DVEntry::LT])
2565 DEBUG(
dbgs() << *Bound[Level].Upper[Dependence::DVEntry::LT] <<
'\n');
2570 DEBUG(
dbgs() << *Bound[Level].Lower[Dependence::DVEntry::EQ] <<
'\t');
2573 if (Bound[Level].Upper[Dependence::DVEntry::EQ])
2574 DEBUG(
dbgs() << *Bound[Level].Upper[Dependence::DVEntry::EQ] <<
'\n');
2579 DEBUG(
dbgs() << *Bound[Level].Lower[Dependence::DVEntry::GT] <<
'\t');
2582 if (Bound[Level].Upper[Dependence::DVEntry::GT])
2583 DEBUG(
dbgs() << *Bound[Level].Upper[Dependence::DVEntry::GT] <<
'\n');
2589 unsigned NewDeps = 0;
2592 if (testBounds(Dependence::DVEntry::LT, Level, Bound, Delta))
2593 NewDeps += exploreDirections(Level + 1, A, B, Bound,
2594 Loops, DepthExpanded, Delta);
2597 if (testBounds(Dependence::DVEntry::EQ, Level, Bound, Delta))
2598 NewDeps += exploreDirections(Level + 1, A, B, Bound,
2599 Loops, DepthExpanded, Delta);
2602 if (testBounds(Dependence::DVEntry::GT, Level, Bound, Delta))
2603 NewDeps += exploreDirections(Level + 1, A, B, Bound,
2604 Loops, DepthExpanded, Delta);
2610 return exploreDirections(Level + 1, A, B, Bound, Loops, DepthExpanded, Delta);
2615 bool DependenceAnalysis::testBounds(
unsigned char DirKind,
2618 const SCEV *Delta)
const {
2619 Bound[
Level].Direction = DirKind;
2620 if (
const SCEV *LowerBound = getLowerBound(Bound))
2623 if (
const SCEV *UpperBound = getUpperBound(Bound))
2645 void DependenceAnalysis::findBoundsALL(CoefficientInfo *A,
2651 if (Bound[K].Iterations) {
2654 Bound[K].Iterations);
2657 Bound[K].Iterations);
2662 Bound[K].Lower[Dependence::DVEntry::ALL] =
2665 Bound[K].Upper[Dependence::DVEntry::ALL] =
2686 void DependenceAnalysis::findBoundsEQ(CoefficientInfo *A,
2692 if (Bound[K].Iterations) {
2694 const SCEV *NegativePart = getNegativePart(Delta);
2696 SE->
getMulExpr(NegativePart, Bound[K].Iterations);
2697 const SCEV *PositivePart = getPositivePart(Delta);
2699 SE->
getMulExpr(PositivePart, Bound[K].Iterations);
2705 const SCEV *NegativePart = getNegativePart(Delta);
2706 if (NegativePart->
isZero())
2707 Bound[K].Lower[Dependence::DVEntry::EQ] = NegativePart;
2708 const SCEV *PositivePart = getPositivePart(Delta);
2709 if (PositivePart->
isZero())
2710 Bound[K].Upper[Dependence::DVEntry::EQ] = PositivePart;
2728 void DependenceAnalysis::findBoundsLT(CoefficientInfo *A,
2734 if (Bound[K].Iterations) {
2735 const SCEV *Iter_1 =
2737 SE->
getConstant(Bound[K].Iterations->getType(), 1));
2738 const SCEV *NegPart =
2739 getNegativePart(SE->
getMinusSCEV(A[K].NegPart, B[K].Coeff));
2742 const SCEV *PosPart =
2743 getPositivePart(SE->
getMinusSCEV(A[K].PosPart, B[K].Coeff));
2750 const SCEV *NegPart =
2751 getNegativePart(SE->
getMinusSCEV(A[K].NegPart, B[K].Coeff));
2753 Bound[K].Lower[Dependence::DVEntry::LT] = SE->
getNegativeSCEV(B[K].Coeff);
2754 const SCEV *PosPart =
2755 getPositivePart(SE->
getMinusSCEV(A[K].PosPart, B[K].Coeff));
2757 Bound[K].Upper[Dependence::DVEntry::LT] = SE->
getNegativeSCEV(B[K].Coeff);
2775 void DependenceAnalysis::findBoundsGT(CoefficientInfo *A,
2781 if (Bound[K].Iterations) {
2782 const SCEV *Iter_1 =
2784 SE->
getConstant(Bound[K].Iterations->getType(), 1));
2785 const SCEV *NegPart =
2786 getNegativePart(SE->
getMinusSCEV(A[K].Coeff, B[K].PosPart));
2789 const SCEV *PosPart =
2790 getPositivePart(SE->
getMinusSCEV(A[K].Coeff, B[K].NegPart));
2797 const SCEV *NegPart = getNegativePart(SE->
getMinusSCEV(A[K].Coeff, B[K].PosPart));
2799 Bound[K].Lower[Dependence::DVEntry::GT] = A[K].Coeff;
2800 const SCEV *PosPart = getPositivePart(SE->
getMinusSCEV(A[K].Coeff, B[K].NegPart));
2802 Bound[K].Upper[Dependence::DVEntry::GT] = A[K].Coeff;
2808 const SCEV *DependenceAnalysis::getPositivePart(
const SCEV *X)
const {
2814 const SCEV *DependenceAnalysis::getNegativePart(
const SCEV *X)
const {
2822 DependenceAnalysis::CoefficientInfo *
2823 DependenceAnalysis::collectCoeffInfo(
const SCEV *Subscript,
2825 const SCEV *&Constant)
const {
2827 CoefficientInfo *CI =
new CoefficientInfo[MaxLevels + 1];
2828 for (
unsigned K = 1; K <= MaxLevels; ++K) {
2830 CI[K].PosPart = Zero;
2831 CI[K].NegPart = Zero;
2832 CI[K].Iterations = NULL;
2834 while (
const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(Subscript)) {
2836 unsigned K = SrcFlag ? mapSrcLoop(L) : mapDstLoop(L);
2838 CI[K].PosPart = getPositivePart(CI[K].Coeff);
2839 CI[K].NegPart = getNegativePart(CI[K].Coeff);
2840 CI[K].Iterations = collectUpperBound(L, Subscript->
getType());
2843 Constant = Subscript;
2845 DEBUG(
dbgs() <<
"\tCoefficient Info\n");
2846 for (
unsigned K = 1; K <= MaxLevels; ++K) {
2847 DEBUG(
dbgs() <<
"\t " << K <<
"\t" << *CI[K].Coeff);
2853 if (CI[K].Iterations)
2859 DEBUG(
dbgs() <<
"\t Constant = " << *Subscript <<
'\n');
2869 const SCEV *DependenceAnalysis::getLowerBound(BoundInfo *Bound)
const {
2870 const SCEV *Sum = Bound[1].Lower[Bound[1].Direction];
2871 for (
unsigned K = 2; Sum && K <= MaxLevels; ++K) {
2872 if (Bound[K].Lower[Bound[K].Direction])
2873 Sum = SE->
getAddExpr(Sum, Bound[K].Lower[Bound[K].Direction]);
2885 const SCEV *DependenceAnalysis::getUpperBound(BoundInfo *Bound)
const {
2886 const SCEV *Sum = Bound[1].Upper[Bound[1].Direction];
2887 for (
unsigned K = 2; Sum && K <= MaxLevels; ++K) {
2888 if (Bound[K].Upper[Bound[K].Direction])
2889 Sum = SE->
getAddExpr(Sum, Bound[K].Upper[Bound[K].Direction]);
2906 const SCEV *DependenceAnalysis::findCoefficient(
const SCEV *Expr,
2907 const Loop *TargetLoop)
const {
2911 if (AddRec->
getLoop() == TargetLoop)
2913 return findCoefficient(AddRec->
getStart(), TargetLoop);
2922 const SCEV *DependenceAnalysis::zeroCoefficient(
const SCEV *Expr,
2923 const Loop *TargetLoop)
const {
2927 if (AddRec->
getLoop() == TargetLoop)
2941 const SCEV *DependenceAnalysis::addToCoefficient(
const SCEV *Expr,
2942 const Loop *TargetLoop,
2950 if (AddRec->
getLoop() == TargetLoop) {
2982 bool DependenceAnalysis::propagate(
const SCEV *&Src,
2987 bool Result =
false;
2989 DEBUG(
dbgs() <<
"\t Constraint[" <<
LI <<
"] is");
2991 if (Constraints[
LI].isDistance())
2992 Result |= propagateDistance(Src, Dst, Constraints[
LI], Consistent);
2993 else if (Constraints[
LI].isLine())
2994 Result |= propagateLine(Src, Dst, Constraints[
LI], Consistent);
2995 else if (Constraints[
LI].isPoint())
2996 Result |= propagatePoint(Src, Dst, Constraints[
LI]);
3007 bool DependenceAnalysis::propagateDistance(
const SCEV *&Src,
3009 Constraint &CurConstraint,
3011 const Loop *CurLoop = CurConstraint.getAssociatedLoop();
3012 DEBUG(
dbgs() <<
"\t\tSrc is " << *Src <<
"\n");
3013 const SCEV *A_K = findCoefficient(Src, CurLoop);
3018 Src = zeroCoefficient(Src, CurLoop);
3019 DEBUG(
dbgs() <<
"\t\tnew Src is " << *Src <<
"\n");
3020 DEBUG(
dbgs() <<
"\t\tDst is " << *Dst <<
"\n");
3022 DEBUG(
dbgs() <<
"\t\tnew Dst is " << *Dst <<
"\n");
3023 if (!findCoefficient(Dst, CurLoop)->
isZero())
3034 bool DependenceAnalysis::propagateLine(
const SCEV *&Src,
3036 Constraint &CurConstraint,
3038 const Loop *CurLoop = CurConstraint.getAssociatedLoop();
3039 const SCEV *A = CurConstraint.getA();
3040 const SCEV *B = CurConstraint.getB();
3041 const SCEV *
C = CurConstraint.getC();
3042 DEBUG(
dbgs() <<
"\t\tA = " << *A <<
", B = " << *B <<
", C = " << *C <<
"\n");
3043 DEBUG(
dbgs() <<
"\t\tSrc = " << *Src <<
"\n");
3044 DEBUG(
dbgs() <<
"\t\tDst = " << *Dst <<
"\n");
3048 if (!Bconst || !Cconst)
return false;
3050 APInt Charlie = Cconst->getValue()->getValue();
3052 assert(Charlie.
srem(Beta) == 0 &&
"C should be evenly divisible by B");
3053 const SCEV *AP_K = findCoefficient(Dst, CurLoop);
3056 Dst = zeroCoefficient(Dst, CurLoop);
3057 if (!findCoefficient(Src, CurLoop)->
isZero())
3063 if (!Aconst || !Cconst)
return false;
3065 APInt Charlie = Cconst->getValue()->getValue();
3067 assert(Charlie.
srem(Alpha) == 0 &&
"C should be evenly divisible by A");
3068 const SCEV *A_K = findCoefficient(Src, CurLoop);
3070 Src = zeroCoefficient(Src, CurLoop);
3071 if (!findCoefficient(Dst, CurLoop)->
isZero())
3077 if (!Aconst || !Cconst)
return false;
3079 APInt Charlie = Cconst->getValue()->getValue();
3081 assert(Charlie.
srem(Alpha) == 0 &&
"C should be evenly divisible by A");
3082 const SCEV *A_K = findCoefficient(Src, CurLoop);
3084 Src = zeroCoefficient(Src, CurLoop);
3085 Dst = addToCoefficient(Dst, CurLoop, A_K);
3086 if (!findCoefficient(Dst, CurLoop)->
isZero())
3091 const SCEV *A_K = findCoefficient(Src, CurLoop);
3095 Src = zeroCoefficient(Src, CurLoop);
3096 Dst = addToCoefficient(Dst, CurLoop, SE->
getMulExpr(A_K, B));
3097 if (!findCoefficient(Dst, CurLoop)->
isZero())
3100 DEBUG(
dbgs() <<
"\t\tnew Src = " << *Src <<
"\n");
3101 DEBUG(
dbgs() <<
"\t\tnew Dst = " << *Dst <<
"\n");
3109 bool DependenceAnalysis::propagatePoint(
const SCEV *&Src,
3111 Constraint &CurConstraint) {
3112 const Loop *CurLoop = CurConstraint.getAssociatedLoop();
3113 const SCEV *A_K = findCoefficient(Src, CurLoop);
3114 const SCEV *AP_K = findCoefficient(Dst, CurLoop);
3117 DEBUG(
dbgs() <<
"\t\tSrc is " << *Src <<
"\n");
3119 Src = zeroCoefficient(Src, CurLoop);
3120 DEBUG(
dbgs() <<
"\t\tnew Src is " << *Src <<
"\n");
3121 DEBUG(
dbgs() <<
"\t\tDst is " << *Dst <<
"\n");
3122 Dst = zeroCoefficient(Dst, CurLoop);
3123 DEBUG(
dbgs() <<
"\t\tnew Dst is " << *Dst <<
"\n");
3130 const Constraint &CurConstraint
3132 DEBUG(
dbgs() <<
"\tUpdate direction, constraint =");
3134 if (CurConstraint.isAny())
3136 else if (CurConstraint.isDistance()) {
3139 Level.
Distance = CurConstraint.getD();
3142 NewDirection = Dependence::DVEntry::EQ;
3144 NewDirection |= Dependence::DVEntry::LT;
3146 NewDirection |= Dependence::DVEntry::GT;
3149 else if (CurConstraint.isLine()) {
3154 else if (CurConstraint.isPoint()) {
3159 CurConstraint.getY(),
3160 CurConstraint.getX()))
3164 CurConstraint.getY(),
3165 CurConstraint.getX()))
3169 CurConstraint.getY(),
3170 CurConstraint.getX()))
3184 DependenceAnalysis::tryDelinearize(
const SCEV *SrcSCEV,
const SCEV *DstSCEV,
3188 if (!SrcAR || !DstAR || !SrcAR->
isAffine() || !DstAR->isAffine())
3193 DstAR->delinearize(*SE, DstSubscripts, DstSizes);
3195 int size = SrcSubscripts.
size();
3196 int dstSize = DstSubscripts.
size();
3197 if (size != dstSize || size < 2)
3202 for (
int i = 0; i < size; i++)
3205 for (
int i = 0; i < size; i++)
3214 for (
int i = 0; i < size; ++i) {
3215 Pair[i].Src = SrcSubscripts[i];
3216 Pair[i].Dst = DstSubscripts[i];
3258 bool PossiblyLoopIndependent) {
3260 PossiblyLoopIndependent =
false;
3269 DEBUG(
dbgs() <<
"can only handle simple loads and stores\n");
3280 DEBUG(
dbgs() <<
"can't analyze may or partial alias\n");
3291 establishNestingLevels(Src, Dst);
3292 DEBUG(
dbgs() <<
" common nesting levels = " << CommonLevels <<
"\n");
3293 DEBUG(
dbgs() <<
" maximum nesting levels = " << MaxLevels <<
"\n");
3295 FullDependence Result(Src, Dst, PossiblyLoopIndependent, CommonLevels);
3299 bool UsefulGEP =
false;
3302 if (SrcGEP && DstGEP &&
3305 const SCEV *DstPtrSCEV = SE->
getSCEV(DstGEP->getPointerOperand());
3306 DEBUG(
dbgs() <<
" SrcPtrSCEV = " << *SrcPtrSCEV <<
"\n");
3307 DEBUG(
dbgs() <<
" DstPtrSCEV = " << *DstPtrSCEV <<
"\n");
3320 DstIdx = DstGEP->idx_begin();
3322 ++SrcIdx, ++DstIdx, ++
P) {
3323 Pair[
P].Src = SE->
getSCEV(*SrcIdx);
3324 Pair[
P].Dst = SE->
getSCEV(*DstIdx);
3331 DEBUG(
dbgs() <<
" SrcSCEV = " << *SrcSCEV <<
"\n");
3332 DEBUG(
dbgs() <<
" DstSCEV = " << *DstSCEV <<
"\n");
3333 Pair[0].Src = SrcSCEV;
3334 Pair[0].Dst = DstSCEV;
3337 if (
Delinearize && Pairs == 1 && CommonLevels > 1 &&
3338 tryDelinearize(Pair[0].Src, Pair[0].Dst, Pair)) {
3340 Pairs = Pair.
size();
3343 for (
unsigned P = 0;
P < Pairs; ++
P) {
3344 Pair[
P].Loops.
resize(MaxLevels + 1);
3345 Pair[
P].GroupLoops.
resize(MaxLevels + 1);
3347 removeMatchingExtensions(&Pair[
P]);
3348 Pair[
P].Classification =
3349 classifyPair(Pair[P].Src,
LI->getLoopFor(Src->getParent()),
3350 Pair[P].Dst,
LI->getLoopFor(Dst->getParent()),
3352 Pair[
P].GroupLoops = Pair[
P].Loops;
3353 Pair[
P].Group.set(P);
3354 DEBUG(
dbgs() <<
" subscript " << P <<
"\n");
3355 DEBUG(
dbgs() <<
"\tsrc = " << *Pair[P].Src <<
"\n");
3356 DEBUG(
dbgs() <<
"\tdst = " << *Pair[P].Dst <<
"\n");
3357 DEBUG(
dbgs() <<
"\tclass = " << Pair[P].Classification <<
"\n");
3422 for (
unsigned SI = 0; SI < Pairs; ++SI) {
3423 if (Pair[SI].Classification == Subscript::NonLinear) {
3425 ++NonlinearSubscriptPairs;
3426 collectCommonLoops(Pair[SI].Src,
3427 LI->getLoopFor(Src->getParent()),
3429 collectCommonLoops(Pair[SI].Dst,
3430 LI->getLoopFor(Dst->getParent()),
3432 Result.Consistent =
false;
3434 else if (Pair[SI].Classification == Subscript::ZIV) {
3441 for (
unsigned SJ = SI + 1; SJ < Pairs; ++SJ) {
3443 Intersection &= Pair[SJ].GroupLoops;
3444 if (Intersection.
any()) {
3446 Pair[SJ].GroupLoops |= Pair[SI].GroupLoops;
3448 Pair[SJ].Group |= Pair[SI].Group;
3453 if (Pair[SI].Group.count() == 1) {
3455 ++SeparableSubscriptPairs;
3459 ++CoupledSubscriptPairs;
3470 Constraint NewConstraint;
3471 NewConstraint.setAny(SE);
3475 DEBUG(
dbgs() <<
"testing subscript " << SI);
3476 switch (Pair[SI].Classification) {
3477 case Subscript::ZIV:
3479 if (testZIV(Pair[SI].Src, Pair[SI].Dst, Result))
3482 case Subscript::SIV: {
3485 const SCEV *SplitIter = NULL;
3486 if (testSIV(Pair[SI].Src, Pair[SI].Dst, Level,
3487 Result, NewConstraint, SplitIter))
3491 case Subscript::RDIV:
3493 if (testRDIV(Pair[SI].Src, Pair[SI].Dst, Result))
3496 case Subscript::MIV:
3498 if (testMIV(Pair[SI].Src, Pair[SI].Dst, Pair[SI].Loops, Result))
3506 if (Coupled.
count()) {
3508 DEBUG(
dbgs() <<
"starting on coupled subscripts\n");
3509 DEBUG(
dbgs() <<
"MaxLevels + 1 = " << MaxLevels + 1 <<
"\n");
3511 for (
unsigned II = 0; II <= MaxLevels; ++II)
3512 Constraints[II].setAny(SE);
3514 DEBUG(
dbgs() <<
"testing subscript group " << SI <<
" { ");
3521 if (Pair[SJ].Classification == Subscript::SIV)
3527 while (Sivs.
any()) {
3528 bool Changed =
false;
3530 DEBUG(
dbgs() <<
"testing subscript " << SJ <<
", SIV\n");
3533 const SCEV *SplitIter = NULL;
3535 if (testSIV(Pair[SJ].Src, Pair[SJ].Dst, Level,
3536 Result, NewConstraint, SplitIter))
3538 ConstrainedLevels.
set(Level);
3539 if (intersectConstraints(&Constraints[Level], &NewConstraint)) {
3540 if (Constraints[Level].isEmpty()) {
3541 ++DeltaIndependence;
3555 DEBUG(
dbgs() <<
"\tSJ = " << SJ <<
"\n");
3556 if (propagate(Pair[SJ].Src, Pair[SJ].Dst, Pair[SJ].Loops,
3557 Constraints, Result.Consistent)) {
3559 ++DeltaPropagations;
3560 Pair[SJ].Classification =
3561 classifyPair(Pair[SJ].Src,
LI->getLoopFor(Src->getParent()),
3562 Pair[SJ].Dst,
LI->getLoopFor(Dst->getParent()),
3564 switch (Pair[SJ].Classification) {
3565 case Subscript::ZIV:
3567 if (testZIV(Pair[SJ].Src, Pair[SJ].Dst, Result))
3571 case Subscript::SIV:
3575 case Subscript::RDIV:
3576 case Subscript::MIV:
3588 if (Pair[SJ].Classification == Subscript::RDIV) {
3590 if (testRDIV(Pair[SJ].Src, Pair[SJ].Dst, Result))
3601 if (Pair[SJ].Classification == Subscript::MIV) {
3603 if (testMIV(Pair[SJ].Src, Pair[SJ].Dst, Pair[SJ].Loops, Result))
3612 for (
int SJ = ConstrainedLevels.
find_first();
3613 SJ >= 0; SJ = ConstrainedLevels.
find_next(SJ)) {
3614 updateDirection(Result.DV[SJ - 1], Constraints[SJ]);
3623 for (
unsigned SI = 0; SI < Pairs; ++SI)
3624 CompleteLoops |= Pair[SI].Loops;
3625 for (
unsigned II = 1; II <= CommonLevels; ++II)
3626 if (CompleteLoops[II])
3627 Result.DV[II - 1].
Scalar =
false;
3629 if (PossiblyLoopIndependent) {
3633 for (
unsigned II = 1; II <= CommonLevels; ++II) {
3635 Result.LoopIndependent =
false;
3643 bool AllEqual =
true;
3644 for (
unsigned II = 1; II <= CommonLevels; ++II) {
3709 unsigned SplitLevel) {
3710 assert(Dep &&
"expected a pointer to a Dependence");
3712 "Dep should be splitable at SplitLevel");
3715 assert(Src->mayReadFromMemory() || Src->mayWriteToMemory());
3725 establishNestingLevels(Src, Dst);
3730 bool UsefulGEP =
false;
3733 if (SrcGEP && DstGEP &&
3736 const SCEV *DstPtrSCEV = SE->
getSCEV(DstGEP->getPointerOperand());
3747 DstIdx = DstGEP->idx_begin();
3749 ++SrcIdx, ++DstIdx, ++
P) {
3750 Pair[
P].Src = SE->
getSCEV(*SrcIdx);
3751 Pair[
P].Dst = SE->
getSCEV(*DstIdx);
3757 Pair[0].Src = SrcSCEV;
3758 Pair[0].Dst = DstSCEV;
3761 if (
Delinearize && Pairs == 1 && CommonLevels > 1 &&
3762 tryDelinearize(Pair[0].Src, Pair[0].Dst, Pair)) {
3764 Pairs = Pair.
size();
3767 for (
unsigned P = 0;
P < Pairs; ++
P) {
3768 Pair[
P].Loops.
resize(MaxLevels + 1);
3769 Pair[
P].GroupLoops.
resize(MaxLevels + 1);
3771 removeMatchingExtensions(&Pair[
P]);
3772 Pair[
P].Classification =
3773 classifyPair(Pair[P].Src,
LI->getLoopFor(Src->getParent()),
3774 Pair[P].Dst,
LI->getLoopFor(Dst->getParent()),
3776 Pair[
P].GroupLoops = Pair[
P].Loops;
3777 Pair[
P].Group.set(P);
3784 for (
unsigned SI = 0; SI < Pairs; ++SI) {
3785 if (Pair[SI].Classification == Subscript::NonLinear) {
3787 collectCommonLoops(Pair[SI].Src,
3788 LI->getLoopFor(Src->getParent()),
3790 collectCommonLoops(Pair[SI].Dst,
3791 LI->getLoopFor(Dst->getParent()),
3793 Result.Consistent =
false;
3795 else if (Pair[SI].Classification == Subscript::ZIV)
3800 for (
unsigned SJ = SI + 1; SJ < Pairs; ++SJ) {
3802 Intersection &= Pair[SJ].GroupLoops;
3803 if (Intersection.
any()) {
3805 Pair[SJ].GroupLoops |= Pair[SI].GroupLoops;
3807 Pair[SJ].Group |= Pair[SI].Group;
3812 if (Pair[SI].Group.count() == 1)
3820 Constraint NewConstraint;
3821 NewConstraint.setAny(SE);
3825 switch (Pair[SI].Classification) {
3826 case Subscript::SIV: {
3828 const SCEV *SplitIter = NULL;
3829 (void) testSIV(Pair[SI].Src, Pair[SI].Dst, Level,
3830 Result, NewConstraint, SplitIter);
3831 if (Level == SplitLevel) {
3832 assert(SplitIter != NULL);
3837 case Subscript::ZIV:
3838 case Subscript::RDIV:
3839 case Subscript::MIV:
3846 if (Coupled.
count()) {
3849 for (
unsigned II = 0; II <= MaxLevels; ++II)
3850 Constraints[II].setAny(SE);
3857 if (Pair[SJ].Classification == Subscript::SIV)
3862 while (Sivs.
any()) {
3863 bool Changed =
false;
3867 const SCEV *SplitIter = NULL;
3868 (void) testSIV(Pair[SJ].Src, Pair[SJ].Dst, Level,
3869 Result, NewConstraint, SplitIter);
3870 if (Level == SplitLevel && SplitIter)
3872 ConstrainedLevels.
set(Level);
3873 if (intersectConstraints(&Constraints[Level], &NewConstraint))
3881 if (propagate(Pair[SJ].Src, Pair[SJ].Dst,
3882 Pair[SJ].Loops, Constraints, Result.Consistent)) {
3883 Pair[SJ].Classification =
3884 classifyPair(Pair[SJ].Src,
LI->getLoopFor(Src->getParent()),
3885 Pair[SJ].Dst,
LI->getLoopFor(Dst->getParent()),
3887 switch (Pair[SJ].Classification) {
3888 case Subscript::ZIV:
3891 case Subscript::SIV:
3895 case Subscript::RDIV:
3896 case Subscript::MIV:
NoWrapFlags getNoWrapFlags(NoWrapFlags Mask=NoWrapMask) const
Pointers differ, but pointees overlap.
bool isPeelFirst(unsigned Level) const
APInt LLVM_ATTRIBUTE_UNUSED_RESULT abs() const
Get the absolute value;.
INITIALIZE_PASS_BEGIN(DependenceAnalysis,"da","Dependence Analysis", true, true) INITIALIZE_PASS_END(DependenceAnalysis
virtual bool isConfused() const
static bool isLoopInvariant(Value *V, const Loop *L, const DominatorTree *DT)
const SCEV * getConstant(ConstantInt *V)
APInt GreatestCommonDivisor(const APInt &Val1, const APInt &Val2)
Compute GCD of two APInt values.
The main container class for the LLVM Intermediate Representation.
virtual bool isPeelFirst(unsigned Level) const
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
FunctionPass * createDependenceAnalysisPass()
bool runOnFunction(Function &F)
bool isScalar(unsigned Level) const
bool isKnownNonNegative(const SCEV *S)
static APInt ceilingOfQuotient(APInt A, APInt B)
static void dumpExampleDependence(raw_ostream &OS, Function *F, DependenceAnalysis *DA)
static void sdivrem(const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder)
const SCEV * getStepRecurrence(ScalarEvolution &SE) const
static Value * getPointerOperand(Instruction *I)
static void dumpSmallBitVector(SmallBitVector &BV)
bool isLoopInvariant(const SCEV *S, const Loop *L)
LoopT * getParentLoop() const
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
LoopInfoBase< BlockT, LoopT > * LI
const SCEV * getStart() const
bool isKnownNonPositive(const SCEV *S)
const SCEV * getDistance(unsigned Level) const
Type * getPointerOperandType() const
Value * GetUnderlyingObject(Value *V, const DataLayout *TD=0, unsigned MaxLookup=6)
#define INITIALIZE_PASS_DEPENDENCY(depName)
inst_iterator inst_begin(Function *F)
const APInt & getValue() const
Return the constant's value.
#define llvm_unreachable(msg)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
static bool findGCD(unsigned Bits, APInt AM, APInt BM, APInt Delta, APInt &G, APInt &X, APInt &Y)
uint64_t getTypeSizeInBits(Type *Ty) const
virtual bool isSplitable(unsigned Level) const
unsigned count() const
count - Returns the number of bits which are set.
ID
LLVM Calling Convention Representation.
bool isKnownPredicate(ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS)
bool mayReadFromMemory() const
bool sgt(const APInt &RHS) const
Signed greather than comparison.
uint64_t getTypeStoreSize(Type *Ty)
static cl::opt< bool > Delinearize("da-delinearize", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Try to delinearize array references."))
STATISTIC(TotalArrayPairs,"Array pairs tested")
static const SCEVConstant * getConstantPart(const SCEVMulExpr *Product)
const SCEV * getAddRecExpr(const SCEV *Start, const SCEV *Step, const Loop *L, SCEV::NoWrapFlags Flags)
size_t getNumOperands() const
void getAnalysisUsage(AnalysisUsage &) const
void print(raw_ostream &, const Module *=0) const
initializer< Ty > init(const Ty &Val)
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
* if(!EatIfPresent(lltok::kw_thread_local)) return false
static AliasAnalysis::AliasResult underlyingObjectsAlias(AliasAnalysis *AA, const Value *A, const Value *B)
LLVM Basic Block Representation.
Dependence * depends(Instruction *Src, Instruction *Dst, bool PossiblyLoopIndependent)
virtual AliasResult alias(const Location &LocA, const Location &LocB)
LLVM Constant Representation.
virtual bool isScalar(unsigned Level) const
const SCEV * getOperand(unsigned i) const
static bool isLoadOrStore(const Instruction *I)
const SCEV * getSMaxExpr(const SCEV *LHS, const SCEV *RHS)
const SCEV * getMinusSCEV(const SCEV *LHS, const SCEV *RHS, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
getMinusSCEV - Return LHS-RHS. Minus is represented in SCEV as A+B*-1.
unsigned getBitWidth() const
Return the number of bits in the APInt.
unsigned getDirection(unsigned Level) const
int find_next(unsigned Prev) const
Value * getPointerOperand()
APInt LLVM_ATTRIBUTE_UNUSED_RESULT sdiv(const APInt &RHS) const
Signed division function for APInt.
const SCEV * getSplitIteration(const Dependence *Dep, unsigned Level)
virtual const SCEV * getDistance(unsigned Level) const
bool isKnownNegative(const SCEV *S)
Instruction * getSrc() const
static APInt minAPInt(APInt A, APInt B)
#define INITIALIZE_AG_DEPENDENCY(depName)
const SCEV * getNoopOrZeroExtend(const SCEV *V, Type *Ty)
virtual unsigned getDirection(unsigned Level) const
virtual bool isConsistent() const
bool mayWriteToMemory() const
APInt LLVM_ATTRIBUTE_UNUSED_RESULT srem(const APInt &RHS) const
Function for signed remainder operation.
bool isPeelLast(unsigned Level) const
const SCEV * getSMinExpr(const SCEV *LHS, const SCEV *RHS)
static bool isZero(Value *V, DataLayout *DL)
bool isKnownPositive(const SCEV *S)
bool slt(const APInt &RHS) const
Signed less than comparison.
static APInt floorOfQuotient(APInt A, APInt B)
virtual unsigned getLevels() const
ConstantInt * getValue() const
const SCEV * delinearize(ScalarEvolution &SE, SmallVectorImpl< const SCEV * > &Subscripts, SmallVectorImpl< const SCEV * > &Sizes) const
virtual bool isPeelLast(unsigned Level) const
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
Class for arbitrary precision integers.
FullDependence(Instruction *Src, Instruction *Dst, bool LoopIndependent, unsigned Levels)
const SCEV * getAddExpr(SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
virtual bool isLoopIndependent() const
Instruction * getDst() const
void dump(raw_ostream &OS) const
bool isKnownNonZero(const SCEV *S)
static bool isRemainderZero(const SCEVConstant *Dividend, const SCEVConstant *Divisor)
AnalysisUsage & addRequiredTransitive()
const Loop * getLoop() const
static APInt maxAPInt(APInt A, APInt B)
const SCEV * getBackedgeTakenCount(const Loop *L)
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
LLVM Value Representation.
bool any() const
any - Returns true if any bit is set.
const SCEV * getSCEV(Value *V)
const SCEV * getUDivExpr(const SCEV *LHS, const SCEV *RHS)
inst_iterator inst_end(Function *F)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
const SCEV * getNegativeSCEV(const SCEV *V)
static APInt getNullValue(unsigned numBits)
Get the '0' value.
const SCEV * getOperand() const
unsigned getLoopDepth() const
const SCEV * getMulExpr(SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
bool hasLoopInvariantBackedgeTakenCount(const Loop *L)
static RegisterPass< NVPTXAllocaHoisting > X("alloca-hoisting","Hoisting alloca instructions in non-entry ""blocks to the entry block")
const BasicBlock * getParent() const
bool isSplitable(unsigned Level) const