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

Nick Lewycky nicholas at mxc.ca
Thu Jul 21 01:06:32 PDT 2011


Jay Foad wrote:
>> In general though, will I be
>> allowed to use an O(n) loop in ComputeMaskedBits if needed? I don't think
>> we'll be able to solve multiply without it--though we can try!
>
> I'd be very surprised if you get any real world benefit from trying to
> calculate the middle bits of the result of a multiply. Surely it's
> good enough to calculate just the low bits and the high bits?

No, I do want middle bits, but ...

> Or maybe you do want the middle bits, but only in the special case
> where one operand is a completely known constant. That might be easier
> to solve than the completely general case, but I haven't thought about
> it much.

... all the cases I care about right now have a constant RHS.

Jay, would you be willing to review this updated patch, now for add+sub? 
I think I'd like to do the rest (overflow intrinsics and bswap) next 
before moving on to mul, actually. I have piles of missed optz'ns of due 
to overflow intrinsics that I haven't solved.

In previous review over IRC, Chris complained that the change to 
InstSimplify was unclear and I promised to add comments. I have 
reconsidered, and consider the code clear enough with the same comments 
it had before (but with a bugfix). In particular the 'and' analysis only 
requests masked bits because we knows that if the whole result is 
constant than the result bits not in the mask must be zero, while an 
'or' could be setting all the unknown bits to one, but we still need 
ComputeMaskedBits to tell us what the other bits actually are. In 
addition, I've added four tests, one for each "return" statement in 
InstSimplify (another one of Chris' comments was that one of the returns 
was unreachable).

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


More information about the llvm-commits mailing list