From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 793093858421 for ; Mon, 24 Oct 2022 13:34:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 793093858421 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666618487; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AY1A2q/MrBC5qf2Km5ivO3+U0Vv2OsEksTzECJl0d3c=; b=Lm+FlBPXr8JQ+Ild8JCTC2UNKb0pouYnJpB1/V9emGmuopZYa1Lt7gEv3rLhYYwoSGFgIk Em7ubnM72tdHp/40Fn+Mnl6EaekoBLX5/Ze9i/lCRVKlQtjrrysGZ1e4xeg08ZtbemY4Bm 3AUAVFYm4J5o8Jp4dCKp3ejYijf9pXw= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-651-576b5ztePAyiqYYthQmC6Q-1; Mon, 24 Oct 2022 09:34:43 -0400 X-MC-Unique: 576b5ztePAyiqYYthQmC6Q-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-33dc888dc62so91811397b3.4 for ; Mon, 24 Oct 2022 06:34:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AY1A2q/MrBC5qf2Km5ivO3+U0Vv2OsEksTzECJl0d3c=; b=yrKv4LCXaSLajd6NvdTa0htMRgOha9cWbWXuUwchNVDZQqHQWAeEC7P3O9oXE0LlEc JDPjw6iH9huT9T5nXw6XaV707YvSCRX4fAdOmcZNpbaTGipCcpJazQvn63tGEImpJ6tm NE5qaRCC48GCr2P6d/J33E75EPqpJAx7Vx51TfdOPw9FC/Lysx/fRPB7NrQhM7g/f9Lv WRFt77RvX9lLZhYGjo8D2HkgLosT8O9FHrixptBaLakWwHZWqqmuiyAArK/ciGela5R/ eiJ/tsQbZ62R58Fr2rCVEjAejKKu9UIpczUdBCkHJEOkIVB1Kb2OXhi7pWb9CxN4a6nK sRgA== X-Gm-Message-State: ACrzQf1zC+4qX3sYx9rNp67e9gKxjEvCQoj26Y10QSUihEs32uwEMBuv xvP/nBadc/ad/0EhhAXp7wUrk/ajf5+E9Mi//t64MKgPpn5ZAOhYth2YAeReIiQJgD198A085ex UeNr1Oh5TTz7q+ZBePzoev02ZDjaBau7P3A== X-Received: by 2002:a25:6055:0:b0:6be:340a:3757 with SMTP id u82-20020a256055000000b006be340a3757mr27709410ybb.109.1666618483223; Mon, 24 Oct 2022 06:34:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM63yQstOiV2WDmgseUHj0zUns8ZkY9WhNnNz82baoU1kbGRNRgzpEPW69n7NZ9qeM9aDRu540bjDPO1oSgtkJE= X-Received: by 2002:a25:6055:0:b0:6be:340a:3757 with SMTP id u82-20020a256055000000b006be340a3757mr27709394ybb.109.1666618482944; Mon, 24 Oct 2022 06:34:42 -0700 (PDT) MIME-Version: 1.0 References: <20221024133316.33026-1-aldyh@redhat.com> In-Reply-To: <20221024133316.33026-1-aldyh@redhat.com> From: Aldy Hernandez Date: Mon, 24 Oct 2022 15:34:31 +0200 Message-ID: Subject: Re: [PATCH] [PR tree-optimization/107355] Handle NANs in abs range-op entry. To: GCC patches Cc: Andrew MacLeod X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested on x86-64 Linux. Pushed. On Mon, Oct 24, 2022 at 3:33 PM Aldy Hernandez wrote: > > The problem here is that the threader is coming up with a path where > the only valid result is a NAN. When the abs op1_range entry is > trying to add the negative posibility, it attempts to get the bounds > of the working range. NANs don't have bounds so they need to be > special cased. > > PR tree-optimization/107355 > > gcc/ChangeLog: > > * range-op-float.cc (foperator_abs::op1_range): Handle NAN. > > gcc/testsuite/ChangeLog: > > * gcc.dg/tree-ssa/pr107355.c: New test. > --- > gcc/range-op-float.cc | 9 +++++++++ > gcc/testsuite/gcc.dg/tree-ssa/pr107355.c | 13 +++++++++++++ > 2 files changed, 22 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr107355.c > > diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc > index 8777bc70d71..04208c88dd1 100644 > --- a/gcc/range-op-float.cc > +++ b/gcc/range-op-float.cc > @@ -1269,6 +1269,15 @@ foperator_abs::op1_range (frange &r, tree type, > positives.update_nan (/*sign=*/false); > positives.intersect (lhs); > r = positives; > + // Add -NAN if relevant. > + if (r.maybe_isnan ()) > + { > + frange neg_nan; > + neg_nan.set_nan (type, true); > + r.union_ (neg_nan); > + } > + if (r.known_isnan ()) > + return true; > // Then add the negative of each pair: > // ABS(op1) = [5,20] would yield op1 => [-20,-5][5,20]. > r.union_ (frange (type, > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr107355.c b/gcc/testsuite/gcc.dg/tree-ssa/pr107355.c > new file mode 100644 > index 00000000000..40796344bfb > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr107355.c > @@ -0,0 +1,13 @@ > +// { dg-do compile } > +// { dg-options "-O2 -fno-guess-branch-probability -fsanitize=float-cast-overflow --param=max-jump-thread-duplication-stmts=240" } > + > +float f; > + > +void > +foo (double d) > +{ > + (char) f; > + long l = __builtin_fabs (d); > + (char) f; > + (long) d; > +} > -- > 2.37.3 >