[PATCH] D90708: [LangRef] Clarify GEP inbounds wrapping semantics

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 5 02:10:49 PST 2020


nhaehnle added a comment.

This makes sense to me.

> However, I do wonder if we could get away with saying that no allocated object may wrap the signed address space, in which case inbounds would just map cleanly to nsw, which would both allow more optimization and be easier to reason about.

Unfortunately, that wouldn't work for us. We have 32-bit address spaces that are treated as the unsigned range [0, 0xffffffff], and there's no limitation as to where objects can appear in that range.



================
Comment at: llvm/docs/LangRef.rst:9785-9786
+   unsigned address space and remains *in bounds* of the allocated object.
+   As a corollary, if the added offset is non-negative, the addition does not
+   wrap in an unsigned sense (``nuw``).
+*  In cases where the base is a vector of pointers, the ``inbounds`` keyword
----------------
As a second corollary, the addition wraps in an unsigned sense if and only if the added offset is negative?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90708/new/

https://reviews.llvm.org/D90708



More information about the llvm-commits mailing list