From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 66153 invoked by alias); 11 Jun 2015 20:09:27 -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 65596 invoked by uid 89); 11 Jun 2015 20:09:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mail2-relais-roc.national.inria.fr Received: from mail2-relais-roc.national.inria.fr (HELO mail2-relais-roc.national.inria.fr) (192.134.164.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 11 Jun 2015 20:09:25 +0000 Received: from ip-0.net-81-220-131.standre.rev.numericable.fr (HELO laptop-mg.local) ([81.220.131.0]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 Jun 2015 22:09:22 +0200 Date: Thu, 11 Jun 2015 20:12:00 -0000 From: Marc Glisse To: Marek Polacek cc: Jakub Jelinek , GCC Patches , Richard Biener Subject: Re: match.pd: Optimize (x & y) ^ (x | y) In-Reply-To: <20150611120246.GZ2756@redhat.com> Message-ID: References: <20150611110432.GY2756@redhat.com> <20150611110905.GW10247@tucnak.redhat.com> <20150611120246.GZ2756@redhat.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-7; format=flowed Content-Transfer-Encoding: 8BIT X-SW-Source: 2015-06/txt/msg00878.txt.bz2 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. -- Marc Glisse