diff options
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopAccessAnalysis.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index d67fd79..872bc52 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -412,12 +412,10 @@ bool RuntimePointerChecking::needsChecking( /// Return nullptr in case we couldn't find an answer. static const SCEV *getMinFromExprs(const SCEV *I, const SCEV *J, ScalarEvolution *SE) { - const SCEV *Diff = SE->getMinusSCEV(J, I); - const SCEVConstant *C = dyn_cast<const SCEVConstant>(Diff); - - if (!C) + std::optional<APInt> Diff = SE->computeConstantDifference(J, I); + if (!Diff) return nullptr; - return C->getValue()->isNegative() ? J : I; + return Diff->isNegative() ? J : I; } bool RuntimeCheckingPtrGroup::addPointer( @@ -1599,11 +1597,11 @@ std::optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA, // Otherwise compute the distance with SCEV between the base pointers. const SCEV *PtrSCEVA = SE.getSCEV(PtrA); const SCEV *PtrSCEVB = SE.getSCEV(PtrB); - const auto *Diff = - dyn_cast<SCEVConstant>(SE.getMinusSCEV(PtrSCEVB, PtrSCEVA)); + std::optional<APInt> Diff = + SE.computeConstantDifference(PtrSCEVB, PtrSCEVA); if (!Diff) return std::nullopt; - Val = Diff->getAPInt().getSExtValue(); + Val = Diff->getSExtValue(); } int Size = DL.getTypeStoreSize(ElemTyA); int Dist = Val / Size; |