Reply is inline.<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Dec 9, 2012 at 6:57 AM, Jakub Staszak <span dir="ltr"><<a href="mailto:kubastaszak@gmail.com" target="_blank">kubastaszak@gmail.com</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">Hi David,<br>
<br>
In general your patch looks fine for me, but I see some areas for the improvement:<br>
1. Your patch works only one way:<br>
(1 << x)&~y != 0  into (1 << x)&y == 0, however<br>
(1 << x)&~y == 0  into (1 << x)&y != 0 is not supported.<br></blockquote><div><br></div><div>Thanks, I will add this case.</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">

<br>
2. It doesn't have to be 1 which is shifted. It works with any power-of-two value (you can use m_Power2 pattern).<br></blockquote>







<p class="">I was under the impression that m_Power2 does not handle values generated from shl instructions.</p>
<div>Further, it seems that LLVM already turns !!(~A & C) into !(A & C) where C is a constant and a power of 2. Should I add such a transform anyway?</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">

<br>
- Kuba<br>
<div><div class="h5"><br>
On Dec 9, 2012, at 12:53 AM, David Majnemer <<a href="mailto:david.majnemer@gmail.com">david.majnemer@gmail.com</a>> wrote:<br>
<br>
> The attached patched takes a sequence like:<br>
>  %neg = xor i32 %A, -1<br>
>  %shl = shl i32 1, %B<br>
>  %and = and i32 %shl, %neg<br>
>  %cmp = icmp ne i32 %and, 0<br>
><br>
> and turns it into:<br>
>  %shl = shl i32 1, %B<br>
>  %and = and i32 %shl, %A<br>
>  %cmp = icmp eq i32 %and, 0<br>
><br>
> The patch includes a test case that exercises this transform.<br>
><br>
> Examples of frontend code that could generate sequence 1 is:<br>
><br>
> bool fun1(unsigned A, unsigned B) { return ~A & (1 << B); }<br>
><br>
> An example of sequence 2 is:<br>
> bool fun2(unsigned A, unsigned B) { return !(A & (1 << B)); }<br>
><br>
> With this patch, they would have the same IR.<br>
</div></div>> <bit_test.patch>_______________________________________________<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>