From patchwork Thu Oct 20 16:46:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 6299 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp213355wrr; Thu, 20 Oct 2022 09:47:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5eIq+3FavvqYSNxcyVG/C86xUk/3I9GThqOaS2EkOhq3FlfRRwo7EG5rVr2UEMeLB6wc9O X-Received: by 2002:aa7:d348:0:b0:45b:8ae3:ee3d with SMTP id m8-20020aa7d348000000b0045b8ae3ee3dmr13123292edr.428.1666284459491; Thu, 20 Oct 2022 09:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666284459; cv=none; d=google.com; s=arc-20160816; b=nhNSX1idcv5jJfjEzy1VhTYCzesY80xmrZxirgKw2N1AGQ9Gs7XXDupamg15Bq7cDs QoLXrXkxHqA/1wWoryu9CTIPNaFMZOEnEM5Zvgm8FcCKw2W9OucWmK8Ha4Dq91bRQQBW Vef00MDraa6DbFPlnmvMNRM0nwWJm+eSWWfaMpEOVON9Ma7Dn0NVh/vm8mjJISULeof1 ftWeht+N6GJC9eP3lif1Vp3l8vjh/4OTtJjQGqZgL+Dxa/a4LeJqBZ2kY4UoFsHlKv/O XHpovf9S6dTQODCWlurg2xHjt7Wy56/W4QZ07IR/ww+SoJReaus8NPPaFfWvVtqlBha2 Baag== 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-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=26OuE8u4JBKlxHWbIAuRtWXpZedzXhoI8/SkupO/XoM=; b=tfXDBpQROKFNT9WST7JlKdUI7Tasc5YQm32LBTd5UxQT8Xj3Q8rkP2pqPu4AB4CVqI rvugY4KlqEMwE+4kYVwodUl22rlhwhYWF96kRvxCd+QtuyheHNyQ2vEN9AW+4lG95Tb1 1TojjGIW92C+GJaXsZf62WAZDka509eo8h2ky3Ql8ZgCTKR/uz3PvuOxwi1TBw+nk8Sr W2ytOv+0YvsqGRdFOnYUxYCzjLxinMA9hCWOp1rcn+3J9bKK+MU/HVt1df/QmFEIpla8 iib1l6GFtuaKJt65KghpME+uzrLmMouvy9+Fk0eHZbdkurx9SjeojaBUNt1dw9SJDJC9 L/BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=J65JXtrs; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v8-20020a50c408000000b0045744c3c3d8si16330796edf.515.2022.10.20.09.47.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 09:47:39 -0700 (PDT) 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=J65JXtrs; 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 22A34384D1B0 for ; Thu, 20 Oct 2022 16:47:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22A34384D1B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666284458; bh=26OuE8u4JBKlxHWbIAuRtWXpZedzXhoI8/SkupO/XoM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=J65JXtrsh7Uy4rm6WuFBZfPHZidlhlE2ryRvHv4gCktmU0fH6J4pYFVa2QPhbZZyN gVHklY5EmGqrECuyuGg09d7kKlQV22Mg4ogvXTX4IW+/xhDXtyoz9iQUMetcNJ59kz /R7qLwRhvgVZJh5zMaAikdRg9bhyEDBeUHup8gO4= 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 8088A384D1AF for ; Thu, 20 Oct 2022 16:46:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8088A384D1AF 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-328-u8fPASf7M_iWb3O2mb1MuA-1; Thu, 20 Oct 2022 12:46:53 -0400 X-MC-Unique: u8fPASf7M_iWb3O2mb1MuA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 513A4823F74 for ; Thu, 20 Oct 2022 16:46:48 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.87]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 348A24047AD; Thu, 20 Oct 2022 16:46:44 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 29KGkav8256451 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 18:46:37 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 29KGkasg256450; Thu, 20 Oct 2022 18:46:36 +0200 To: GCC patches Subject: [COMMITTED] A false UNORDERED_ means neither operand can be a NAN. Date: Thu, 20 Oct 2022 18:46:33 +0200 Message-Id: <20221020164633.256422-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 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 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: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez 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?1747225893009109674?= X-GMAIL-MSGID: =?utf-8?q?1747225893009109674?= The false side of UNORDERED_ means neither operand can be a NAN. Adjust all the op[12]_range entries for the UNORDERED operators such that a known NAN on one operands means the other operands is undefined. gcc/ChangeLog: * range-op-float.cc (foperator_unordered_le::op1_range): Adjust false side with a NAN operand. (foperator_unordered_le::op2_range): Same. (foperator_unordered_gt::op1_range): Same. (foperator_unordered_gt::op2_range): Same. (foperator_unordered_ge::op1_range): Same. (foperator_unordered_ge::op2_range): Same. (foperator_unordered_equal::op1_range): Same. --- gcc/range-op-float.cc | 51 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index a9e74c86877..0cb07c2ec29 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -1351,7 +1351,11 @@ foperator_unordered_le::op1_range (frange &r, tree type, break; case BRS_FALSE: - if (build_gt (r, type, op2)) + // A false UNORDERED_LE means both operands are !NAN, so it's + // impossible for op2 to be a NAN. + if (op2.known_isnan ()) + r.set_undefined (); + else if (build_gt (r, type, op2)) r.clear_nan (); break; @@ -1375,7 +1379,11 @@ foperator_unordered_le::op2_range (frange &r, break; case BRS_FALSE: - if (build_lt (r, type, op1)) + // A false UNORDERED_LE means both operands are !NAN, so it's + // impossible for op1 to be a NAN. + if (op1.known_isnan ()) + r.set_undefined (); + else if (build_lt (r, type, op1)) r.clear_nan (); break; @@ -1434,7 +1442,11 @@ foperator_unordered_gt::op1_range (frange &r, break; case BRS_FALSE: - if (build_le (r, type, op2)) + // A false UNORDERED_GT means both operands are !NAN, so it's + // impossible for op2 to be a NAN. + if (op2.known_isnan ()) + r.set_undefined (); + else if (build_le (r, type, op2)) r.clear_nan (); break; @@ -1458,7 +1470,11 @@ foperator_unordered_gt::op2_range (frange &r, break; case BRS_FALSE: - if (build_ge (r, type, op1)) + // A false UNORDERED_GT means both operands are !NAN, so it's + // impossible for op1 to be a NAN. + if (op1.known_isnan ()) + r.set_undefined (); + else if (build_ge (r, type, op1)) r.clear_nan (); break; @@ -1517,7 +1533,11 @@ foperator_unordered_ge::op1_range (frange &r, break; case BRS_FALSE: - if (build_lt (r, type, op2)) + // A false UNORDERED_GE means both operands are !NAN, so it's + // impossible for op2 to be a NAN. + if (op2.known_isnan ()) + r.set_undefined (); + else if (build_lt (r, type, op2)) r.clear_nan (); break; @@ -1540,7 +1560,11 @@ foperator_unordered_ge::op2_range (frange &r, tree type, break; case BRS_FALSE: - if (build_gt (r, type, op1)) + // A false UNORDERED_GE means both operands are !NAN, so it's + // impossible for op1 to be a NAN. + if (op1.known_isnan ()) + r.set_undefined (); + else if (build_gt (r, type, op1)) r.clear_nan (); break; @@ -1606,10 +1630,17 @@ foperator_unordered_equal::op1_range (frange &r, tree type, break; case BRS_FALSE: - // The false side indictates !NAN and not equal. We can at least - // represent !NAN. - r.set_varying (type); - r.clear_nan (); + // A false UNORDERED_EQ means both operands are !NAN, so it's + // impossible for op2 to be a NAN. + if (op2.known_isnan ()) + r.set_undefined (); + else + { + // The false side indictates !NAN and not equal. We can at least + // represent !NAN. + r.set_varying (type); + r.clear_nan (); + } break; default: