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.133.124]) by sourceware.org (Postfix) with ESMTPS id EB3AF385B1B3 for ; Mon, 5 Dec 2022 22:37:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EB3AF385B1B3 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=1670279831; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-to:resent-from:resent-message-id; bh=sfUZsS/3XI5bqxR9SQ0R3UX5trIboI+efIB2wdqNuec=; b=i3v/TeH7EnTN0hf0OjF+bZE19jdBE0KjbE2VX6r+S/XyGa/gQqB6sbZ1k3WXWX2IKIZ5Sd 7lJ9JJZ2udLmqwk2N0Q7kaYrgTfP2SyLtfSwtscUbCX1ome51QcGSFWfRQWA9/FjGZWKnO vpE9CZaRatFAPNteKS1U2mKnR53inwM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-424-sKQIy_3aP9Ko0LH6Aweodw-1; Mon, 05 Dec 2022 17:37:10 -0500 X-MC-Unique: sKQIy_3aP9Ko0LH6Aweodw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4BA6A101A54E; Mon, 5 Dec 2022 22:37:10 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.195.114]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0CD7C1121325; Mon, 5 Dec 2022 22:37:09 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 2B5Mb5lN3424795 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 5 Dec 2022 23:37:05 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2B5Mb4oH3424794; Mon, 5 Dec 2022 23:37:04 +0100 Resent-From: Jakub Jelinek Resent-Date: Mon, 5 Dec 2022 23:37:04 +0100 Resent-Message-ID: Resent-To: Richard Biener , Aldy Hernandez , gcc-patches@gcc.gnu.org Date: Mon, 5 Dec 2022 19:35:46 +0100 From: Jakub Jelinek To: Richard Biener , Aldy Hernandez Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] range-op-float: Fix up ICE in lower_bound [PR107975] Message-ID: Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,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: Hi! According to https://gcc.gnu.org/pipermail/gcc-regression/2022-December/077258.html my patch caused some ICEs, e.g. the following testcase ICEs. The problem is that lower_bound and upper_bound methods on a france assert that the range isn't VR_NAN or VR_UNDEFINED. All the op1_range/op2_range methods already return early if lhs.undefined_p, but the other cases (when lhs is VR_NAN or the other opN is VR_NAN or VR_UNDEFINED) aren't. float_binary_op_range_finish will DTRT for those cases already. Ok for trunk if this passes bootstrap/regtest? 2022-12-05 Jakub Jelinek PR tree-optimization/107975 * range-op-float.cc (foperator_mult::op1_range, foperator_div::op1_range, foperator_div::op2_range): Just return float_binary_op_range_finish result if lhs is known NAN, or the other operand is known NAN or UNDEFINED. * gcc.dg/pr107975.c: New test. --- gcc/range-op-float.cc.jj 2022-12-05 11:17:34.900573272 +0100 +++ gcc/range-op-float.cc 2022-12-05 17:58:38.059754128 +0100 @@ -2146,6 +2146,8 @@ public: bool ret = rdiv.fold_range (r, type, lhs, op2); if (ret == false) return false; + if (lhs.known_isnan () || op2.known_isnan () || op2.undefined_p ()) + return float_binary_op_range_finish (ret, r, type, lhs); const REAL_VALUE_TYPE &lhs_lb = lhs.lower_bound (); const REAL_VALUE_TYPE &lhs_ub = lhs.upper_bound (); const REAL_VALUE_TYPE &op2_lb = op2.lower_bound (); @@ -2296,6 +2298,8 @@ public: bool ret = fop_mult.fold_range (r, type, lhs, op2); if (!ret) return ret; + if (lhs.known_isnan () || op2.known_isnan () || op2.undefined_p ()) + return float_binary_op_range_finish (ret, r, type, lhs); const REAL_VALUE_TYPE &lhs_lb = lhs.lower_bound (); const REAL_VALUE_TYPE &lhs_ub = lhs.upper_bound (); const REAL_VALUE_TYPE &op2_lb = op2.lower_bound (); @@ -2325,6 +2329,8 @@ public: bool ret = fold_range (r, type, op1, lhs); if (!ret) return ret; + if (lhs.known_isnan () || op1.known_isnan () || op1.undefined_p ()) + return float_binary_op_range_finish (ret, r, type, lhs); const REAL_VALUE_TYPE &lhs_lb = lhs.lower_bound (); const REAL_VALUE_TYPE &lhs_ub = lhs.upper_bound (); const REAL_VALUE_TYPE &op1_lb = op1.lower_bound (); --- gcc/testsuite/gcc.dg/pr107975.c.jj 2022-12-05 19:15:56.518851401 +0100 +++ gcc/testsuite/gcc.dg/pr107975.c 2022-12-05 19:15:04.014620281 +0100 @@ -0,0 +1,15 @@ +/* PR tree-optimization/107975 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-add-options ieee } */ + +double +foo (double x, double y) +{ + if (x == 42.0) + return 1.0; + double r = x * y; + if (!__builtin_isnan (r)) + __builtin_unreachable (); + return r; +} Jakub