[PATCH] D11051: Extend LICM to hoist loop invariant GEP out

Nuno Lopes nunoplopes at sapo.pt
Wed Jul 15 02:39:03 PDT 2015


nlopes added a comment.

In http://reviews.llvm.org/D11051#204371, @hfinkel wrote:

> In http://reviews.llvm.org/D11051#204369, @atrick wrote:
>
> > I don't think GEP reassociation should be done as a canonical InstCombine for two reasons
> >  (1) the inbounds property would need to be dropped
>
>
> Can you even do this if you don't have inbounds GEPs? Nuno, do you have an opinion about this?


I think Andy is right.
If you don't have the inbounds tag, then you can safely perform this transformation, since LLVM's semantics guarantee that it will compute the overflowing value correctly. The implementation of the lowering and constant folding of GEPs in LLVM matches the semantics.
If you have the inbounds tag, then the transformation can still be performed, although inbounds has to dropped in most cases, since otherwise we would need to prove that the intermediate results don't overflow.

This problem is similar to reassociation of integer expressions. It's always safe when there are no nsw/nuw, but if there are, they usually have to be dropped.

Nuno


Repository:
  rL LLVM

http://reviews.llvm.org/D11051







More information about the llvm-commits mailing list