[llvm] [DA] Fix the check between Subscript and Size after delinearization (PR #151326)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 7 04:33:36 PDT 2025
================
@@ -1111,9 +1111,9 @@ bool DependenceInfo::isKnownPredicate(ICmpInst::Predicate Pred, const SCEV *X,
}
}
-/// Compare to see if S is less than Size, using isKnownNegative(S - max(Size, 1))
----------------
kasuga-fj wrote:
Before comparing `Subscript` and `Size`, we check that `Subscript` is non-negative. This function is, as the name suggests, returns true if `Subscript` is less than `Size`. If `Size` being 0 pass implies `0 <= Subscript < 0`. Something seems off.
I think the case where `Size` is 0 is a special one and should be handled more pessimistically. For example, an offset like `i*d0*d1 + j*d1 + k` would be delinearized with Sizes as `[UnknownSize][d0][d1]` and Subscripts as `[i][j][k]`.
If `d1` is 0, the offset calculation yields `k`, regardless of the values of the first two subscripts. However, if the subscripts of `Src` are `[2*i+1][j][k]` and those of `Dst` are `[2*i][j][k]`, then DA would conclude that no dependency exists between them.
https://github.com/llvm/llvm-project/pull/151326
More information about the llvm-commits
mailing list