From patchwork Fri Feb 3 18:09:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1737177 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=qoIAI3cD; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P7kFm3M5tz23gY for ; Sat, 4 Feb 2023 05:09:48 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9EA003858C5F for ; Fri, 3 Feb 2023 18:09:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9EA003858C5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675447785; bh=tPYiZ+DwY3J5KSleXoRFIY3wvQxWLHU1u9DrMUObjIE=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=qoIAI3cDp/M/ZkSGXyzPBlhuCTmvPZkwLncPturLpWq1f5/16Zpdr69wJGgP0xboh 7MykPyl0x8D1p/MpcYyG7KWtdQ2EL2E8sClo0EV3Lh/N/rD2sg3YXNNgbunVFWLta+ 83UC452rkDWPKTz5ztYKiXi7Yq+2bBGRkEuWGVic= 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 1C128385842D for ; Fri, 3 Feb 2023 18:09:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C128385842D 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-552-DNjq-ZHjNo-IAyI7jx1QLw-1; Fri, 03 Feb 2023 13:09:24 -0500 X-MC-Unique: DNjq-ZHjNo-IAyI7jx1QLw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 518851871CD6 for ; Fri, 3 Feb 2023 18:09:24 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD316140EBF4; Fri, 3 Feb 2023 18:09:23 +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 313I9LM6006580 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 3 Feb 2023 19:09:21 +0100 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 313I9L1B006579; Fri, 3 Feb 2023 19:09:21 +0100 To: Jakub Jelinek Cc: Andrew MacLeod , GCC patches , Aldy Hernandez Subject: [PATCH] range-ops: Handle undefined ranges in frange op[12]_range [PR108647] Date: Fri, 3 Feb 2023 19:09:18 +0100 Message-Id: <20230203180918.6417-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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_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: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch gracefully handles undefined operand ranges for the floating point op[12]_range operators. This is very low risk, as we would have ICEd otherwise. We don't have a testcase that ICEs for floating point ranges, but it's only a matter of time. Besides, this dovetails nicely with the integer versions Jakub is testing. Tested on x86-64 Linux. OK? gcc/ChangeLog: PR tree-optimization/108647 * range-op-float.cc (foperator_lt::op1_range): Handle undefined ranges. (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. (foperator_unordered_lt::op1_range): Same. (foperator_unordered_lt::op2_range): Same. (foperator_unordered_le::op1_range): Same. (foperator_unordered_le::op2_range): Same. (foperator_unordered_gt::op1_range): Same. (foperator_unordered_gt::op2_range): Same. (foperator_unordered_ge::op1_range): Same. (foperator_unordered_ge::op2_range): Same. --- gcc/range-op-float.cc | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 2db83aeb2fc..ff42b95de4f 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -866,6 +866,8 @@ foperator_lt::op1_range (frange &r, // The TRUE side of x < NAN is unreachable. if (op2.known_isnan ()) r.set_undefined (); + else if (op2.undefined_p ()) + return false; else if (build_lt (r, type, op2)) { r.clear_nan (); @@ -901,6 +903,8 @@ foperator_lt::op2_range (frange &r, // The TRUE side of NAN < x is unreachable. if (op1.known_isnan ()) r.set_undefined (); + else if (op1.undefined_p ()) + return false; else if (build_gt (r, type, op1)) { r.clear_nan (); @@ -982,6 +986,8 @@ foperator_le::op1_range (frange &r, // The TRUE side of x <= NAN is unreachable. if (op2.known_isnan ()) r.set_undefined (); + else if (op2.undefined_p ()) + return false; else if (build_le (r, type, op2)) r.clear_nan (); break; @@ -1013,6 +1019,8 @@ foperator_le::op2_range (frange &r, // The TRUE side of NAN <= x is unreachable. if (op1.known_isnan ()) r.set_undefined (); + else if (op1.undefined_p ()) + return false; else if (build_ge (r, type, op1)) r.clear_nan (); break; @@ -1021,6 +1029,8 @@ foperator_le::op2_range (frange &r, // On the FALSE side of NAN <= x, we know nothing about x. if (op1.known_isnan ()) r.set_varying (type); + else if (op1.undefined_p ()) + return false; else build_lt (r, type, op1); break; @@ -1090,6 +1100,8 @@ foperator_gt::op1_range (frange &r, // The TRUE side of x > NAN is unreachable. if (op2.known_isnan ()) r.set_undefined (); + else if (op2.undefined_p ()) + return false; else if (build_gt (r, type, op2)) { r.clear_nan (); @@ -1102,6 +1114,8 @@ foperator_gt::op1_range (frange &r, // On the FALSE side of x > NAN, we know nothing about x. if (op2.known_isnan ()) r.set_varying (type); + else if (op2.undefined_p ()) + return false; else build_le (r, type, op2); break; @@ -1125,6 +1139,8 @@ foperator_gt::op2_range (frange &r, // The TRUE side of NAN > x is unreachable. if (op1.known_isnan ()) r.set_undefined (); + else if (op1.undefined_p ()) + return false; else if (build_lt (r, type, op1)) { r.clear_nan (); @@ -1137,6 +1153,8 @@ foperator_gt::op2_range (frange &r, // On The FALSE side of NAN > x, we know nothing about x. if (op1.known_isnan ()) r.set_varying (type); + else if (op1.undefined_p ()) + return false; else build_ge (r, type, op1); break; @@ -1206,6 +1224,8 @@ foperator_ge::op1_range (frange &r, // The TRUE side of x >= NAN is unreachable. if (op2.known_isnan ()) r.set_undefined (); + else if (op2.undefined_p ()) + return false; else if (build_ge (r, type, op2)) r.clear_nan (); break; @@ -1214,6 +1234,8 @@ foperator_ge::op1_range (frange &r, // On the FALSE side of x >= NAN, we know nothing about x. if (op2.known_isnan ()) r.set_varying (type); + else if (op2.undefined_p ()) + return false; else build_lt (r, type, op2); break; @@ -1236,6 +1258,8 @@ foperator_ge::op2_range (frange &r, tree type, // The TRUE side of NAN >= x is unreachable. if (op1.known_isnan ()) r.set_undefined (); + else if (op1.undefined_p ()) + return false; else if (build_le (r, type, op1)) r.clear_nan (); break; @@ -1244,6 +1268,8 @@ foperator_ge::op2_range (frange &r, tree type, // On the FALSE side of NAN >= x, we know nothing about x. if (op1.known_isnan ()) r.set_varying (type); + else if (op1.undefined_p ()) + return false; else build_gt (r, type, op1); break; @@ -1592,6 +1618,8 @@ foperator_unordered_lt::op1_range (frange &r, tree type, case BRS_TRUE: if (op2.known_isnan ()) r.set_varying (type); + else if (op2.undefined_p ()) + return false; else build_lt (r, type, op2); break; @@ -1601,6 +1629,8 @@ foperator_unordered_lt::op1_range (frange &r, tree type, // impossible for op2 to be a NAN. if (op2.known_isnan ()) r.set_undefined (); + else if (op2.undefined_p ()) + return false; else if (build_ge (r, type, op2)) r.clear_nan (); break; @@ -1622,6 +1652,8 @@ foperator_unordered_lt::op2_range (frange &r, tree type, case BRS_TRUE: if (op1.known_isnan ()) r.set_varying (type); + else if (op1.undefined_p ()) + return false; else build_gt (r, type, op1); break; @@ -1631,6 +1663,8 @@ foperator_unordered_lt::op2_range (frange &r, tree type, // impossible for op1 to be a NAN. if (op1.known_isnan ()) r.set_undefined (); + else if (op1.undefined_p ()) + return false; else if (build_le (r, type, op1)) r.clear_nan (); break; @@ -1686,6 +1720,8 @@ foperator_unordered_le::op1_range (frange &r, tree type, case BRS_TRUE: if (op2.known_isnan ()) r.set_varying (type); + else if (op2.undefined_p ()) + return false; else build_le (r, type, op2); break; @@ -1717,6 +1753,8 @@ foperator_unordered_le::op2_range (frange &r, case BRS_TRUE: if (op1.known_isnan ()) r.set_varying (type); + else if (op1.undefined_p ()) + return false; else build_ge (r, type, op1); break; @@ -1726,6 +1764,8 @@ foperator_unordered_le::op2_range (frange &r, // impossible for op1 to be a NAN. if (op1.known_isnan ()) r.set_undefined (); + else if (op1.undefined_p ()) + return false; else if (build_lt (r, type, op1)) r.clear_nan (); break; @@ -1783,6 +1823,8 @@ foperator_unordered_gt::op1_range (frange &r, case BRS_TRUE: if (op2.known_isnan ()) r.set_varying (type); + else if (op2.undefined_p ()) + return false; else build_gt (r, type, op2); break; @@ -1792,6 +1834,8 @@ foperator_unordered_gt::op1_range (frange &r, // impossible for op2 to be a NAN. if (op2.known_isnan ()) r.set_undefined (); + else if (op2.undefined_p ()) + return false; else if (build_le (r, type, op2)) r.clear_nan (); break; @@ -1814,6 +1858,8 @@ foperator_unordered_gt::op2_range (frange &r, case BRS_TRUE: if (op1.known_isnan ()) r.set_varying (type); + else if (op1.undefined_p ()) + return false; else build_lt (r, type, op1); break; @@ -1823,6 +1869,8 @@ foperator_unordered_gt::op2_range (frange &r, // impossible for op1 to be a NAN. if (op1.known_isnan ()) r.set_undefined (); + else if (op1.undefined_p ()) + return false; else if (build_ge (r, type, op1)) r.clear_nan (); break; @@ -1880,6 +1928,8 @@ foperator_unordered_ge::op1_range (frange &r, case BRS_TRUE: if (op2.known_isnan ()) r.set_varying (type); + else if (op2.undefined_p ()) + return false; else build_ge (r, type, op2); break; @@ -1889,6 +1939,8 @@ foperator_unordered_ge::op1_range (frange &r, // impossible for op2 to be a NAN. if (op2.known_isnan ()) r.set_undefined (); + else if (op2.undefined_p ()) + return false; else if (build_lt (r, type, op2)) r.clear_nan (); break; @@ -1910,6 +1962,8 @@ foperator_unordered_ge::op2_range (frange &r, tree type, case BRS_TRUE: if (op1.known_isnan ()) r.set_varying (type); + else if (op1.undefined_p ()) + return false; else build_le (r, type, op1); break; @@ -1919,6 +1973,8 @@ foperator_unordered_ge::op2_range (frange &r, tree type, // impossible for op1 to be a NAN. if (op1.known_isnan ()) r.set_undefined (); + else if (op1.undefined_p ()) + return false; else if (build_gt (r, type, op1)) r.clear_nan (); break;