[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
Sun Nov 30 09:43:18 PST 2025


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

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

> In an earlier discussion before, you were not even clear about the concept of UB and I mentioned it right there.

Which one?


> > It looks to me that you still don't understand what `nsw` of addrecs means. `{c,+,a}<nsw>` does NOT say `a*i` doesn't overflow. It only says `(((c + a) + a) + ...)` doesn't overflow.
> 
> When you have enough `a` in that sequence, you will have an overflow. that is the point.

If you want to proof the correctness, you really need to understand the semantics of nowrap properties correctly. Consider the case where `a = 1`, `c = -2^63` and `BTC = 2^64 - 1`. It doesn't cause overflow.

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


More information about the llvm-commits mailing list