<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 28, 2014 at 2:44 PM, Nuno Lopes <span dir="ltr"><<a href="mailto:nunoplopes@sapo.pt" target="_blank">nunoplopes@sapo.pt</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
On 27 August 2014 06:16, David Majnemer <<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Author: majnemer<br>
Date: Wed Aug 27 00:16:04 2014<br>
New Revision: 216523<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=216523&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=216523&view=rev</a><br>
Log:<br>
InstCombine: Optimize GEP's involving ptrtoint better<br>
</blockquote>
<br>
<br>
Hi David,<br>
<br>
I've done a bisect and this commit broke out test-suite bot:<br>
<br>
<a href="http://lab.llvm.org:8011/builders/clang-native-arm-lnt/builds/8059" target="_blank">http://lab.llvm.org:8011/<u></u>builders/clang-native-arm-lnt/<u></u>builds/8059</a><br>
<br>
The big problem is that the test "result" is just an MD5. :(<br>
<br>
I'm investigating.<br>
<br>
cheers,<br>
--renato<br>
</blockquote>
<br>
<br></div></div>
I tried to specify this transformation in Alive. The transformation supports more complex cases, but I get a failure even for the simplest case:<br>
<br>
$ ./alive.py < gep.opt<br>
Precondition: true<br>
%0 = ptrtoint i1* %Y<br>
%1 = sub i64 0, %0<br>
%r = getelementptr i1* %X, %1<br>
=><br>
%0 = ptrtoint i1* %Y<br>
%2 = ptrtoint * %X to i64<br>
%3 = sub %2, %0<br>
%r = inttoptr %3 to *<br>
<br>
<br>
ERROR: Mismatch in values of i1* %r<br>
<br>
Example:<br>
%Y i1* = 18446744073709551615 (0xffffffffffffffffL)<br>
%0 i64 = 18446744073709551615 (0xffffffffffffffffL)<br>
%1 i64 = 1 (0x1)<br>
%X i1* = 0 (0x0)<br>
%2 i64 = 0 (0x0)<br>
%3 i64 = 1 (0x1)<br>
Source value: 64 (0x40)<br>
Target value: 1 (0x1)<br>
<br>
Note that the counterexample is assuming pointer-size=8 bits.<br>
Let me know if I can help with debugging the transformation. (I may be missing some precondition; I just quickly glanced through your patch)</blockquote><div><br></div><div><br></div><div>Hi Nuno,</div><div><br></div><div>
I believe Alive isn't ready for getelementptr:</div><div><br></div><div>----------------------------------------<br></div><div><div>Optimization: 1</div><div>Precondition: true</div><div>%gep = getelementptr i8* %A, i64 1</div>
<div>%ret = ptrtoint i8* %gep to i64</div><div> =></div><div>%ptrtoint = ptrtoint i8* %A to i64</div><div>%ret = add i64 %ptrtoint, 1</div><div><br></div><div><br></div><div>ERROR: Mismatch in values of i64 %ret</div>
<div><br></div><div>Example:</div><div>%A i8* = 0 (0x0)</div><div>%gep i8* = 64 (0x40)</div><div>%ptrtoint i64 = 0 (0x0)</div><div>Source value: 64 (0x40)</div><div>Target value: 1 (0x1)</div></div><div><br></div><div>%gep should not be 64.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span><font color="#888888"><br>
<br>
Nuno <br>
</font></span></blockquote></div><br></div></div>