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 67E0F3857361 for ; Tue, 11 Oct 2022 13:51:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 67E0F3857361 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=1665496316; 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: in-reply-to:in-reply-to:references:references; bh=Py0uMyUmkeQv6pC1yYlyv8x04MejOG2YOV7I0iIP4cc=; b=VVR5c/PQ8m2eS+5WFrPvFpgeLoBLvo3uqDelT0RE+Go5qpk1VgHWdwhAl+2jkFnPFaMySx Ry7pR4eBQGcosz5uo86HqZTKMBt0YD4Kf+Y1gRdRhfSvJEO8U5lT2BEEcHOW7j6/MbjGgt V04NJiYrhxv9Qo7m6od+6x0iKIfdzHk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-298-TibfCmxVPeiP_at52kPIVQ-1; Tue, 11 Oct 2022 09:51:54 -0400 X-MC-Unique: TibfCmxVPeiP_at52kPIVQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 835713C138A4 for ; Tue, 11 Oct 2022 13:51:54 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.194.162]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2609EC8E405; Tue, 11 Oct 2022 13:51:53 +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 29BDpqA3369685 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 11 Oct 2022 15:51:52 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 29BDpqIe369684; Tue, 11 Oct 2022 15:51:52 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] Implement op1_range operators for unordered comparisons. Date: Tue, 11 Oct 2022 15:51:35 +0200 Message-Id: <20221011135136.369644-3-aldyh@redhat.com> In-Reply-To: <20221011135136.369644-1-aldyh@redhat.com> References: <20221011135136.369644-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=-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,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: gcc/ChangeLog: * range-op-float.cc (foperator_unordered_le::op1_range): New. (foperator_unordered_le::op2_range): New. (foperator_unordered_gt::op1_range): New. (foperator_unordered_gt::op2_range): New. (foperator_unordered_ge::op1_range): New. (foperator_unordered_ge::op2_range): New. (foperator_unordered_equal::op1_range): New. --- gcc/range-op-float.cc | 205 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 8dd4bcc70c0..ef51b7538e3 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -1162,6 +1162,8 @@ public: class foperator_unordered_le : public range_operator_float { using range_operator_float::fold_range; + using range_operator_float::op1_range; + using range_operator_float::op2_range; public: bool fold_range (irange &r, tree type, const frange &op1, const frange &op2, @@ -1184,11 +1186,65 @@ public: return true; } } + bool op1_range (frange &r, tree type, + const irange &lhs, const frange &op2, + relation_kind rel) const final override; + bool op2_range (frange &r, tree type, + const irange &lhs, const frange &op1, + relation_kind rel) const final override; } fop_unordered_le; +bool +foperator_unordered_le::op1_range (frange &r, tree type, + const irange &lhs, const frange &op2, + relation_kind) const +{ + switch (get_bool_state (r, lhs, type)) + { + case BRS_TRUE: + build_le (r, type, op2); + break; + + case BRS_FALSE: + build_gt (r, type, op2); + r.clear_nan (); + break; + + default: + break; + } + return true; +} + +bool +foperator_unordered_le::op2_range (frange &r, + tree type, + const irange &lhs, + const frange &op1, + relation_kind) const +{ + switch (get_bool_state (r, lhs, type)) + { + case BRS_TRUE: + build_ge (r, type, op1); + break; + + case BRS_FALSE: + build_lt (r, type, op1); + r.clear_nan (); + break; + + default: + break; + } + return true; +} + class foperator_unordered_gt : public range_operator_float { using range_operator_float::fold_range; + using range_operator_float::op1_range; + using range_operator_float::op2_range; public: bool fold_range (irange &r, tree type, const frange &op1, const frange &op2, @@ -1211,11 +1267,67 @@ public: return true; } } + bool op1_range (frange &r, tree type, + const irange &lhs, const frange &op2, + relation_kind rel) const final override; + bool op2_range (frange &r, tree type, + const irange &lhs, const frange &op1, + relation_kind rel) const final override; } fop_unordered_gt; +bool +foperator_unordered_gt::op1_range (frange &r, + tree type, + const irange &lhs, + const frange &op2, + relation_kind) const +{ + switch (get_bool_state (r, lhs, type)) + { + case BRS_TRUE: + build_gt (r, type, op2); + break; + + case BRS_FALSE: + build_le (r, type, op2); + r.clear_nan (); + break; + + default: + break; + } + return true; +} + +bool +foperator_unordered_gt::op2_range (frange &r, + tree type, + const irange &lhs, + const frange &op1, + relation_kind) const +{ + switch (get_bool_state (r, lhs, type)) + { + case BRS_TRUE: + build_lt (r, type, op1); + break; + + case BRS_FALSE: + build_ge (r, type, op1); + r.clear_nan (); + break; + + default: + break; + } + return true; +} + class foperator_unordered_ge : public range_operator_float { using range_operator_float::fold_range; + using range_operator_float::op1_range; + using range_operator_float::op2_range; public: bool fold_range (irange &r, tree type, const frange &op1, const frange &op2, @@ -1238,11 +1350,66 @@ public: return true; } } + bool op1_range (frange &r, tree type, + const irange &lhs, const frange &op2, + relation_kind rel) const final override; + bool op2_range (frange &r, tree type, + const irange &lhs, const frange &op1, + relation_kind rel) const final override; } fop_unordered_ge; +bool +foperator_unordered_ge::op1_range (frange &r, + tree type, + const irange &lhs, + const frange &op2, + relation_kind) const +{ + switch (get_bool_state (r, lhs, type)) + { + case BRS_TRUE: + build_ge (r, type, op2); + break; + + case BRS_FALSE: + build_lt (r, type, op2); + r.clear_nan (); + break; + + default: + break; + } + return true; +} + +bool +foperator_unordered_ge::op2_range (frange &r, tree type, + const irange &lhs, + const frange &op1, + relation_kind) const +{ + switch (get_bool_state (r, lhs, type)) + { + case BRS_TRUE: + build_le (r, type, op1); + break; + + case BRS_FALSE: + build_gt (r, type, op1); + r.clear_nan (); + break; + + default: + break; + } + return true; +} + class foperator_unordered_equal : public range_operator_float { using range_operator_float::fold_range; + using range_operator_float::op1_range; + using range_operator_float::op2_range; public: bool fold_range (irange &r, tree type, const frange &op1, const frange &op2, @@ -1265,8 +1432,46 @@ public: return true; } } + bool op1_range (frange &r, tree type, + const irange &lhs, const frange &op2, + relation_kind rel) const final override; + bool op2_range (frange &r, tree type, + const irange &lhs, const frange &op1, + relation_kind rel) const final override + { + return op1_range (r, type, lhs, op1, rel); + } } fop_unordered_equal; +bool +foperator_unordered_equal::op1_range (frange &r, tree type, + const irange &lhs, + const frange &op2, + relation_kind) const +{ + switch (get_bool_state (r, lhs, type)) + { + case BRS_TRUE: + // If it's true, the result is the same as OP2 plus a NAN. + r = op2; + // Add both zeros if there's the possibility of zero equality. + frange_add_zeros (r, type); + // Add the posibility of a NAN. + r.update_nan (); + 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 (); + break; + + default: + break; + } + return true; +} // Instantiate a range_op_table for floating point operations. static floating_op_table global_floating_table; -- 2.37.3