diff --git a/llvm/include/llvm/Analysis/DependenceAnalysis.h b/llvm/include/llvm/Analysis/DependenceAnalysis.h index ec16fe5871c3..7ca7dde46708 100644 --- a/llvm/include/llvm/Analysis/DependenceAnalysis.h +++ b/llvm/include/llvm/Analysis/DependenceAnalysis.h @@ -535,10 +535,8 @@ private: /// Returns true if any possible dependence is disproved. /// If there might be a dependence, returns false. /// Sets appropriate direction entry. - bool weakCrossingSIVtest(const SCEV *SrcCoeff, const SCEV *SrcConst, - const SCEV *DstConst, const Loop *CurrentSrcLoop, - const Loop *CurrentDstLoop, unsigned Level, - FullDependence &Result) const; + bool weakCrossingSIVtest(const SCEVAddRecExpr *Src, const SCEVAddRecExpr *Dst, + unsigned Level, FullDependence &Result) const; /// ExactSIVtest - Tests the SIV subscript pair /// (Src and Dst) for dependence. diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp index f9ef645f8f2d..76f514e4c932 100644 --- a/llvm/lib/Analysis/DependenceAnalysis.cpp +++ b/llvm/lib/Analysis/DependenceAnalysis.cpp @@ -1363,15 +1363,20 @@ bool DependenceInfo::strongSIVtest(const SCEVAddRecExpr *Src, // Can determine iteration for splitting. // // Return true if dependence disproved. -bool DependenceInfo::weakCrossingSIVtest(const SCEV *Coeff, - const SCEV *SrcConst, - const SCEV *DstConst, - const Loop *CurSrcLoop, - const Loop *CurDstLoop, unsigned Level, +bool DependenceInfo::weakCrossingSIVtest(const SCEVAddRecExpr *Src, + const SCEVAddRecExpr *Dst, + unsigned Level, FullDependence &Result) const { if (!isDependenceTestEnabled(DependenceTestType::WeakCrossingSIV)) return false; + const SCEV *Coeff = Src->getStepRecurrence(*SE); + const SCEV *SrcConst = Src->getStart(); + const SCEV *DstConst = Dst->getStart(); + + assert(Coeff == SE->getNegativeSCEV(Dst->getStepRecurrence(*SE)) && + "Unexpected input for weakCrossingSIVtest"); + LLVM_DEBUG(dbgs() << "\tWeak-Crossing SIV test\n"); LLVM_DEBUG(dbgs() << "\t Coeff = " << *Coeff << "\n"); LLVM_DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n"); @@ -1421,6 +1426,7 @@ bool DependenceInfo::weakCrossingSIVtest(const SCEV *Coeff, // We're certain that Delta > 0 and ConstCoeff > 0. // Check Delta/(2*ConstCoeff) against upper loop bound + const Loop *CurSrcLoop = Src->getLoop(); if (const SCEV *UpperBound = collectUpperBound(CurSrcLoop, Delta->getType())) { LLVM_DEBUG(dbgs() << "\t UpperBound = " << *UpperBound << "\n"); @@ -2074,8 +2080,6 @@ bool DependenceInfo::testSIV(const SCEV *Src, const SCEV *Dst, unsigned &Level, const SCEVAddRecExpr *SrcAddRec = dyn_cast(Src); const SCEVAddRecExpr *DstAddRec = dyn_cast(Dst); if (SrcAddRec && DstAddRec) { - const SCEV *SrcConst = SrcAddRec->getStart(); - const SCEV *DstConst = DstAddRec->getStart(); const SCEV *SrcCoeff = SrcAddRec->getStepRecurrence(*SE); const SCEV *DstCoeff = DstAddRec->getStepRecurrence(*SE); const Loop *CurSrcLoop = SrcAddRec->getLoop(); @@ -2089,8 +2093,7 @@ bool DependenceInfo::testSIV(const SCEV *Src, const SCEV *Dst, unsigned &Level, disproven = strongSIVtest(SrcAddRec, DstAddRec, Level, Result, UnderRuntimeAssumptions); else if (SrcCoeff == SE->getNegativeSCEV(DstCoeff)) - disproven = weakCrossingSIVtest(SrcCoeff, SrcConst, DstConst, CurSrcLoop, - CurDstLoop, Level, Result); + disproven = weakCrossingSIVtest(SrcAddRec, DstAddRec, Level, Result); else disproven = exactSIVtest(SrcAddRec, DstAddRec, Level, Result); return disproven || gcdMIVtest(Src, Dst, Result);