[llvm] [DA] Add tests for nsw doesn't hold on entier iteration (PR #162281)

Ehsan Amiri via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 15 17:03:59 PST 2025


amehsan wrote:

> Just an idea at this point: If like what we saw in my analysis for small constants, existence of dependency when `delta != 0` requires some part of computation to overflow, I think we should be able to prove this: Strong SIV will work correctly for monotonic references even under arbitrary control flow.
> 
> I will give this high priority to see if this can be made accurate and proven or not.



The proof seems relatively easy. I will post it later after checking it a bit more. What we need is a relaxed form of monotonicity. It doesn't matter we have `nuw` or `nsw`. As long as all operations used in the subscript calculation have the same no wrap flag, we can prove that `delta != 0` implies independence for strong SIV.  I will move on to the next SIV test to see if this can be applied there as well or not.

Two comments:
1-  We have two problems: control flow and overflow. If there is no overflow, strong SIV is easy. If there is not control flow strong SIV is easy. If we have both, it becomes much more complex.

2- It makes much more sense now that the numbers being signed or unsigned doesn't matter. It really shouldn't.

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


More information about the llvm-commits mailing list