[llvm-commits] [PATCH] Simplify negated bit test

David Majnemer david.majnemer at gmail.com
Sat Dec 8 16:12:02 PST 2012


Updated patch attached. No functional change, just nicer whitespace.


On Sat, Dec 8, 2012 at 3:53 PM, David Majnemer <david.majnemer at gmail.com>wrote:

> The attached patched takes a sequence like:
>  %neg = xor i32 %A, -1
>  %shl = shl i32 1, %B
>  %and = and i32 %shl, %neg
>  %cmp = icmp ne i32 %and, 0
>
> and turns it into:
>  %shl = shl i32 1, %B
>  %and = and i32 %shl, %A
>  %cmp = icmp eq i32 %and, 0
>
> The patch includes a test case that exercises this transform.
>
> Examples of frontend code that could generate sequence 1 is:
>
> bool fun1(unsigned A, unsigned B) { return ~A & (1 << B); }
>
> An example of sequence 2 is:
> bool fun2(unsigned A, unsigned B) { return !(A & (1 << B)); }
>
> With this patch, they would have the same IR.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121208/512be3e0/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bit_test.patch
Type: application/octet-stream
Size: 1463 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121208/512be3e0/attachment.obj>


More information about the llvm-commits mailing list