From patchwork Sat Jun 10 00:34:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 70848 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 479D53853D0F for ; Sat, 10 Jun 2023 00:35:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 479D53853D0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357305; bh=ymRJ2Q8lL6s1fr/qKcVWwadx9usvrPqPVMq7c5GlK/I=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=H5dfeSbKrcYGrWUWIc532XYB4hJjo1eYmZXb6Sc9JSm9KOhrBJ1m8v+8uTSN5Pyfx Egp6cD+l/H2lkds4NQ8pq8LUrcClJaoFs0HFClks3XxdYKJrfiwa9n/fKNWJvoeu4+ AouEPoD+Ukc325YKnSgomIUw3rcW8quvrekH8zUs= 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 9082E3858D3C for ; Sat, 10 Jun 2023 00:34:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9082E3858D3C Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-465-cxJKWqhPPvOtYHUSHZN7Hg-1; Fri, 09 Jun 2023 20:34:23 -0400 X-MC-Unique: cxJKWqhPPvOtYHUSHZN7Hg-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-75d0a182bdfso329440485a.3 for ; Fri, 09 Jun 2023 17:34:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686357262; x=1688949262; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HIo0vJUA8jbjFL9E6R+uJ7gn/dh7YOykOyKlDQPbZGo=; b=adRLoKYvd9epg0mBAc5QvsdeuLPzKD/fnyLTogoG5hydYb1BuBVeAfh5LwFpd0mmO3 ucbZuAC1S8K4gbcX1aweCzljY2UQ9WXX9iS/gUdwqtstet5Bub43aVF9lSzU5BY/8pqc hX2XgT9eCDNd29h5Y60zQL4xoZVUloy1cx3liGS+ygSdlqYhZCmNZd3gXINYG9IUshj8 MmjxcjA1TPidVT8B44UTxZTW5GdqZYhChBd7dyfzxFPyKKzjBv2jfTNv6vBsS7FXlylb zkc8evehfpLAgl5agD8VnrgFnMyMRUD6ukY51+R2hz4+yn0/ZnVYtGzHKDrYNtL2chcq IAPg== X-Gm-Message-State: AC+VfDxgo6oTBPhY0+Uc2IGeBEfN4qZZ0ZvLtnvGHG1S1Gz8gPQi5xLR 4xAxWO91AOzshKdUF2rSCsB3wiCFmzozL3rjtaC4E/PSxeU1V3GHyqGUDtivYjXuCcnKXz/9p1c Bs0mi/mGLapCBHpgYZmooOQ+1IlGBoveNKd+ZTQx33suPVJRP/o4Hei4uVBzIkDpyVF8R8lKghu fAvQ== X-Received: by 2002:a05:620a:2454:b0:75b:23a0:de9b with SMTP id h20-20020a05620a245400b0075b23a0de9bmr3693120qkn.25.1686357262790; Fri, 09 Jun 2023 17:34:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7StHytCOJwym/vhnO95v4TykHwjzeVtg77pWcmitVIPBcWHYDcQB2c3oTwLJyTAucHNvzvbA== X-Received: by 2002:a05:620a:2454:b0:75b:23a0:de9b with SMTP id h20-20020a05620a245400b0075b23a0de9bmr3693106qkn.25.1686357262451; Fri, 09 Jun 2023 17:34:22 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id s27-20020a05620a031b00b007592f2016f4sm1367473qkm.110.2023.06.09.17.34.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 17:34:22 -0700 (PDT) Message-ID: <84ed3426-9b27-e0e1-d20a-ad9ce8224e03@redhat.com> Date: Fri, 9 Jun 2023 20:34:21 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: gcc-patches Cc: "hernandez, aldy" Subject: [COMMITTED 4/15] Unify LT_EXPR range operator X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.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, 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: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Unify the LT_EXPR opcode Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed. Andrew From f7c1366a89edf1ffdd9c495cff544358f2ff395e Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 9 Jun 2023 13:29:15 -0400 Subject: [PATCH 04/31] Unify LT_EXPR range operator Move the declaration of the class to the range-op-mixed header, add the floating point prototypes as well, and use it in the new unified table. * range-op-float.cc (foperator_lt): Remove. Move prototypes to range-op-mixed.h (operator_lt::fold_range): Rename from foperator_lt. (operator_lt::op1_range): Ditto. (float_table::float_table): Remove LT_EXPR. * range-op-mixed.h (class operator_lt): Combined from integer and float files. * range-op.cc (op_lt): New object. (unified_table::unified_table): Add LT_EXPR. (class operator_lt): Move to range-op-mixed.h. (lt_op1_op2_relation): Fold into operator_lt::op1_op2_relation. (integral_table::integral_table): Remove LT_EXPR. (pointer_table::pointer_table): Remove LT_EXPR. * range-op.h (lt_op1_op2_relation): Delete. --- gcc/range-op-float.cc | 52 +++++++++++++------------------------------ gcc/range-op-mixed.h | 30 +++++++++++++++++++++++++ gcc/range-op.cc | 39 +++++++------------------------- gcc/range-op.h | 1 - 4 files changed, 53 insertions(+), 69 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index ec24167a8c5..1b0ac9a7fc2 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -779,32 +779,10 @@ operator_not_equal::op1_range (frange &r, tree type, return true; } -class foperator_lt : public range_operator -{ - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - bool fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio = TRIO_VARYING) const final override; - relation_kind op1_op2_relation (const irange &lhs) const final override - { - return lt_op1_op2_relation (lhs); - } - bool op1_range (frange &r, tree type, - const irange &lhs, const frange &op2, - relation_trio = TRIO_VARYING) const final override; - bool op2_range (frange &r, tree type, - const irange &lhs, const frange &op1, - relation_trio = TRIO_VARYING) const final override; -} fop_lt; - bool -foperator_lt::fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio rel) const +operator_lt::fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio rel) const { if (frelop_early_resolve (r, type, op1, op2, rel, VREL_LT)) return true; @@ -822,11 +800,11 @@ foperator_lt::fold_range (irange &r, tree type, } bool -foperator_lt::op1_range (frange &r, - tree type, - const irange &lhs, - const frange &op2, - relation_trio) const +operator_lt::op1_range (frange &r, + tree type, + const irange &lhs, + const frange &op2, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -859,11 +837,11 @@ foperator_lt::op1_range (frange &r, } bool -foperator_lt::op2_range (frange &r, - tree type, - const irange &lhs, - const frange &op1, - relation_trio) const +operator_lt::op2_range (frange &r, + tree type, + const irange &lhs, + const frange &op1, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -1547,7 +1525,8 @@ public: op1_no_nan.clear_nan (); if (op2.maybe_isnan ()) op2_no_nan.clear_nan (); - if (!fop_lt.fold_range (r, type, op1_no_nan, op2_no_nan, rel)) + if (!range_op_handler (LT_EXPR).fold_range (r, type, op1_no_nan, + op2_no_nan, rel)) return false; // The result is the same as the ordered version when the // comparison is true or when the operands cannot be NANs. @@ -2786,7 +2765,6 @@ float_table::float_table () // All the relational operators are expected to work, because the // calculation of ranges on outgoing edges expect the handlers to be // present. - set (LT_EXPR, fop_lt); set (LE_EXPR, fop_le); set (GT_EXPR, fop_gt); set (GE_EXPR, fop_ge); diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 03a988d9c8a..bc93ab5be06 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -141,4 +141,34 @@ public: void update_bitmask (irange &r, const irange &lh, const irange &rh) const final override; }; + +class operator_lt : public range_operator +{ +public: + using range_operator::fold_range; + using range_operator::op1_range; + using range_operator::op2_range; + using range_operator::op1_op2_relation; + bool fold_range (irange &r, tree type, + const irange &op1, const irange &op2, + relation_trio = TRIO_VARYING) const final override; + bool fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio = TRIO_VARYING) const final override; + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio = TRIO_VARYING) const final override; + bool op1_range (frange &r, tree type, + const irange &lhs, const frange &op2, + relation_trio = TRIO_VARYING) const final override; + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &op1, + relation_trio = TRIO_VARYING) const final override; + bool op2_range (frange &r, tree type, + const irange &lhs, const frange &op1, + relation_trio = TRIO_VARYING) const final override; + relation_kind op1_op2_relation (const irange &lhs) const final override; + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override; +}; #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 1bea4af101d..13877999847 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -64,6 +64,7 @@ class unified_table : public range_op_table operator_equal op_equal; operator_not_equal op_not_equal; +operator_lt op_lt; // Invoke the initialization routines for each class of range. @@ -75,6 +76,7 @@ unified_table::unified_table () set (EQ_EXPR, op_equal); set (NE_EXPR, op_not_equal); + set (LT_EXPR, op_lt); } // The tables are hidden and accessed via a simple extern function. @@ -1090,34 +1092,17 @@ build_ge (irange &r, tree type, const wide_int &val) } -class operator_lt : public range_operator +void +operator_lt::update_bitmask (irange &r, const irange &lh, + const irange &rh) const { - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - virtual bool fold_range (irange &r, tree type, - const irange &op1, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio = TRIO_VARYING) const; - virtual relation_kind op1_op2_relation (const irange &lhs) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, LT_EXPR, lh, rh); } -} op_lt; + update_known_bitmask (r, LT_EXPR, lh, rh); +} // Check if the LHS range indicates a relation between OP1 and OP2. relation_kind -lt_op1_op2_relation (const irange &lhs) +operator_lt::op1_op2_relation (const irange &lhs) const { if (lhs.undefined_p ()) return VREL_UNDEFINED; @@ -1132,12 +1117,6 @@ lt_op1_op2_relation (const irange &lhs) return VREL_VARYING; } -relation_kind -operator_lt::op1_op2_relation (const irange &lhs) const -{ - return lt_op1_op2_relation (lhs); -} - bool operator_lt::fold_range (irange &r, tree type, const irange &op1, @@ -4847,7 +4826,6 @@ pointer_or_operator::wi_fold (irange &r, tree type, integral_table::integral_table () { - set (LT_EXPR, op_lt); set (LE_EXPR, op_le); set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); @@ -4899,7 +4877,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (LT_EXPR, op_lt); set (LE_EXPR, op_le); set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); diff --git a/gcc/range-op.h b/gcc/range-op.h index 8ab5f414147..df1d8871b53 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -266,7 +266,6 @@ extern void wi_set_zero_nonzero_bits (tree type, wide_int &mustbe_nonzero); // op1_op2_relation methods that are the same across irange and frange. -relation_kind lt_op1_op2_relation (const irange &lhs); relation_kind le_op1_op2_relation (const irange &lhs); relation_kind gt_op1_op2_relation (const irange &lhs); relation_kind ge_op1_op2_relation (const irange &lhs); -- 2.40.1