[PATCH] InstCombine ((x | ~y) ^ (~x ^ y)) to (x & ~y)

David Majnemer david.majnemer at gmail.com
Fri Aug 22 12:25:28 PDT 2014


On Fri, Aug 22, 2014 at 12:11 PM, Richard Smith <richard at metafoo.co.uk>
wrote:

> On Fri, Aug 22, 2014 at 11:14 AM, David Majnemer <david.majnemer at gmail.com
> > wrote:
>
>> This can be generalized:
>>
>> `(X | (Y ^ Z)) ^ ((X ^ Z) ^ Y)` -> `X & (Y ^ Z)`
>
>
> Is matching that really the right approach? I would (perhaps naively)
> think we should instead CSE that to
>
>   (X | A) ^ X ^ A   (with A = Y ^ Z)
>

We don't manage to CSE the Y ^ Z op, which is why I proposed the more
general form.


>
> ... and we should be able to perform these more primitive transformations:
>
>  (X | A) ^ X -> ~X & A
>  (~X & A) ^ A -> X & A
>
> ... which together reduce your expression to X & (Y ^ Z). Perhaps one of
> those takes us further from canonical form, though. What are the rules for
> canonicity here?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140822/b6eb4317/attachment.html>


More information about the llvm-commits mailing list