diff options
author | Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com> | 2024-10-22 09:58:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-22 09:58:54 +0100 |
commit | d897ea37dbac66d51794938af4f112e05fb61b05 (patch) | |
tree | 20016d1842f0615bae5a0ae322018b99f4aaa70b /llvm/lib/Analysis/LoopAccessAnalysis.cpp | |
parent | f719cfa8685a30a3f4115cc0ce446262daf81244 (diff) | |
download | llvm-d897ea37dbac66d51794938af4f112e05fb61b05.zip llvm-d897ea37dbac66d51794938af4f112e05fb61b05.tar.gz llvm-d897ea37dbac66d51794938af4f112e05fb61b05.tar.bz2 |
LAA: check nusw on GEP in place of inbounds (#112223)
With the introduction of the nusw flag in GEPNoWrapFlags, it should be
safe to weaken the check in LoopAccessAnalysis to just check the nusw
flag on the GEP, instead of inbounds.
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopAccessAnalysis.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index 0d2ee6f..6f00d50 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -1407,9 +1407,9 @@ static bool isNoWrapAddRec(Value *Ptr, const SCEVAddRecExpr *AR, // Look through the potentially overflowing instruction to try to prove // non-wrapping for the *specific* value of Ptr. - // The arithmetic implied by an inbounds GEP can't overflow. + // The arithmetic implied by an nusw GEP can't overflow. const auto *GEP = dyn_cast<GetElementPtrInst>(Ptr); - if (!GEP || !GEP->isInBounds()) + if (!GEP || !GEP->hasNoUnsignedSignedWrap()) return false; // Make sure there is only one non-const index and analyze that. @@ -1511,12 +1511,12 @@ llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, Value *Ptr, if (isNoWrapAddRec(Ptr, AR, PSE, Lp)) return Stride; - // An inbounds getelementptr that is a AddRec with a unit stride + // An nusw getelementptr that is a AddRec with a unit stride // cannot wrap per definition. If it did, the result would be poison // and any memory access dependent on it would be immediate UB // when executed. if (auto *GEP = dyn_cast<GetElementPtrInst>(Ptr); - GEP && GEP->isInBounds() && (Stride == 1 || Stride == -1)) + GEP && GEP->hasNoUnsignedSignedWrap() && (Stride == 1 || Stride == -1)) return Stride; // If the null pointer is undefined, then a access sequence which would |