[LLVMdev] XOR Optimization

Daniel Nicácio dnicacios at gmail.com
Thu Jul 28 13:58:55 PDT 2011


Hey guys,

I still think there is no optimization doing what I want. When the loop is
unrolled 32 times, llvm is able to identify that the loop is working on a
whole word, it finds some constants and propagate them, resulting in the
folded XOR instruction. However, when the loop operates on some bits of the
word, llvm is still not able to fold those XOR, even when the operated bits
does not overlap each other.

Therefore, I am implementing the following optimization for folding XOR
instructions working on bits (it still must be extended to OR and AND
instructions). Any comments and critics are appreciated.

Basically, I try to identify a chain of XOR instructions and fold it. The
below image illustrate this:

[image: XORChain.png]

In order to do that I am adding an additional function call to "visitXor()"
in Instruction Combining.

My Optimization function is attached as a patch file. (the diff was made
using the 2.9 release version of llvm).

Thanks

Daniel Nicacio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110728/a5bc09cf/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: XORChain.png
Type: image/png
Size: 59953 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110728/a5bc09cf/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: InstCombineAndOrXor.diff
Type: application/octet-stream
Size: 635 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110728/a5bc09cf/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: InstructionCombining.diff
Type: application/octet-stream
Size: 7068 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110728/a5bc09cf/attachment-0001.obj>


More information about the llvm-dev mailing list