hi Jud,<br><br>thanks very much for this. i completely forgot the overflow stuff ... so turn the compare instruction to subtract is a bad idea.<br><br>--best regards<br>ether<br><br><div class="gmail_quote">On Sun, Apr 18, 2010 at 2:35 AM, Jud Leonard <span dir="ltr"><<a href="mailto:jud.leonard@gmail.com">jud.leonard@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Be careful about oversimplifying signed integer comparisons -- integer arithmetic can easily overflow, so you cannot transform A > B to A - B > 0. The compare instructions in most processors do not simply subtract and test the most significant bit; they compute what the sign of the difference would be in extended precision.<br>
<br>
On Apr 17, 2010, at 1:00 PM, <a href="mailto:llvmdev-request@cs.uiuc.edu">llvmdev-request@cs.uiuc.edu</a> wrote:<br>
<br>
> Message: 13<br>
> Date: Sat, 17 Apr 2010 22:17:54 +0800<br>
> From: ether zhhb <<a href="mailto:etherzhhb@gmail.com">etherzhhb@gmail.com</a>><br>
> Subject: [LLVMdev] SCEV expression for ICmpInst<br>
> To: LLVM Developers Mailing List <<a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a>><br>
> Message-ID:<br>
> <<a href="mailto:s2w5f72161f1004170717re1325ffdr53b6b7308215b3fa@mail.gmail.com">s2w5f72161f1004170717re1325ffdr53b6b7308215b3fa@mail.gmail.com</a>><br>
> Content-Type: text/plain; charset="iso-8859-1"<br>
<div class="im">><br>
> Hi,<br>
><br>
> i am playing the ScalarEvolution these days. i found the the ScalarEvolution<br>
> will simply return a SCEVUnknow for a ICmpInst, so i think maybe great to<br>
> add a new kind of SCEV to the ScalarEvolution framework.<br>
><br>
><br>
> for example, if i run ScalarEvolution on the bc file generate from the<br>
> following C source file:<br>
><br>
> int f(int a, int b, int c, int d) {<br>
> return (2 * a + 5 * c + 2) > (4 * d - 3*b +3);<br>
> }<br>
><br>
> i will get a SCEVUnknow for the compare instruction, but it's great if i<br>
> could get something like 2 * a + 5 * c - 4 * d - 3*b - 1 > 0 for the compare<br>
> instruction :)<br>
><br>
><br>
</div><div class="im">> In my opinion, we need only 3 kind of SCEV expression to express the<br>
> ICmpInst: SCEVEqCond for equal condition, SCEVNeCond for not equal<br>
> condition and SCEVGtCond for others. Because we can always transform A < B<br>
> to B > A, and transform A >= B to A > B - 1 (or A + 1> B), and A <= B to A <<br>
> B + 1 (or A - 1 < B). Furthermore, we can transform A > B to A - B > 0 and A<br>
> != B to A - B != 0, so the SCEV for conditions will be very simple.<br>
><br>
> As there are already some functions such as "isKnownNonZero" in<br>
> ScalarEvolution, so we can compute these condition easily.<br>
><br>
> With the SCEV for conditions, we may write more meaningful code:<br>
><br>
> SCEVEQCond *S = SE.getCondition(some_icmp_instruction);<br>
><br>
> if (some_cond.isAlwaysTrue(SE))<br>
> ... do some thing ...<br>
> else<br>
> ... do some others thing ...<br>
><br>
> Dose this make sense? or i just make things unnecessarily complex?<br>
><br>
> any comment is appreciated.<br>
><br>
> --best regards<br>
> ether<br>
<br>
<br>
</div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br>