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

David Majnemer david.majnemer at gmail.com
Mon Dec 10 13:48:25 PST 2012


This patch has been updated with feedback from Nuno and Jakub. It adds an
additional test case to cover another transformation.


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

> 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/20121210/c9a16882/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bit_test.patch
Type: application/octet-stream
Size: 2646 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121210/c9a16882/attachment.obj>


More information about the llvm-commits mailing list