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

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 27 16:41:55 PST 2025


================

----------------
kasuga-fj wrote:

> The link is to the proof for Symbolic RDIV. Correct link to the proof for strong SIV is this: [#168823 (comment)](https://github.com/llvm/llvm-project/issues/168823#issuecomment-3582394502) And I believe you talk about case 2, which is the test that you are talking about.

Similar approach can be applied to Symbolic RDIV as well. So both https://github.com/llvm/llvm-project/pull/162281#issuecomment-3564376265 and Case 2 in https://github.com/llvm/llvm-project/issues/168823#issuecomment-3582394502 are unnecessary.

> I believe you rely on the SCEV's conservative decision to drop nsw flags for instructions that are under a condition. That is a deliberately conservative choice on SCEV's part, and I don't think we should rely on that. In future SCEV may change or be extended or modified otherwise. There is no reason to create potential future limitations.

It is guaranteed that the nowrap property holds within the defining scope of the SCEV. This means that the nowrap property of an addrec applies to all executed iterations of the loop. It is therefore reasonable to rely on this contract. I'd recommend to read [this article](https://www.npopov.com/2023/10/03/LLVM-Scalar-evolution.html#nowrap-flags) and https://github.com/llvm/llvm-project/issues/159846#issuecomment-3380981125.



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


More information about the llvm-commits mailing list