[PATCH] D90637: [ValueTracking] Inbounds does not imply nsw

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 13:38:19 PST 2020


nikic added a comment.

In D90637#2369434 <https://reviews.llvm.org/D90637#2369434>, @lebedev.ri wrote:

> Please can you explain what problem is this solving?
> Either this is missing words "however if we'd add all offsets together, and then add the final offset to the base pointer, that addition is NSW",
> or this is inconsistent with langref/D68342 <https://reviews.llvm.org/D68342>.

Other way around. The offset multiplications/additions are all nsw, but the final addition to the base is not. If `%base = 0x7fffffff` and `%offset = 1`, then `gep inbounds %base, %offset` is perfectly legal (assuming an allocated object at that location), despite wrapping the signed space. In terms of wrapping behavior of the base addition, "inbounds" implies "nusw" which (in the general case) implies neither nsw nor nuw.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90637



More information about the llvm-commits mailing list