[llvm] [SCEV] Try to prove no-wrap for AddRecs via BTC. (PR #131538)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 30 04:05:27 PDT 2025


https://github.com/nikic commented:

Looking at the test diffs, it seems like the case where this helps in practice is if we have a -1 max const btc.

I feel like this case should really be handled by something more fundamental. The proveNoWrapViaConstantRanges() logic doesn't catch this because it checks whether adding the step to the range will not overflow -- in this case the range is full, but the code doesn't know that it won't actually wrap. Of course, the code that actually calculated that range (getRangeForAffineAR) *does* know that, but we lose the distinction between a full range because the addrec can hit all values and a full range because the calculation overflowed...

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


More information about the llvm-commits mailing list