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 B3428385084D for ; Thu, 20 Oct 2022 14:14:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B3428385084D 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=1666275259; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sTVTfVhQcKjzMmkNEGHmg4qV+1hyVrtzt+T2Nv4yqXM=; b=Q66kqG2GR+2qaaFjge8zb7zBUXRLfx9jENbfEW1mZwzrTTzXCyfNJifcTF0nNna65heETx wamlB2wbbHsmeCxHvH8gVbuRYaDRwHqMLIxVaJfy0HM5L5m4jRTz8/dueuGRXeYD+HN4JU CLahw86WTNXi0FihKLwGaDtDWmxyhuc= 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-584-_dasZna6O_WnYudtNwNsEQ-1; Thu, 20 Oct 2022 10:14:18 -0400 X-MC-Unique: _dasZna6O_WnYudtNwNsEQ-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 46E6A806002 for ; Thu, 20 Oct 2022 14:14:08 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 972DC40C6E16; Thu, 20 Oct 2022 14:13:54 +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 29KEDobH229266 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 16:13:50 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 29KEDeNe228827; Thu, 20 Oct 2022 16:13:40 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] Replace finite_operands_p with maybe_isnan. Date: Thu, 20 Oct 2022 16:13:35 +0200 Message-Id: <20221020141336.228799-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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.6 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 List-Id: The finite_operands_p function was incorrectly named, as it only returned TRUE when !NAN. This was leftover from the initial implementation of frange. Using the maybe_isnan() nomenclature is more consistent and easier to understand. gcc/ChangeLog: * range-op-float.cc (finite_operand_p): Remove. (finite_operands_p): Rename to... (maybe_isnan): ...this. (frelop_early_resolve): Use maybe_isnan instead of finite_operands_p. (foperator_equal::fold_range): Same. (foperator_equal::op1_range): Same. (foperator_not_equal::fold_range): Same. (foperator_lt::fold_range): Same. (foperator_le::fold_range): Same. (foperator_gt::fold_range): Same. (foperator_ge::fold_range): Same. --- gcc/range-op-float.cc | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 0605a908684..2a4a99ba467 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -166,20 +166,15 @@ range_operator_float::op1_op2_relation (const frange &lhs ATTRIBUTE_UNUSED) cons return VREL_VARYING; } -// Return TRUE if OP1 is known to be free of NANs. +// Return TRUE if OP1 and OP2 may be a NAN. static inline bool -finite_operand_p (const frange &op1) +maybe_isnan (const frange &op1, const frange &op2) { - return flag_finite_math_only || !op1.maybe_isnan (); -} - -// Return TRUE if OP1 and OP2 are known to be free of NANs. + if (flag_finite_math_only) + return false; -static inline bool -finite_operands_p (const frange &op1, const frange &op2) -{ - return flag_finite_math_only || (!op1.maybe_isnan () && !op2.maybe_isnan ()); + return op1.maybe_isnan () || op2.maybe_isnan (); } // Floating version of relop_early_resolve that takes into account NAN @@ -196,7 +191,7 @@ frelop_early_resolve (irange &r, tree type, // We can fold relations from the oracle when we know both operands // are free of NANs, or when -ffinite-math-only. - return (finite_operands_p (op1, op2) + return (!maybe_isnan (op1, op2) && relop_early_resolve (r, type, op1, op2, rel, my_rel)); } @@ -391,7 +386,7 @@ foperator_equal::fold_range (irange &r, tree type, else r = range_false (type); } - else if (finite_operands_p (op1, op2)) + else if (!maybe_isnan (op1, op2)) { // If ranges do not intersect, we know the range is not equal, // otherwise we don't know anything for sure. @@ -441,7 +436,7 @@ foperator_equal::op1_range (frange &r, tree type, // If the result is false, the only time we know anything is // if OP2 is a constant. else if (op2.singleton_p () - || (finite_operand_p (op2) && op2.zero_p ())) + || (!op2.maybe_isnan () && op2.zero_p ())) { REAL_VALUE_TYPE tmp = op2.lower_bound (); r.set (type, tmp, tmp, VR_ANTI_RANGE); @@ -494,7 +489,7 @@ foperator_not_equal::fold_range (irange &r, tree type, else r = range_false (type); } - else if (finite_operands_p (op1, op2)) + else if (!maybe_isnan (op1, op2)) { // If ranges do not intersect, we know the range is not equal, // otherwise we don't know anything for sure. @@ -590,7 +585,7 @@ foperator_lt::fold_range (irange &r, tree type, if (op1.known_isnan () || op2.known_isnan ()) r = range_false (type); - else if (finite_operands_p (op1, op2)) + else if (!maybe_isnan (op1, op2)) { if (real_less (&op1.upper_bound (), &op2.lower_bound ())) r = range_true (type); @@ -706,7 +701,7 @@ foperator_le::fold_range (irange &r, tree type, if (op1.known_isnan () || op2.known_isnan ()) r = range_false (type); - else if (finite_operands_p (op1, op2)) + else if (!maybe_isnan (op1, op2)) { if (real_compare (LE_EXPR, &op1.upper_bound (), &op2.lower_bound ())) r = range_true (type); @@ -814,7 +809,7 @@ foperator_gt::fold_range (irange &r, tree type, if (op1.known_isnan () || op2.known_isnan ()) r = range_false (type); - else if (finite_operands_p (op1, op2)) + else if (!maybe_isnan (op1, op2)) { if (real_compare (GT_EXPR, &op1.lower_bound (), &op2.upper_bound ())) r = range_true (type); @@ -930,7 +925,7 @@ foperator_ge::fold_range (irange &r, tree type, if (op1.known_isnan () || op2.known_isnan ()) r = range_false (type); - else if (finite_operands_p (op1, op2)) + else if (!maybe_isnan (op1, op2)) { if (real_compare (GE_EXPR, &op1.lower_bound (), &op2.upper_bound ())) r = range_true (type); @@ -1302,7 +1297,7 @@ public: return false; // The result is the same as the ordered version when the // comparison is true or when the operands cannot be NANs. - if (finite_operands_p (op1, op2) || r == range_true (type)) + if (!maybe_isnan (op1, op2) || r == range_true (type)) return true; else { @@ -1331,7 +1326,7 @@ public: return false; // The result is the same as the ordered version when the // comparison is true or when the operands cannot be NANs. - if (finite_operands_p (op1, op2) || r == range_true (type)) + if (!maybe_isnan (op1, op2) || r == range_true (type)) return true; else { @@ -1412,7 +1407,7 @@ public: return false; // The result is the same as the ordered version when the // comparison is true or when the operands cannot be NANs. - if (finite_operands_p (op1, op2) || r == range_true (type)) + if (!maybe_isnan (op1, op2) || r == range_true (type)) return true; else { @@ -1495,7 +1490,7 @@ public: return false; // The result is the same as the ordered version when the // comparison is true or when the operands cannot be NANs. - if (finite_operands_p (op1, op2) || r == range_true (type)) + if (!maybe_isnan (op1, op2) || r == range_true (type)) return true; else { @@ -1577,7 +1572,7 @@ public: return false; // The result is the same as the ordered version when the // comparison is true or when the operands cannot be NANs. - if (finite_operands_p (op1, op2) || r == range_true (type)) + if (!maybe_isnan (op1, op2) || r == range_true (type)) return true; else { -- 2.37.3