This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: match.pd: Optimize (x & y) ^ (x | y)

On June 11, 2015 5:25:30 PM GMT+02:00, Marc Glisse <> wrote:
>On Thu, 11 Jun 2015, Marek Polacek wrote:
>> I have verified this transformation on a toy testcase (tried x and y
>> in the range [-1000,1000]) and it does a correct thing for all
>Note that for pure bitop (only involving &|^), testing the range [0,1]
>> +/* (x & y) ^ (x | y) -> x ^ y */
>> +(simplify
>> + (bit_xor:c (bit_and@2 @0 @1) (bit_ior@3 @0 @1))
>Make either bit_and or bit_ior commutative? Or do we canonicalize in a
>that makes it unnecessary?

Yes, operand canonicalization should make this unnecessary.

>> +  (if (single_use (@2) && single_use (@3))
>> +   (bit_xor @0 @1)))
>I don't think we should use single_use here. The result is never more 
>complicated than the original. Sure, it might increase register
>pressure a 
>bit in some cases, but we have not used that as a criterion for other 
>simplifications in match.pd yet (LLVM does though).

Hmm yes, you are right here.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]