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.129.124]) by sourceware.org (Postfix) with ESMTPS id CC2E83858D28 for ; Mon, 28 Aug 2023 06:17:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CC2E83858D28 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=1693203429; 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=/hkunlrTNxWuPlhfNfqqVyrjW8uyaDmjugFVzsQb5Ow=; b=DldFax9Z7hkDyUQ9WJBfnEoh9Ok+Y48zhl/SpwEucqumcVVBSIAyp90igfnitUWV3c5Ycx yTiGrI/ck4l1bh6e88LUS1uHaL882nW8O24+SPolhcxBCpvYxuEZ+1u2sfSnleu+21dEzv lWh9M1zfr8DoAT65HBc52HEDXqLn8hE= 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-195-9tizHfsmPauPfFzWfwB6bQ-1; Mon, 28 Aug 2023 02:17:07 -0400 X-MC-Unique: 9tizHfsmPauPfFzWfwB6bQ-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 562A580006E for ; Mon, 28 Aug 2023 06:17:07 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.178]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A11FC15E6A; Mon, 28 Aug 2023 06:17:06 +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 37S6H5A4466540 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 28 Aug 2023 08:17:05 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 37S6H5G4466539; Mon, 28 Aug 2023 08:17:05 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Jakub Jelinek , Aldy Hernandez Subject: [COMMITTED] [frange] Handle relations in LTGT_EXPR. Date: Mon, 28 Aug 2023 08:16:31 +0200 Message-ID: <20230828061701.466521-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=-11.4 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_H4,RCVD_IN_MSPIKE_WL,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: LTGT_EXPR hasn't been handling relations, especially with NANs as a possibility. This handles them while documenting how relations work in a world with NANs. Basically we need to special case VREL_EQ before calling frelop_early_resolve. Note that VREL_EQ on entry to a range-op entry is really VREL_EQ U NAN, but to make sure about the NAN possibility, one must look at the operands. However, even VREL_EQ U NAN is false for LTGT_EXPR since the latter is just NE_EXPR without a NAN. After we handle VREL_EQ, we drop down to frelop_early_resolve pretending to be a NE_EXPR, and everything should just map correctly. 2023-08-28 Aldy Hernandez * range-op-float.cc (fold_range): Handle relations. --- gcc/range-op-float.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 14199647744..eebc73f9918 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -2204,8 +2204,23 @@ class foperator_ltgt : public range_operator public: bool fold_range (irange &r, tree type, const frange &op1, const frange &op2, - relation_trio rel = TRIO_VARYING) const final override + relation_trio trio = TRIO_VARYING) const final override { + relation_kind rel = trio.op1_op2 (); + + // VREL_EQ is really VREL_(UN)EQ because we could have a NAN in + // the operands, but since LTGT_EXPR is really a NE_EXPR without + // the NAN, VREL_EQ & LTGT_EXPR is an impossibility. + if (rel == VREL_EQ) + { + r = range_false (type); + return true; + } + // ...otherwise pretend we're trying to resolve a NE_EXPR and + // everything will "just work". + if (frelop_early_resolve (r, type, op1, op2, trio, VREL_NE)) + return true; + if (op1.known_isnan () || op2.known_isnan ()) { r = range_false (type); @@ -2218,7 +2233,7 @@ public: if (op2.maybe_isnan ()) op2_no_nan.clear_nan (); if (!range_op_handler (NE_EXPR).fold_range (r, type, op1_no_nan, - op2_no_nan, rel)) + op2_no_nan, trio)) return false; // The result is the same as the ordered version when the // comparison is true or when the operands cannot be NANs. -- 2.41.0