<div dir="ltr">On Fri, Sep 20, 2013 at 7:38 AM, Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@googlemail.com" target="_blank">benny.kra@googlemail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: d0k<br>
Date: Fri Sep 20 09:38:44 2013<br>
New Revision: 191090<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=191090&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=191090&view=rev</a><br>
Log:<br>
InstCombine: Canonicalize (gep i8* X, -(ptrtoint Y)) to (sub (ptrtoint X), (ptrtoint Y))<br>
<br>
The GEP pattern is what SCEV expander emits for "ugly geps". The latter is what<br>
you get for pointer subtraction in C code. The rest of instcombine already<br>
knows how to deal with that so just canonicalize on that.<br>
<br><br></blockquote><div><br></div><div>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.)<br>
<br></div><div>-Eli<br></div></div></div></div>