From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35455 invoked by alias); 30 May 2015 09:57:36 -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 33476 invoked by uid 89); 30 May 2015 09:57:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 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; Sat, 30 May 2015 09:57:34 +0000 Received: from afontenayssb-151-1-46-43.w82-121.abo.wanadoo.fr (HELO laptop-mg.local) ([82.121.95.43]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 30 May 2015 11:57:13 +0200 Date: Sat, 30 May 2015 15:10:00 -0000 From: Marc Glisse Reply-To: gcc-patches@gcc.gnu.org To: Jeff Law cc: gcc-patches Subject: Re: [RFA] Reimplement canonicalization of comparison arguments in match.pd In-Reply-To: <55693F80.9070805@redhat.com> Message-ID: References: <55693F80.9070805@redhat.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-SW-Source: 2015-05/txt/msg02855.txt.bz2 On Fri, 29 May 2015, Jeff Law wrote: > c-common.c::shorten_compare has code to canonicalize the arguments of a > comparison so that the constant is the second argument. This patch removes > the implementation from c-common.c and instead implements it in match.pd. > > Note the match.pd tries to match the prior behavior of shorten_compare, hence > the strange handling of zero. No justification exists AFAIK for that strange > handling in shorten_compare. > > The match.pd pattern is primarily Kai's -- I just took the 4 patterns he > wrote and squashed them into a single pattern to avoid the test duplication. > > The xfailed testcase is only case I saw across my comparison tests where this > change regressed. Basically shorten-compare had something non-canonical when > called. It was able to canonicalize, then optimize the result. I just > wanted a record of that test in the testsuite. Obviously if we hit our goal > of implementing everything from shorten_compare, that test will no longer > need to be xfailed :-) > > Bootstrapped and regression tested on x86-linux-gnu. OK for the trunk? I understand doing it in 2 commits to better see what regresses, but I don't think we should keep the weirdness in match.pd. Does it regress anything if we instead add inside the for loop that follows /* -A CMP -B -> B CMP A. */ (simplify (cmp CONSTANT_CLASS_P@0 @1) (scmp @1 @0)) ? If we want to inhibit in some cases because we fail to fold to a constant, or because COND_EXPR needs 1 != 0 or something, we can always add checks: (simplify (cmp CONSTANT_CLASS_P@0 @1) (if (!zerop (@1)) (scmp @1 @0))) (hmm, I didn't add zerop to tree.[hc] yet) or !CONSTANT_CLASS_P (@1) or whatever is necessary. -- Marc Glisse