From patchwork Mon Dec 5 18:35:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 29977 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2507821wrr; Mon, 5 Dec 2022 14:37:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf6h6Fr/aLd0rTpo6Y2q3IIyWdpUHLRSV+pX3exkoo5Go/vysG74tlvQ58cNETfYZgjH+L8V X-Received: by 2002:a17:906:72cc:b0:7c1:1c1:c7d6 with SMTP id m12-20020a17090672cc00b007c101c1c7d6mr2768870ejl.556.1670279876833; Mon, 05 Dec 2022 14:37:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670279876; cv=none; d=google.com; s=arc-20160816; b=RRDkj725FZ4QfcXyyV7LxCfZE1ZmpOodLo4cqppyc6bF1Ij3UnVtkluzpOQHsvZ6nK 6OjgmfosdgUZw/pJ3Y92xWyqt4CSi4IwRVjg54sUvTr9NQn9mDVQ+NA7Fjth/5JOw68N hbSsFixYCmhWpmZhPn5MlzleCd/d8S+WKCVIP1ZPZYQhJVrrhZAYy2eH0GEQCzdTgUg5 +Z6PZCfus4y1Um3QKFA1krisEynsQBbSXiieq9dLJIa3afA/HTYLB3UknaIlbCRXOfuJ Xlhro+ibALAvAxteTTRRx4qGrP1rOFmKJU6FPDQWcxuC03kFenAYfVN4tLoHZJ6Lf/pk IIaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :resent-to:resent-message-id:resent-date:resent-from:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=sfUZsS/3XI5bqxR9SQ0R3UX5trIboI+efIB2wdqNuec=; b=iC2fjQtcYEfeu1hD7n9m4xeFEGGvH0S6mv7GJFaTQFNE76BK4EGiXCV/WK9Bd/Q7/L VSWmbAdRtMm272sza1qtiky1018vX4KneKngkBSNmLW3ZPJxVkEGz0brOwH6V88l7JAe LszejyztcXnqgBX1lgECqNSKo0XGqqfssWxmJA8lE1XcHFXzgvR8mJRwZoeNnhaXWIoQ cpjUH66KBUGT6FIe9FKppHNLob/42gwp3OwztI2xRp0oyqGzWI+exIv9IXb+pavNB7mI MEmCLEVYkVeMPah/8/LlMAfzPjL2zZzKSDXMb0zw2FDw1Ggx7hvCL+aYnFhy2DjJKqFH RI4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nEr5CxDA; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i11-20020aa7c70b000000b0045981993486si491787edq.227.2022.12.05.14.37.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 14:37:56 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nEr5CxDA; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C5CAA385B18C for ; Mon, 5 Dec 2022 22:37:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C5CAA385B18C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670279875; bh=sfUZsS/3XI5bqxR9SQ0R3UX5trIboI+efIB2wdqNuec=; h=Resent-From:Resent-Date:Resent-To:Date:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=nEr5CxDAyJgcatL3dgIf+LJ9xe/3aqCQTDXD7L1pjflwWxzFNwXbiJ7vWOw0H817M 3q+/ldruslPuj+hMNDLQmgWzlwA31eUtPnvjfmjrxe153if+s1q15nqoGWURMDbLi7 jL74p4ujZObNu2uNvp6xgHsaizwJ/m9FdayDNHoM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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 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: 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-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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751415392066095117?= X-GMAIL-MSGID: =?utf-8?q?1751415392066095117?= 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. Jakub --- 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; +}