[llvm-commits] [PATCH] Simplify negated bit test
David Majnemer
david.majnemer at gmail.com
Sat Dec 8 15:53:16 PST 2012
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/b3ca4d46/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bit_test.patch
Type: application/octet-stream
Size: 1511 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121208/b3ca4d46/attachment.obj>
More information about the llvm-commits
mailing list