public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marc Glisse <marc.glisse@inria.fr>
To: Richard Biener <rguenther@suse.de>
Cc: Marek Polacek <polacek@redhat.com>,
	Jakub Jelinek <jakub@redhat.com>,
	    GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: match.pd: Optimize (x & y) ^ (x | y)
Date: Fri, 12 Jun 2015 07:22:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.20.1506120834490.1593@laptop-mg.saclay.inria.fr> (raw)
In-Reply-To: <F754CE2F-C241-4380-996E-93B9EA4A03F0@suse.de>

On Fri, 12 Jun 2015, Richard Biener wrote:

>> 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.

Without special casing, I currently have:

(match (nopcvt @0)
  (convert? @0)
  (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))))
(simplify
  (bit_xor:c (convert1? (bit_and@2 (nopcvt @0) (nopcvt @1)))
             (convert2? (bit_ior:c (nopcvt @0) (nopcvt @1))))
  (if (tree_nop_conversion_p (type, TREE_TYPE (@2)))
   (bit_xor (convert @0) (convert @1))))

which simplifies Jakub's testcase without exploding the size of *-match.c, 
but it is still not very satisfying.

-- 
Marc Glisse

  reply	other threads:[~2015-06-12  6:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-11 11:08 Marek Polacek
2015-06-11 11:09 ` Richard Biener
2015-06-11 12:14   ` Marek Polacek
2015-06-11 11:18 ` Jakub Jelinek
2015-06-11 12:07   ` Marek Polacek
2015-06-11 20:12     ` Marc Glisse
2015-06-12  5:59       ` Richard Biener
2015-06-12  7:22         ` Marc Glisse [this message]
2015-06-12  9:04           ` Marek Polacek
2015-06-13 10:46             ` Marc Glisse
2015-06-16 13:47               ` Richard Biener
2015-06-11 15:26 ` Marc Glisse
2015-06-11 16:12   ` Richard Biener
2015-06-11 16:14   ` Marek Polacek
2015-06-11 16:34     ` Marc Glisse
2015-06-11 16:58       ` Marek Polacek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1506120834490.1593@laptop-mg.saclay.inria.fr \
    --to=marc.glisse@inria.fr \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=polacek@redhat.com \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).