[llvm] r191090 - InstCombine: Canonicalize (gep i8* X, -(ptrtoint Y)) to (sub (ptrtoint X), (ptrtoint Y))

Benjamin Kramer benny.kra at gmail.com
Fri Sep 20 12:12:21 PDT 2013


On 20.09.2013, at 20:59, Eli Friedman <eli.friedman at gmail.com> wrote:

> On Fri, Sep 20, 2013 at 7:38 AM, Benjamin Kramer <benny.kra at googlemail.com> wrote:
> Author: d0k
> Date: Fri Sep 20 09:38:44 2013
> New Revision: 191090
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=191090&view=rev
> Log:
> InstCombine: Canonicalize (gep i8* X, -(ptrtoint Y)) to (sub (ptrtoint X), (ptrtoint Y))
> 
> The GEP pattern is what SCEV expander emits for "ugly geps". The latter is what
> you get for pointer subtraction in C code. The rest of instcombine already
> knows how to deal with that so just canonicalize on that.
> 
> 
> 
> Is this really a good idea?  We lose aliasing information from turning the GEP into a sub, and it seems like it could easily trigger on regular C++ code.  (If the only user of the GEP is a ptrtoint, it's a different story, but you're not checking that.)

I was thinking the same first, but does subtracting two pointers and using the result as a pointer really make sense? I can't see how that would be useful. 

- Ben





More information about the llvm-commits mailing list