This is the mail archive of the gcc-patches@gcc.gnu.org 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 Thu, 11 Jun 2015, Marek Polacek wrote:

+  (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).

I don't have a strong preference here but we surely use single_use
in match.pd elsewhere.

The criterion for single_use up to now has been whether we may end up with more operations after the transformation than before. Take:
(x & ~m) | (y & m) -> ((x ^ y) & m) ^ x

If (x & ~m) and (y & m) have other uses, we are going to compute them anyway, and the original is essentially a single bit_ior operation. After the transformation, we have 2 more operations. That's worse than we started with, so we don't do it.

--
Marc Glisse


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