[PATCH] Teach InstCombine to simplify (A & ~B) in icmp

David Majnemer david.majnemer at gmail.com
Fri Apr 12 01:52:41 PDT 2013


The attached patch can transform:

(A & ~B) == 0 --> (A & B) != 0
(A & ~B) != 0 --> (A & B) == 0

if we can prove that A is definitely a power of 2.

Last time I tried this (almost exactly four months ago), self hosted clang
builds failed because of undefined behavior. Somewhere.

I've tested this patch against a checkout that was compiled by a compiler
that was compiled with this patch and it went fine.

Tests that exercise both transforms are included.

-- 
David Majnemer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130412/fb788788/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pow2_and_mask.ll
Type: application/octet-stream
Size: 1932 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130412/fb788788/attachment.obj>


More information about the llvm-commits mailing list