[PATCH] Combine bit test + conditional or into simple math

Nick Lewycky nicholas at mxc.ca
Sun Apr 14 20:49:34 PDT 2013


On 04/14/2013 07:02 PM, David Majnemer wrote:
> This patch simplifies constructs like:
>
> (select (icmp eq (and X, C1), 0), Y, (or Y, C2))
>
> into:
>
> (or (shl (and X, C1), C3), y)
>
> where C3 = Log(C2) - Log(C1)

... and where C1 and C2 are single bits. :)

> It includes quite a number of test cases and successfully runs 'make
> check' cleanly against r179493.

Please add asserts that C1 and C2 aren't zero (it would miscompile those 
cases). Looks good!

Nick



More information about the llvm-commits mailing list