This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: match.pd: Optimize (x & y) ^ (x | y)
- From: Richard Biener <rguenther at suse dot de>
- To: Marc Glisse <marc dot glisse at inria dot fr>,Marek Polacek <polacek at redhat dot com>
- Cc: Jakub Jelinek <jakub at redhat dot com>,GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 12 Jun 2015 07:50:05 +0200
- Subject: Re: match.pd: Optimize (x & y) ^ (x | y)
- Authentication-results: sourceware.org; auth=none
- References: <20150611110432 dot GY2756 at redhat dot com> <20150611110905 dot GW10247 at tucnak dot redhat dot com> <20150611120246 dot GZ2756 at redhat dot com> <alpine dot DEB dot 2 dot 20 dot 1506112127430 dot 1589 at laptop-mg dot saclay dot inria dot fr>
On June 11, 2015 10:09:11 PM GMT+02:00, Marc Glisse <marc.glisse@inria.fr> wrote:
>On Thu, 11 Jun 2015, Marek Polacek wrote:
>
>> On Thu, Jun 11, 2015 at 01:09:05PM +0200, Jakub Jelinek wrote:
>>> What about some nop type conversions in between?
>>> int
>>> fn1 (unsigned int x, unsigned int y)
>>> {
>>> int a = x;
>>> int b = y;
>>> unsigned int c = x & y;
>>> int d = a | b;
>>> return (int) (c ^ d);
>>> }
>>> ? Also wonder, if some testcases for match.pd shouldn't be
>>
>> It doesn't work then. Adding some convert?s into the pattern didn't
>help
>> either.
>
>Not judging at all whether it is desirable or not, but you might have
>hit
>the issue that when you want several convert?, you need to use the
>spelling convert1?, convert2?, and it stops there, while here you would
>
>probably want at least 4 (maybe 6?) for this case. You might be able to
>
>work around it with a user-defined predicate, but I keep getting errors
>
>like
>generic-match.c:6655:16: error: redeclaration of âtree_node* o20_pops
>[2]â
>
>If you want to reproduce the error (this is probably not good as is, it
>is
>only provided as a reproducer)
>
>(match (nopand @0 @1)
> (bit_and (convert1? @0) (convert2? @1))
> (if (tree_nop_conversion_p (type, TREE_TYPE (@0))
> && tree_nop_conversion_p (type, TREE_TYPE (@1)))))
>(match (nopior @0 @1)
> (bit_ior (convert1? @0) (convert2? @1))
> (if (tree_nop_conversion_p (type, TREE_TYPE (@0))
> && tree_nop_conversion_p (type, TREE_TYPE (@1)))))
>(simplify
> (bit_xor:c (convert1? (nopand@2 @0 @1))
> (convert2? (nopior@3 @0 @1)))
> (if (tree_nop_conversion_p (type, TREE_TYPE (@2))
> && tree_nop_conversion_p (type, TREE_TYPE (@3)))
> (bit_xor (convert @0) (convert @1))))
>
>
>fold-const.c traditionally avoided the combinatorial explosion by using
>
>strip_nops.
Yeah. We can probably special case conditional conversions in code generation instead of lowering it. And then go the full way and special case nop conversions so you can avoid writing the predicate as well.
Richard.