[llvm] [DependenceAnalysis] Prevent non-AddRec expressions from reaching testSIV (PR #154980)

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 10 10:08:55 PDT 2025


https://github.com/kasuga-fj commented:

I think #148435 should be resolved in a more "robust" way. Regarding this specific case, the memory access is currently delinearized as:

```
[(zext i1 {false,+,true}<%loop> to i64)][{0,+,1}<nuw><nsw><%loop>]
```

Also, since the backedge-taken count is 4, the AddRec `{false,+,true}<%loop>` definitely wraps. So, some validation, such as `checkSubscript`, should detect it at an earlier stage and the analysis should bail out. Unfortunately, DA doesn't have any validation step to ensure that the AddRec doesn't wrap, so I think such a "robust" solution would require multiple steps. This is why I have not addressed only this specific case.

If you really want to fix only this case, I'd suggest to fix `removeMatchingExtensions` so that it doesn't purge `zext`. Apart from wrapping checks, I think it's also incorrect to eliminate `zext` without proving that its operand is non-negative. I didn't try myself, but I believe that would also fix this specific case.

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


More information about the llvm-commits mailing list