[llvm-commits] patch: go crazy, compute bits for an entire add instruction

Nick Lewycky nicholas at mxc.ca
Tue Jul 5 23:26:38 PDT 2011


This is a patch to ComputeMaskedBits primarily, though it's hard to 
observe the effect in a small testcase without also adding more smarts 
someplace else, which this patch does for instsimplify.

When faced with an add instruction, ComputeMaskedBits will look at the 
leading bits and the trailing bits to attempt to establish a pattern -- 
and it does a decent job. However, there may be bits we could calculate 
in the middle, which we currently don't. Go wild, try to compute every 
bit in an add.

This requires a new loop that is O(n) in the number of bits, which I 
think is sensible enough given that most values will be either 32 or 64 
bits, making this effectively a constant-time operation.

Please review!

If this patch is okay, I'm going to do it for sub as well obviously, but 
eventually for multiply. Currently if we transform some things to mul 
(using mul as a bit-spreading operation, basically) we lose optimization 
power because we can no longer analyze it as well as the equivalent 
series of shifts with add's/or's.

Nick
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compute-add-bits.patch
Type: text/x-patch
Size: 7495 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110705/6432ba9c/attachment.bin>


More information about the llvm-commits mailing list