[llvm] LAA: be less conservative in isNoWrap (PR #112553)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 20 21:58:05 PDT 2024
================
@@ -825,14 +825,13 @@ static bool hasComputableBounds(PredicatedScalarEvolution &PSE, Value *Ptr,
/// Check whether a pointer address cannot wrap.
static bool isNoWrap(PredicatedScalarEvolution &PSE,
- const DenseMap<Value *, const SCEV *> &Strides, Value *Ptr, Type *AccessTy,
- Loop *L) {
+ const DenseMap<Value *, const SCEV *> &Strides, Value *Ptr,
+ Type *AccessTy, Loop *L, bool Assume) {
const SCEV *PtrScev = PSE.getSCEV(Ptr);
if (PSE.getSE()->isLoopInvariant(PtrScev, L))
return true;
- int64_t Stride = getPtrStride(PSE, AccessTy, Ptr, L, Strides).value_or(0);
- return Stride == 1 ||
+ return getPtrStride(PSE, AccessTy, Ptr, L, Strides, Assume).has_value() ||
----------------
fhahn wrote:
> getPtrStride returns Strides == 1 or -1, except when isNoWrapAddRec or Assume are true; we can include the case of -1 Stride, and when isNoWrapAddRec is true.
I am not sure this is true for all cases; I think unless `ShouldCheckWrap` is true, we may return strides > 1 or < -1 even if they may wrap; we should probably pass `ShouldCheckWrap = true` (for most parts, checks in other places should catch issues, but better be safe here)
https://github.com/llvm/llvm-project/pull/112553
More information about the llvm-commits
mailing list