[llvm-commits] [PATCH] Implement a few missing InstCombine/InstSimplify optimizations

David Majnemer david.majnemer at gmail.com
Mon May 30 20:35:38 PDT 2011


This patch implements a few of the optimizations mentioned in
http://www.nondot.org/sabre/LLVMNotes/InstCombine.txt

specifically:
if ((x & C) == 0) x |= C	becomes		x |= C
if ((x & C) == 0) x &= ~C	becomes		nothing
if (((1 << which_alternative) & 0x7)) becomes if (which_alternative < 3)
if (!((1 << which_alternative) & 0x3)) becomes if (which_alternative >= 2)

The patch also implements slightly more powerful variations of the
first two, C need not be a constant.

For those still using that file, note that the array indexing example
seems to be optimized out.

I have included several tests that verify that the transform is coming
into effect, they seem to be comprehensive enough.

If I have implemented something wrong/tested something wrong/broken
something, I'll fix it ASAP

One last thing, I believe that there were some redundant hasOneUse()
calls in InstCombineCompares.cpp, I removed the ones that were nearby.

-- 
David Majnemer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: instcombine.patch
Type: application/octet-stream
Size: 5715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110530/5a4fca12/attachment.obj>


More information about the llvm-commits mailing list