<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 17, 2014 at 3:00 AM, Ankur Garg <span dir="ltr"><<a href="mailto:ankur29.garg@samsung.com" target="_blank">ankur29.garg@samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi majnemer, dexonsmith, suyog,<br>
<br>
Hi,<br>
The following patch implements the optimization for the instructions of the type:<br>
icmp eq/ne (shl Const2, A), Const1<br>
<br>
Such instructions can be converted to:<br>
icmp eq/ne A, (TrailingZeros(Const1) - TrailingZeros(Const2))<br></blockquote><div><br></div><div>What?</div><div><br></div><div>(1 << A) == 0b1100</div><div>is equivalent to</div><div>A == 2</div><div>?</div><div><br></div><div>Notice that the produced expression in the proposed optimization is invariant under the following transformation of the constants: changing any bit above the least significant 1. However, the recognized expression is not invariant under that change.</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
This handles only the equality operators for now. Other operators need to be handled.<br>
<br>
This patch is related to the <a href="http://reviews.llvm.org/D4068" target="_blank">http://reviews.llvm.org/D4068</a>. The D4068 implements this optimization for ashr/lshr operators. The following patch implements the optimization for shl operator.<br>
<br>
Please help in reviewing it.<br>
<br>
Thanks.<br>
Ankur<br>
<br>
<a href="http://reviews.llvm.org/D5839" target="_blank">http://reviews.llvm.org/D5839</a><br>
<br>
Files:<br>
  lib/Transforms/InstCombine/InstCombine.h<br>
  lib/Transforms/InstCombine/InstCombineCompares.cpp<br>
  test/Transforms/InstCombine/icmp.ll<br>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div>