[PATCH] D93820: [InstSimplify] Don't fold gep p, -p to null

Nuno Lopes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 10 07:52:59 PST 2021


nlopes added a comment.

In D93820#2489066 <https://reviews.llvm.org/D93820#2489066>, @nikic wrote:

> Based on what @RalfJung mentioned on zulip, the question of whether the transform is legal for inbounds comes down to the particular choice of inbounds semantics. I was using the semantics specified in LangRef, which make the optimization illegal, while @nlopes used the semantics from https://people.mpi-sws.org/~jung/twinsem/twinsem.pdf (or something similar), which makes it legal. The relevant difference to the LangRef semantics (if we stick to the gep-inbounds-logical case) would be:
>
>   - The base pointer has an in bounds address of an allocated object [...]
>   + The base pointer has an in bounds address of the allocated object it is based on [...]
>
> In any case, regardless of whether this is legal for the inbounds case, I think everyone agrees it's not legal for the non-inbounds case (and not legal for the non-null case regardless of inbounds). Is that enough to move forward here, or do you want me to thread inbounds information through SimplifyGEPInst and retain this optimization for the inbounds case?

LGTM, it's a step in the right direction (removing wrong optimizations)!


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

https://reviews.llvm.org/D93820



More information about the llvm-commits mailing list