From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 88943 invoked by alias); 12 Jun 2015 09:03:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 88926 invoked by uid 89); 12 Jun 2015 09:03:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 12 Jun 2015 09:03:41 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 286D8C6A1D; Fri, 12 Jun 2015 09:03:40 +0000 (UTC) Received: from redhat.com (ovpn-204-74.brq.redhat.com [10.40.204.74]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5C924GF029064 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Fri, 12 Jun 2015 05:03:38 -0400 Date: Fri, 12 Jun 2015 09:04:00 -0000 From: Marek Polacek To: Marc Glisse Cc: Richard Biener , Jakub Jelinek , GCC Patches Subject: Re: match.pd: Optimize (x & y) ^ (x | y) Message-ID: <20150612090204.GF2756@redhat.com> References: <20150611110432.GY2756@redhat.com> <20150611110905.GW10247@tucnak.redhat.com> <20150611120246.GZ2756@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-06/txt/msg00906.txt.bz2 On Fri, Jun 12, 2015 at 08:44:45AM +0200, Marc Glisse wrote: > 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]’ I remember trying convert1?, convert2?, and so on. But I gave up soon. > >>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. Yeah, imagine if we'd have to change every pattern like that :-(. Marek