From patchwork Mon Oct 17 13:25:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 3457 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1446046wrs; Mon, 17 Oct 2022 06:26:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7jy5fE9OT5oNBwbagpVFnhiqF850YNgMZG88xSj8hfHHXvDv4Y3GFyswYv9Dvj9vGBwHiz X-Received: by 2002:a17:907:da7:b0:791:8f57:6860 with SMTP id go39-20020a1709070da700b007918f576860mr5030788ejc.509.1666013186833; Mon, 17 Oct 2022 06:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666013186; cv=none; d=google.com; s=arc-20160816; b=BxOIcr/8DP/09Lw9cQJJ3Oh718zYy1V8ueR2Tuu5E3CJwQNZY/jddhcUU6y/V3B84v CZqCV2uND+b72pMMs1oCephxCiKNhRKtKLMxyyZ2x0lyZsJrPATQR/TlBoYEJoha60Rc VPLUs4gwadeLJgAd/2sfWM0Mqi2u0CX8YuJYZht/t4m92UfJLU44pEK2/RkKrddGszfW nQMG5q54XoagnjudbCcL23TaIpc4dQfmANKs1lzLsFjyJZqTXsemm3Vv9yZYRBWoK1aF OF8mer1H4obrfTCR8S+blLnKlgNLu6MOBQ2+XbQKWF9bNizXkhRFaE7rjnabUGXhBYiV DD5w== 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-language :subject:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=sDtpjd4dcd1zZG0OPqyoYw/QwsovlrKHTXcdbgD/36I=; b=xOhBRtID7sacvx6PRD3Ko6sCNfEYpl4vLawDJA58O71JqBo2qpYHzlG/1PORzYjoiq nzBt3M1f4DZ5xvannH4cPLMKSy/tUey9P4UxOk1RCJaONA39GHkVlHxQS01nAhDbZbA+ 6eozcH02PKcmQHV2l1dOZ/POBnY145VcRD/PBBKBGStc4hGogw+raTqwO2b1YpTHmAJt zY21c2zKgp7h+am0wnp4DAp7Z+TgIzWO+LMdjZjMCbnBzu8O+8LE0Ekc9onzUAiv4g5Z iwr9YxtuuIRQ18wqqF+KDmKwBrOXjHW/cwJ1PIAWN7oRXxOMxIjx3dvOwqsy3nvOdkM+ Le2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=PwV7QQGR; 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 tz14-20020a170907c78e00b0078a891e3eb1si6244983ejc.103.2022.10.17.06.26.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 06:26:26 -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=PwV7QQGR; 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 0917C385780A for ; Mon, 17 Oct 2022 13:26:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0917C385780A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666013174; bh=sDtpjd4dcd1zZG0OPqyoYw/QwsovlrKHTXcdbgD/36I=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=PwV7QQGRNtwx6h7kTP4TlyX9bChIMJ1bewojtubYGqfMX+Ff11KBOpE3q/6ke1U6i DbQ9nzYU9PVhzGxL3HFKlUpO1SLZiC9wdJJvYiLy1pE9wFHcLvYFFkB52YhkBGoQRX jqzcPBgkLh5cGbac49orHvKiERu3kWiS3trBBbjQ= 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 265633858290 for ; Mon, 17 Oct 2022 13:25:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 265633858290 Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-632-eP7r7hyiOSSldSlGpUrk1A-1; Mon, 17 Oct 2022 09:25:27 -0400 X-MC-Unique: eP7r7hyiOSSldSlGpUrk1A-1 Received: by mail-il1-f199.google.com with SMTP id i8-20020a056e0212c800b002f9a4c75658so9017540ilm.3 for ; Mon, 17 Oct 2022 06:25:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8BlhAy575jK7WeioEf0uR+yrwLCtDj2zZOdbn55QFME=; b=7CWXdryzqXy6wWUrD/MviKjLuEU1koew5JS8SfaCF8//vfrN/PqCjbry6L5/EgrcCH Ooj1kR5BEamCINKGorT03dXDSFR2u0BL/LTqgLjeXPdy227xR+GExXbsNcazvjkC5Ky8 SdH6w0k7hdGPWJHOv4IFEXAx7FDeHMWk7dHqmHj5W3TkCSQ2gKwPNNErJdGcnnfSoC/B c8QU0a3UwCQAhdb5UDvTD8P+Qxt05YWQPAEnzrYXFDIhTy6QUR08JqXSPDqCHZS69+xS CIOzMwTZesraWNZpL1qkx9HiBJWZ1zgNlGmhwdWmzqsssbRs9V7RRAdRIvC5nBDwuuIV DrRQ== X-Gm-Message-State: ACrzQf0b/ZtQbCcB3h6wjeTjrUcRLWl9VZ6t6no5tfpO1LAUiatirPAI okwp0Z66N5yR7cTrJp3j3d4u/ZteQnt0VBhqr6mNcqsxVIWJIQra/+p47EKha3br0xD3kfEYl/G 5Ka2D7u+raICsXwM73O0WCdRUvKR+Y4DGqgJYpQC4gJCmZIC5IvVXauy9Q1GwhP6fNVii2g== X-Received: by 2002:a05:6e02:5a1:b0:2f9:456:139f with SMTP id k1-20020a056e0205a100b002f90456139fmr4660627ils.299.1666013126508; Mon, 17 Oct 2022 06:25:26 -0700 (PDT) X-Received: by 2002:a05:6e02:5a1:b0:2f9:456:139f with SMTP id k1-20020a056e0205a100b002f90456139fmr4660616ils.299.1666013126233; Mon, 17 Oct 2022 06:25:26 -0700 (PDT) Received: from ?IPV6:2607:fea8:a263:f600::50d4? ([2607:fea8:a263:f600::50d4]) by smtp.gmail.com with ESMTPSA id g14-20020a05660226ce00b006a129b10229sm4221431ioo.31.2022.10.17.06.25.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Oct 2022 06:25:25 -0700 (PDT) Message-ID: <03ebe7bc-13bf-a37f-7f8d-d2146e2df918@redhat.com> Date: Mon, 17 Oct 2022 09:25:24 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 To: gcc-patches Subject: [COMMITTED] Fix nan updating in range-ops. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.0 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: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod 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?1746941443168325183?= X-GMAIL-MSGID: =?utf-8?q?1746941443168325183?= There is a path in which clear_nan() is called on an UNDEFINED range, which is not allowed.  This patch simply makes sure VARYING is set before calling clear_nan(). In operator_not_equal, we should check if op1 == op1 AFTER the check for a singleton. operator_ordered was also cealring the NAN on the false side, and should be setting it. None of these paths were being executed to this point as GORI was not passing in the relation between op1 and op2, but the next patch changes that and would trigger these issues. Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 04874fedae8074b252abbd70fea68bf3dd0a605b Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 14 Oct 2022 09:29:23 -0400 Subject: [PATCH 2/4] Fix nan updating in range-ops. Calling clean_nan on an undefined type traps, set_varying first. Other tweaks for correctness. * range-op-float.cc (foperator_not_equal::op1_range): Check for VREL_EQ after singleton. (foperator_unordered::op1_range): Set VARYING before calling clear_nan(). (foperator_ordered::op1_range): Set rather than clear NAN if both operands are the same. --- gcc/range-op-float.cc | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 23e0f5ef4e2..6cf2180ce59 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -510,12 +510,9 @@ foperator_not_equal::op1_range (frange &r, tree type, switch (get_bool_state (r, lhs, type)) { case BRS_TRUE: - // The TRUE side of op1 != op1 implies op1 is NAN. - if (rel == VREL_EQ) - r.set_nan (type); // If the result is true, the only time we know anything is if // OP2 is a constant. - else if (op2.singleton_p ()) + if (op2.singleton_p ()) { // This is correct even if op1 is NAN, because the following // range would be ~[tmp, tmp] with the NAN property set to @@ -523,6 +520,9 @@ foperator_not_equal::op1_range (frange &r, tree type, REAL_VALUE_TYPE tmp = op2.lower_bound (); r.set (type, tmp, tmp, VR_ANTI_RANGE); } + // The TRUE side of op1 != op1 implies op1 is NAN. + else if (rel == VREL_EQ) + r.set_nan (type); else r.set_varying (type); break; @@ -1045,22 +1045,18 @@ foperator_unordered::op1_range (frange &r, tree type, switch (get_bool_state (r, lhs, type)) { case BRS_TRUE: - if (rel == VREL_EQ) - r.set_nan (type); // Since at least one operand must be NAN, if one of them is // not, the other must be. - else if (!op2.maybe_isnan ()) + if (rel == VREL_EQ || !op2.maybe_isnan ()) r.set_nan (type); else r.set_varying (type); break; case BRS_FALSE: - if (rel == VREL_EQ) - r.clear_nan (); // A false UNORDERED means both operands are !NAN, so it's // impossible for op2 to be a NAN. - else if (op2.known_isnan ()) + if (op2.known_isnan ()) r.set_undefined (); else { @@ -1132,10 +1128,11 @@ foperator_ordered::op1_range (frange &r, tree type, break; case BRS_FALSE: - r.set_varying (type); - // The FALSE side of op1 ORDERED op1 implies op1 is !NAN. + // The FALSE side of op1 ORDERED op1 implies op1 is NAN. if (rel == VREL_EQ) - r.clear_nan (); + r.set_nan (type); + else + r.set_varying (type); break; default: -- 2.37.3