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

Ehsan Amiri via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 1 06:36:20 PST 2025


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

----------------
amehsan wrote:

> @amehsan Even if (there is some discussion about allocation larger than half the virtual address space in because `ptrdiff_t` would overflow, but this a limitation for the programming language C, not LLVM-IR, see https://lists.llvm.org/pipermail/llvm-dev/2017-November/118901.html), there are machines with 128 bit addresses as well. The loop variable could also be 32 bits, and so far we haven't even talked about force-promoting all variables to match the virtual address space.
> 
> [except](https://discourse.llvm.org/t/rfc-a-new-pass-as-an-alternative-to-dependenceanalysis/88403/4)

if we have `128` bit addresses then we will have `128` bit pointers and offset. You cannot use a 64 bit example to claim something about 32 bit or 128 bit address spaces. The proof is not about a specific address size. The limitation of allocated object size is in LLVM IR today and it is independent of a specific size for index size.
https://llvm.org/docs/LangRef.html#allocated-objects
Also limitation on the maximum object size has nothing to do with gep being inbounds or not.


Anyways, as I mentioned in my comment above, the entire discussion yesterday is based on a misunderstanding. Please read the proof. If we are using `nsw` to prove monotonicity all numbers must be interpreted as signed. Also keep in mind we start from two montonic subscript that are executed.

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


More information about the llvm-commits mailing list