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

Daniel Berlin dberlin at dberlin.org
Fri Aug 22 14:06:14 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)
>
> ... 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?
>
>
Bringing this up, so far the answers to "why do we keep adding transforms
here" has been "to improve matching capabilities" (which is a result, not
an objective).  I'd really love it if someone could step back and present a
real design (Defining what canonical forms should instcombine expect as
input or output) rather than add a ton of possibly used/not used transforms
that may or may not transform things back and forth.



> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140822/292e24a8/attachment.html>


More information about the llvm-commits mailing list