From patchwork Wed Sep 14 15:08:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1213 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2302:b0:79:6ae5:3758 with SMTP id gv2csp743149dyb; Wed, 14 Sep 2022 08:10:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR5VAqLlW5f7zXyckNB43+5F5r2FwUEQkj5Nwh+cAhIdUW7CulwYQb40jHNvXhBqTE0CFAW3 X-Received: by 2002:a05:6402:2693:b0:450:a807:6c91 with SMTP id w19-20020a056402269300b00450a8076c91mr26570935edd.33.1663168239756; Wed, 14 Sep 2022 08:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663168239; cv=none; d=google.com; s=arc-20160816; b=Lr0BVDPLxQ+sV2g9v4bj/Vz495puJOnhV372GYXsZlNDIdvzu+hEtczSYaWR74alOs NyImsyacDAZCXzlW6P/4+tOMrwLb5UQByvnhmmU+RlgdOvyoPcxk3ZTe5k+ZQ9XVcyhZ jsVcol0+WJ5QYpXMi1F4u+T+vJUf+HfoPUDGIbtDEh0JmRgonur4KpnNTanZVTdBbtP/ dND0hWki+eGixpq/FOO/Z0Ovlmy1YPQwPVzaiyazXsqOsH6yVTLDOstE1Obn3WYEfXd7 7u330sHQM5g75ZCm4ETXOzDqQKV39AVpro7PtRN4r8ZTHUBaXW+QGtfZFUqNZE05qilp dpzg== 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:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=26BmcaNiXhoBUaBBaMuqr2dQPFT/fDETPRANA9dFEVQ=; b=UcuGlNI2IVKe0owXQRLTSemVFeV3ue7Hm6dEEvlkks8IkUGR9lsyiAUCOOmD84+7cX imYj2M0qu/rn7rimw5S59T+a9IBHGuKrekyGRTQEZcc3hHR6ilZuF5gqNU743YbvfT1+ BlVw30MIuIEsFq89uRqvUrYQyAm9k0XMr99ib1//27cwlW1v4zceGEv/5K/MjioFrbG4 FsKZXaYfbp6lcdggnlrYPbJ4sO4UlSN7EyZpI81moyYGXrgrW7Lh3S0+ZEa8yroHzW4W mJFVZyBU5mtRZQggqL2TR+zn0Z8PrKjbE4X5jfzZm4oFf+AXfPcSHCgBuRutmfjm9HyU 0pHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kcFjHBER; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id os4-20020a170906af6400b00741a16e8562si9823303ejb.826.2022.09.14.08.10.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:10:39 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kcFjHBER; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 D17F63851ABB for ; Wed, 14 Sep 2022 15:09:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D17F63851ABB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663168186; bh=26BmcaNiXhoBUaBBaMuqr2dQPFT/fDETPRANA9dFEVQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=kcFjHBER/lmH8v0wN2cvQ/R7rd+mFHxi0TVhmSdbh4lAvHOoi4BscXj9zaHJ1Ua8W 7YTgklf1ix08ao8BjnVkEFO1dtyDG6fbNfnk1DHpSogLLG/W68bF7BTswI19N1G7su Gv05vTe1aVIqg6KDins55ahWhMXabd+ecMCBbZBA= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 548DD3858427 for ; Wed, 14 Sep 2022 15:09:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 548DD3858427 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-17-rl97ZuA8MSajbkqq2nf4pw-1; Wed, 14 Sep 2022 11:09:00 -0400 X-MC-Unique: rl97ZuA8MSajbkqq2nf4pw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F603862FE1 for ; Wed, 14 Sep 2022 15:09:00 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.40.192.189]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22B9840C6EC2; Wed, 14 Sep 2022 15:08:59 +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 28EF8wbT1244457 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 14 Sep 2022 17:08:58 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 28EF8wer1244456; Wed, 14 Sep 2022 17:08:58 +0200 To: GCC patches Subject: [COMMITTED] Pass full range to build_* in range-op-float.cc Date: Wed, 14 Sep 2022 17:08:51 +0200 Message-Id: <20220914150852.1244397-4-aldyh@redhat.com> In-Reply-To: <20220914150852.1244397-1-aldyh@redhat.com> References: <20220914150852.1244397-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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?1743958300163777007?= X-GMAIL-MSGID: =?utf-8?q?1743958300163777007?= The build_ helper functions in range-op-float.cc take the actual value from the operand's endpoint, but this value could be deduced from the operand itself therefore cleaning up the call site. This also reduces the potential of mistakenly passing the wrong bound. No functional changes. Regstrapped on x86-64 Linux, plus I ran selftests for -ffinite-math-only. gcc/ChangeLog: * range-op-float.cc (build_le): Accept frange instead of number. (build_lt): Same. (build_ge): Same. (build_gt): Same. (foperator_lt::op1_range): Pass full range to build_*. (foperator_lt::op2_range): Same. (foperator_le::op1_range): Same. (foperator_le::op2_range): Same. (foperator_gt::op1_range): Same. (foperator_gt::op2_range): Same. (foperator_ge::op1_range): Same. (foperator_ge::op2_range): Same. --- gcc/range-op-float.cc | 72 +++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index f979ca597cb..8f3e5241313 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -208,32 +208,32 @@ frange_drop_ninf (frange &r, tree type) r.intersect (tmp); } -// (X <= VAL) produces the range of [-INF, VAL]. +// Build a range that is <= VAL and store it in R. static bool -build_le (frange &r, tree type, const REAL_VALUE_TYPE &val) +build_le (frange &r, tree type, const frange &val) { - if (real_isnan (&val)) + if (val.known_nan ()) { r.set_undefined (); return false; } - r.set (type, dconstninf, val); + r.set (type, dconstninf, val.upper_bound ()); return true; } -// (X < VAL) produces the range of [-INF, VAL). +// Build a range that is < VAL and store it in R. static bool -build_lt (frange &r, tree type, const REAL_VALUE_TYPE &val) +build_lt (frange &r, tree type, const frange &val) { - if (real_isnan (&val)) + if (val.known_nan ()) { r.set_undefined (); return false; } // < -INF is outside the range. - if (real_isinf (&val, 1)) + if (real_isinf (&val.upper_bound (), 1)) { if (HONOR_NANS (type)) r.set_nan (type); @@ -241,37 +241,37 @@ build_lt (frange &r, tree type, const REAL_VALUE_TYPE &val) r.set_undefined (); return false; } - // Hijack LE because we only support closed intervals. - build_le (r, type, val); + // We only support closed intervals. + r.set (type, dconstninf, val.upper_bound ()); return true; } -// (X >= VAL) produces the range of [VAL, +INF]. +// Build a range that is >= VAL and store it in R. static bool -build_ge (frange &r, tree type, const REAL_VALUE_TYPE &val) +build_ge (frange &r, tree type, const frange &val) { - if (real_isnan (&val)) + if (val.known_nan ()) { r.set_undefined (); return false; } - r.set (type, val, dconstinf); + r.set (type, val.lower_bound (), dconstinf); return true; } -// (X > VAL) produces the range of (VAL, +INF]. +// Build a range that is > VAL and store it in R. static bool -build_gt (frange &r, tree type, const REAL_VALUE_TYPE &val) +build_gt (frange &r, tree type, const frange &val) { - if (real_isnan (&val)) + if (val.known_nan ()) { r.set_undefined (); return false; } // > +INF is outside the range. - if (real_isinf (&val, 0)) + if (real_isinf (&val.lower_bound (), 0)) { if (HONOR_NANS (type)) r.set_nan (type); @@ -280,8 +280,8 @@ build_gt (frange &r, tree type, const REAL_VALUE_TYPE &val) return false; } - // Hijack GE because we only support closed intervals. - build_ge (r, type, val); + // We only support closed intervals. + r.set (type, val.lower_bound (), dconstinf); return true; } @@ -549,7 +549,7 @@ foperator_lt::op1_range (frange &r, switch (get_bool_state (r, lhs, type)) { case BRS_TRUE: - if (build_lt (r, type, op2.upper_bound ())) + if (build_lt (r, type, op2)) { r.clear_nan (); // x < y implies x is not +INF. @@ -558,7 +558,7 @@ foperator_lt::op1_range (frange &r, break; case BRS_FALSE: - build_ge (r, type, op2.lower_bound ()); + build_ge (r, type, op2); break; default: @@ -577,7 +577,7 @@ foperator_lt::op2_range (frange &r, switch (get_bool_state (r, lhs, type)) { case BRS_TRUE: - if (build_gt (r, type, op1.lower_bound ())) + if (build_gt (r, type, op1)) { r.clear_nan (); // x < y implies y is not -INF. @@ -586,7 +586,7 @@ foperator_lt::op2_range (frange &r, break; case BRS_FALSE: - build_le (r, type, op1.upper_bound ()); + build_le (r, type, op1); break; default: @@ -651,12 +651,12 @@ foperator_le::op1_range (frange &r, switch (get_bool_state (r, lhs, type)) { case BRS_TRUE: - if (build_le (r, type, op2.upper_bound ())) + if (build_le (r, type, op2)) r.clear_nan (); break; case BRS_FALSE: - build_gt (r, type, op2.lower_bound ()); + build_gt (r, type, op2); break; default: @@ -675,12 +675,12 @@ foperator_le::op2_range (frange &r, switch (get_bool_state (r, lhs, type)) { case BRS_TRUE: - if (build_ge (r, type, op1.lower_bound ())) + if (build_ge (r, type, op1)) r.clear_nan (); break; case BRS_FALSE: - build_lt (r, type, op1.upper_bound ()); + build_lt (r, type, op1); break; default: @@ -745,7 +745,7 @@ foperator_gt::op1_range (frange &r, switch (get_bool_state (r, lhs, type)) { case BRS_TRUE: - if (build_gt (r, type, op2.lower_bound ())) + if (build_gt (r, type, op2)) { r.clear_nan (); // x > y implies x is not -INF. @@ -754,7 +754,7 @@ foperator_gt::op1_range (frange &r, break; case BRS_FALSE: - build_le (r, type, op2.upper_bound ()); + build_le (r, type, op2); break; default: @@ -773,7 +773,7 @@ foperator_gt::op2_range (frange &r, switch (get_bool_state (r, lhs, type)) { case BRS_TRUE: - if (build_lt (r, type, op1.upper_bound ())) + if (build_lt (r, type, op1)) { r.clear_nan (); // x > y implies y is not +INF. @@ -782,7 +782,7 @@ foperator_gt::op2_range (frange &r, break; case BRS_FALSE: - build_ge (r, type, op1.lower_bound ()); + build_ge (r, type, op1); break; default: @@ -847,12 +847,12 @@ foperator_ge::op1_range (frange &r, switch (get_bool_state (r, lhs, type)) { case BRS_TRUE: - build_ge (r, type, op2.lower_bound ()); + build_ge (r, type, op2); r.clear_nan (); break; case BRS_FALSE: - build_lt (r, type, op2.upper_bound ()); + build_lt (r, type, op2); break; default: @@ -870,11 +870,11 @@ foperator_ge::op2_range (frange &r, tree type, switch (get_bool_state (r, lhs, type)) { case BRS_FALSE: - build_gt (r, type, op1.lower_bound ()); + build_gt (r, type, op1); break; case BRS_TRUE: - build_le (r, type, op1.upper_bound ()); + build_le (r, type, op1); r.clear_nan (); break;