[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 Jul 31 10:14:47 PDT 2025


================
@@ -594,14 +594,15 @@ for.end12:                                        ; preds = %for.inc10, %entry
 }
 
 
+; FIXME? It seems that we cannot prove that %N is non-negative...
 define void @nonnegative(ptr nocapture %A, i32 %N) {
 ; CHECK-LABEL: 'nonnegative'
 ; CHECK-NEXT:  Src: store i32 1, ptr %arrayidx, align 4 --> Dst: store i32 1, ptr %arrayidx, align 4
-; CHECK-NEXT:    da analyze - none!
+; CHECK-NEXT:    da analyze - output [* *]!
 ; CHECK-NEXT:  Src: store i32 1, ptr %arrayidx, align 4 --> Dst: store i32 2, ptr %arrayidx, align 4
-; CHECK-NEXT:    da analyze - consistent output [0 0|<]!
+; CHECK-NEXT:    da analyze - output [* *|<]!
 ; CHECK-NEXT:  Src: store i32 2, ptr %arrayidx, align 4 --> Dst: store i32 2, ptr %arrayidx, align 4
-; CHECK-NEXT:    da analyze - none!
+; CHECK-NEXT:    da analyze - output [* *]!
----------------
kasuga-fj wrote:

So, what happens when `%N` is `INT32_MIN`? When `%h.045` is 0, `%mul` is also 0, and `%add` has the same value as `%i.043`. When `%h.045` is 2, `%mul` is `2 * INT32_MIN`, which is also 0, I think. Therefore, if everything so far is correct, there should be dependencies between all pairs of the stores. But in this specific case, it appears that `inbounds` (or more precisely, `nusw`) guarantees that such cases wouldn't happen, though I'm not confident.

> %N can be larger than INT32_MAX which woud indeed be negative in a signed interpretation. But do we want to only consider signed loop indiction variables?

Sorry, I didn't quite understand. Do you mean it's sufficient to check that `isKnownLessThan` holds for either the signed or unsigned interpretation?

https://github.com/llvm/llvm-project/pull/151326


More information about the llvm-commits mailing list