@@ -1120,57 +1120,6 @@ DependenceInfo::classifyPair(const SCEV *Src, const Loop *SrcLoopNest,
11201120 return Subscript::MIV;
11211121}
11221122
1123- // A wrapper around SCEV::isKnownPredicate.
1124- // Looks for cases where we're interested in comparing for equality.
1125- // If both X and Y have been identically sign or zero extended,
1126- // it strips off the (confusing) extensions before invoking
1127- // SCEV::isKnownPredicate. Perhaps, someday, the ScalarEvolution package
1128- // will be similarly updated.
1129- //
1130- // If SCEV::isKnownPredicate can't prove the predicate,
1131- // we try simple subtraction, which seems to help in some cases
1132- // involving symbolics.
1133- bool DependenceInfo::isKnownPredicate (ICmpInst::Predicate Pred, const SCEV *X,
1134- const SCEV *Y) const {
1135- if (Pred == CmpInst::ICMP_EQ || Pred == CmpInst::ICMP_NE) {
1136- if ((isa<SCEVSignExtendExpr>(X) && isa<SCEVSignExtendExpr>(Y)) ||
1137- (isa<SCEVZeroExtendExpr>(X) && isa<SCEVZeroExtendExpr>(Y))) {
1138- const SCEVIntegralCastExpr *CX = cast<SCEVIntegralCastExpr>(X);
1139- const SCEVIntegralCastExpr *CY = cast<SCEVIntegralCastExpr>(Y);
1140- const SCEV *Xop = CX->getOperand ();
1141- const SCEV *Yop = CY->getOperand ();
1142- if (Xop->getType () == Yop->getType ()) {
1143- X = Xop;
1144- Y = Yop;
1145- }
1146- }
1147- }
1148- if (SE->isKnownPredicate (Pred, X, Y))
1149- return true ;
1150- // If SE->isKnownPredicate can't prove the condition,
1151- // we try the brute-force approach of subtracting
1152- // and testing the difference.
1153- // By testing with SE->isKnownPredicate first, we avoid
1154- // the possibility of overflow when the arguments are constants.
1155- const SCEV *Delta = SE->getMinusSCEV (X, Y);
1156- switch (Pred) {
1157- case CmpInst::ICMP_EQ:
1158- return Delta->isZero ();
1159- case CmpInst::ICMP_NE:
1160- return SE->isKnownNonZero (Delta);
1161- case CmpInst::ICMP_SGE:
1162- return SE->isKnownNonNegative (Delta);
1163- case CmpInst::ICMP_SLE:
1164- return SE->isKnownNonPositive (Delta);
1165- case CmpInst::ICMP_SGT:
1166- return SE->isKnownPositive (Delta);
1167- case CmpInst::ICMP_SLT:
1168- return SE->isKnownNegative (Delta);
1169- default :
1170- llvm_unreachable (" unexpected predicate in isKnownPredicate" );
1171- }
1172- }
1173-
11741123// All subscripts are all the same type.
11751124// Loop bound may be smaller (e.g., a char).
11761125// Should zero extend loop bound, since it's always >= 0.
@@ -1252,11 +1201,11 @@ bool DependenceInfo::testZIV(const SCEV *Src, const SCEV *Dst,
12521201 LLVM_DEBUG (dbgs () << " src = " << *Src << " \n " );
12531202 LLVM_DEBUG (dbgs () << " dst = " << *Dst << " \n " );
12541203 ++ZIVapplications;
1255- if (isKnownPredicate (CmpInst::ICMP_EQ, Src, Dst)) {
1204+ if (SE-> isKnownPredicate (CmpInst::ICMP_EQ, Src, Dst)) {
12561205 LLVM_DEBUG (dbgs () << " provably dependent\n " );
12571206 return false ; // provably dependent
12581207 }
1259- if (isKnownPredicate (CmpInst::ICMP_NE, Src, Dst)) {
1208+ if (SE-> isKnownPredicate (CmpInst::ICMP_NE, Src, Dst)) {
12601209 LLVM_DEBUG (dbgs () << " provably independent\n " );
12611210 ++ZIVindependence;
12621211 return true ; // provably independent
@@ -1335,7 +1284,7 @@ bool DependenceInfo::strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst,
13351284 const SCEV *Product = mulSCEVNoSignedOverflow (UpperBound, AbsCoeff, *SE);
13361285 if (!Product)
13371286 return false ;
1338- return isKnownPredicate (CmpInst::ICMP_SGT, AbsDelta, Product);
1287+ return SE-> isKnownPredicate (CmpInst::ICMP_SGT, AbsDelta, Product);
13391288 }();
13401289 if (IsDeltaLarge) {
13411290 // Distance greater than trip count - no dependence
@@ -1522,13 +1471,13 @@ bool DependenceInfo::weakCrossingSIVtest(const SCEV *Coeff,
15221471 const SCEV *ML =
15231472 SE->getMulExpr (SE->getMulExpr (ConstCoeff, UpperBound), ConstantTwo);
15241473 LLVM_DEBUG (dbgs () << " \t ML = " << *ML << " \n " );
1525- if (isKnownPredicate (CmpInst::ICMP_SGT, Delta, ML)) {
1474+ if (SE-> isKnownPredicate (CmpInst::ICMP_SGT, Delta, ML)) {
15261475 // Delta too big, no dependence
15271476 ++WeakCrossingSIVindependence;
15281477 ++WeakCrossingSIVsuccesses;
15291478 return true ;
15301479 }
1531- if (isKnownPredicate (CmpInst::ICMP_EQ, Delta, ML)) {
1480+ if (SE-> isKnownPredicate (CmpInst::ICMP_EQ, Delta, ML)) {
15321481 // i = i' = UB
15331482 Result.DV [Level].Direction &= ~Dependence::DVEntry::LT;
15341483 Result.DV [Level].Direction &= ~Dependence::DVEntry::GT;
@@ -1911,7 +1860,7 @@ bool DependenceInfo::weakZeroSrcSIVtest(const SCEV *DstCoeff,
19111860 Result.Consistent = false ;
19121861 const SCEV *Delta = SE->getMinusSCEV (SrcConst, DstConst);
19131862 LLVM_DEBUG (dbgs () << " \t Delta = " << *Delta << " \n " );
1914- if (isKnownPredicate (CmpInst::ICMP_EQ, SrcConst, DstConst)) {
1863+ if (SE-> isKnownPredicate (CmpInst::ICMP_EQ, SrcConst, DstConst)) {
19151864 if (Level < CommonLevels) {
19161865 Result.DV [Level].Direction &= Dependence::DVEntry::GE;
19171866 Result.DV [Level].PeelFirst = true ;
@@ -1937,12 +1886,12 @@ bool DependenceInfo::weakZeroSrcSIVtest(const SCEV *DstCoeff,
19371886 collectUpperBound (CurSrcLoop, Delta->getType ())) {
19381887 LLVM_DEBUG (dbgs () << " \t UpperBound = " << *UpperBound << " \n " );
19391888 const SCEV *Product = SE->getMulExpr (AbsCoeff, UpperBound);
1940- if (isKnownPredicate (CmpInst::ICMP_SGT, NewDelta, Product)) {
1889+ if (SE-> isKnownPredicate (CmpInst::ICMP_SGT, NewDelta, Product)) {
19411890 ++WeakZeroSIVindependence;
19421891 ++WeakZeroSIVsuccesses;
19431892 return true ;
19441893 }
1945- if (isKnownPredicate (CmpInst::ICMP_EQ, NewDelta, Product)) {
1894+ if (SE-> isKnownPredicate (CmpInst::ICMP_EQ, NewDelta, Product)) {
19461895 // dependences caused by last iteration
19471896 if (Level < CommonLevels) {
19481897 Result.DV [Level].Direction &= Dependence::DVEntry::LE;
@@ -2024,7 +1973,7 @@ bool DependenceInfo::weakZeroDstSIVtest(const SCEV *SrcCoeff,
20241973 Result.Consistent = false ;
20251974 const SCEV *Delta = SE->getMinusSCEV (DstConst, SrcConst);
20261975 LLVM_DEBUG (dbgs () << " \t Delta = " << *Delta << " \n " );
2027- if (isKnownPredicate (CmpInst::ICMP_EQ, DstConst, SrcConst)) {
1976+ if (SE-> isKnownPredicate (CmpInst::ICMP_EQ, DstConst, SrcConst)) {
20281977 if (Level < CommonLevels) {
20291978 Result.DV [Level].Direction &= Dependence::DVEntry::LE;
20301979 Result.DV [Level].PeelFirst = true ;
@@ -2050,12 +1999,12 @@ bool DependenceInfo::weakZeroDstSIVtest(const SCEV *SrcCoeff,
20501999 collectUpperBound (CurSrcLoop, Delta->getType ())) {
20512000 LLVM_DEBUG (dbgs () << " \t UpperBound = " << *UpperBound << " \n " );
20522001 const SCEV *Product = SE->getMulExpr (AbsCoeff, UpperBound);
2053- if (isKnownPredicate (CmpInst::ICMP_SGT, NewDelta, Product)) {
2002+ if (SE-> isKnownPredicate (CmpInst::ICMP_SGT, NewDelta, Product)) {
20542003 ++WeakZeroSIVindependence;
20552004 ++WeakZeroSIVsuccesses;
20562005 return true ;
20572006 }
2058- if (isKnownPredicate (CmpInst::ICMP_EQ, NewDelta, Product)) {
2007+ if (SE-> isKnownPredicate (CmpInst::ICMP_EQ, NewDelta, Product)) {
20592008 // dependences caused by last iteration
20602009 if (Level < CommonLevels) {
20612010 Result.DV [Level].Direction &= Dependence::DVEntry::GE;
@@ -2268,7 +2217,7 @@ bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2,
22682217 // make sure that c2 - c1 <= a1*N1
22692218 const SCEV *A1N1 = SE->getMulExpr (A1, N1);
22702219 LLVM_DEBUG (dbgs () << " \t A1*N1 = " << *A1N1 << " \n " );
2271- if (isKnownPredicate (CmpInst::ICMP_SGT, C2_C1, A1N1)) {
2220+ if (SE-> isKnownPredicate (CmpInst::ICMP_SGT, C2_C1, A1N1)) {
22722221 ++SymbolicRDIVindependence;
22732222 return true ;
22742223 }
@@ -2277,7 +2226,7 @@ bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2,
22772226 // make sure that -a2*N2 <= c2 - c1, or a2*N2 >= c1 - c2
22782227 const SCEV *A2N2 = SE->getMulExpr (A2, N2);
22792228 LLVM_DEBUG (dbgs () << " \t A2*N2 = " << *A2N2 << " \n " );
2280- if (isKnownPredicate (CmpInst::ICMP_SLT, A2N2, C1_C2)) {
2229+ if (SE-> isKnownPredicate (CmpInst::ICMP_SLT, A2N2, C1_C2)) {
22812230 ++SymbolicRDIVindependence;
22822231 return true ;
22832232 }
@@ -2290,7 +2239,7 @@ bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2,
22902239 const SCEV *A2N2 = SE->getMulExpr (A2, N2);
22912240 const SCEV *A1N1_A2N2 = SE->getMinusSCEV (A1N1, A2N2);
22922241 LLVM_DEBUG (dbgs () << " \t A1*N1 - A2*N2 = " << *A1N1_A2N2 << " \n " );
2293- if (isKnownPredicate (CmpInst::ICMP_SGT, C2_C1, A1N1_A2N2)) {
2242+ if (SE-> isKnownPredicate (CmpInst::ICMP_SGT, C2_C1, A1N1_A2N2)) {
22942243 ++SymbolicRDIVindependence;
22952244 return true ;
22962245 }
@@ -2310,7 +2259,7 @@ bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2,
23102259 const SCEV *A2N2 = SE->getMulExpr (A2, N2);
23112260 const SCEV *A1N1_A2N2 = SE->getMinusSCEV (A1N1, A2N2);
23122261 LLVM_DEBUG (dbgs () << " \t A1*N1 - A2*N2 = " << *A1N1_A2N2 << " \n " );
2313- if (isKnownPredicate (CmpInst::ICMP_SGT, A1N1_A2N2, C2_C1)) {
2262+ if (SE-> isKnownPredicate (CmpInst::ICMP_SGT, A1N1_A2N2, C2_C1)) {
23142263 ++SymbolicRDIVindependence;
23152264 return true ;
23162265 }
@@ -2326,7 +2275,7 @@ bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2,
23262275 // make sure that a1*N1 <= c2 - c1
23272276 const SCEV *A1N1 = SE->getMulExpr (A1, N1);
23282277 LLVM_DEBUG (dbgs () << " \t A1*N1 = " << *A1N1 << " \n " );
2329- if (isKnownPredicate (CmpInst::ICMP_SGT, A1N1, C2_C1)) {
2278+ if (SE-> isKnownPredicate (CmpInst::ICMP_SGT, A1N1, C2_C1)) {
23302279 ++SymbolicRDIVindependence;
23312280 return true ;
23322281 }
@@ -2335,7 +2284,7 @@ bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2,
23352284 // make sure that c2 - c1 <= -a2*N2, or c1 - c2 >= a2*N2
23362285 const SCEV *A2N2 = SE->getMulExpr (A2, N2);
23372286 LLVM_DEBUG (dbgs () << " \t A2*N2 = " << *A2N2 << " \n " );
2338- if (isKnownPredicate (CmpInst::ICMP_SLT, C1_C2, A2N2)) {
2287+ if (SE-> isKnownPredicate (CmpInst::ICMP_SLT, C1_C2, A2N2)) {
23392288 ++SymbolicRDIVindependence;
23402289 return true ;
23412290 }
@@ -2913,10 +2862,10 @@ bool DependenceInfo::testBounds(unsigned char DirKind, unsigned Level,
29132862 BoundInfo *Bound, const SCEV *Delta) const {
29142863 Bound[Level].Direction = DirKind;
29152864 if (const SCEV *LowerBound = getLowerBound (Bound))
2916- if (isKnownPredicate (CmpInst::ICMP_SGT, LowerBound, Delta))
2865+ if (SE-> isKnownPredicate (CmpInst::ICMP_SGT, LowerBound, Delta))
29172866 return false ;
29182867 if (const SCEV *UpperBound = getUpperBound (Bound))
2919- if (isKnownPredicate (CmpInst::ICMP_SGT, Delta, UpperBound))
2868+ if (SE-> isKnownPredicate (CmpInst::ICMP_SGT, Delta, UpperBound))
29202869 return false ;
29212870 return true ;
29222871}
@@ -2949,10 +2898,10 @@ void DependenceInfo::findBoundsALL(CoefficientInfo *A, CoefficientInfo *B,
29492898 SE->getMinusSCEV (A[K].PosPart , B[K].NegPart ), Bound[K].Iterations );
29502899 } else {
29512900 // If the difference is 0, we won't need to know the number of iterations.
2952- if (isKnownPredicate (CmpInst::ICMP_EQ, A[K].NegPart , B[K].PosPart ))
2901+ if (SE-> isKnownPredicate (CmpInst::ICMP_EQ, A[K].NegPart , B[K].PosPart ))
29532902 Bound[K].Lower [Dependence::DVEntry::ALL] =
29542903 SE->getZero (A[K].Coeff ->getType ());
2955- if (isKnownPredicate (CmpInst::ICMP_EQ, A[K].PosPart , B[K].NegPart ))
2904+ if (SE-> isKnownPredicate (CmpInst::ICMP_EQ, A[K].PosPart , B[K].NegPart ))
29562905 Bound[K].Upper [Dependence::DVEntry::ALL] =
29572906 SE->getZero (A[K].Coeff ->getType ());
29582907 }
0 commit comments