From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22559 invoked by alias); 2 Aug 2012 13:37:04 -0000 Received: (qmail 22423 invoked by uid 22791); 2 Aug 2012 13:37:03 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-qc0-f175.google.com (HELO mail-qc0-f175.google.com) (209.85.216.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Aug 2012 13:36:48 +0000 Received: by qcad10 with SMTP id d10so5518227qca.20 for ; Thu, 02 Aug 2012 06:36:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.60.24.7 with SMTP id q7mr36698386oef.54.1343914607919; Thu, 02 Aug 2012 06:36:47 -0700 (PDT) Received: by 10.76.90.71 with HTTP; Thu, 2 Aug 2012 06:36:47 -0700 (PDT) In-Reply-To: References: Date: Thu, 02 Aug 2012 13:37:00 -0000 Message-ID: Subject: Re: ORDERED_EXPR in invert_tree_comparison From: Richard Guenther To: Marc Glisse Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes 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 X-SW-Source: 2012-08/txt/msg00098.txt.bz2 On Thu, Aug 2, 2012 at 2:48 PM, Marc Glisse wrote: > On Thu, 2 Aug 2012, Richard Guenther wrote: > >> On Wed, Aug 1, 2012 at 9:21 PM, Marc Glisse wrote: >>> >>> Hello, >>> >>> an opinion on this? >>> >>> (I just noticed: I'll update the list in the comment visible at the top >>> of >>> the patch if this gets in). >> >> >> It looks ok to me but I am no floating-point expert. Can you add a >> testcase? >> >> Ok with that change. > > > Here again with a testcase. The -O is not necessary for the optimization to > happen, but it seemed wrong to me not to include it. I wondered about adding > an explicit -ftrapping-math, for documentation purposes. > > I am redoing the bootstrap+regtest, then I'll commit if I don't hear > protests about the testcase. Yes, an explicit -ftrapping-math would be good. Thanks, Richard. > gcc/ChangeLog > > 2012-06-15 Marc Glisse > > PR tree-optimization/53805 > * fold-const.c (invert_tree_comparison): Do invert ORDERED_EXPR and > UNORDERED_EXPR for floating point. > > gcc/testsuite/ChangeLog > > 2012-06-15 Marc Glisse > > PR tree-optimization/53805 > * gcc.dg/fold-notunord.c: New testcase. > > -- > Marc Glisse > Index: gcc/testsuite/gcc.dg/fold-notunord.c > =================================================================== > --- gcc/testsuite/gcc.dg/fold-notunord.c (revision 0) > +++ gcc/testsuite/gcc.dg/fold-notunord.c (revision 0) > @@ -0,0 +1,10 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O -fdump-tree-optimized" } */ > + > +int f (double d) > +{ > + return !__builtin_isnan (d); > +} > + > +/* { dg-final { scan-tree-dump " ord " "optimized" } } */ > +/* { dg-final { cleanup-tree-dump "optimized" } } */ > > Property changes on: gcc/testsuite/gcc.dg/fold-notunord.c > ___________________________________________________________________ > Added: svn:eol-style > + native > Added: svn:keywords > + Author Date Id Revision URL > > Index: gcc/fold-const.c > =================================================================== > --- gcc/fold-const.c (revision 190071) > +++ gcc/fold-const.c (working copy) > @@ -2087,26 +2087,28 @@ static tree > pedantic_non_lvalue_loc (location_t loc, tree x) > { > if (pedantic_lvalues) > return non_lvalue_loc (loc, x); > > return protected_set_expr_location_unshare (x, loc); > } > > /* Given a tree comparison code, return the code that is the logical > inverse. > It is generally not safe to do this for floating-point comparisons, > except > - for EQ_EXPR and NE_EXPR, so we return ERROR_MARK in this case. */ > + for EQ_EXPR, NE_EXPR, ORDERED_EXPR and UNORDERED_EXPR, so we return > + ERROR_MARK in this case. */ > > enum tree_code > invert_tree_comparison (enum tree_code code, bool honor_nans) > { > - if (honor_nans && flag_trapping_math && code != EQ_EXPR && code != > NE_EXPR) > + if (honor_nans && flag_trapping_math && code != EQ_EXPR && code != > NE_EXPR > + && code != ORDERED_EXPR && code != UNORDERED_EXPR) > return ERROR_MARK; > > switch (code) > { > case EQ_EXPR: > return NE_EXPR; > case NE_EXPR: > return EQ_EXPR; > case GT_EXPR: > return honor_nans ? UNLE_EXPR : LE_EXPR; >