From patchwork Sat Jun 10 00:35:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 70852 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 494D838313AD for ; Sat, 10 Jun 2023 00:36:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 494D838313AD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357391; bh=z30wSZIXjci25pP/33Yryu3Zyhda91n754yHA10pwws=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=X+zAFGjUg30t+S9b7g4PnpcakS49UQyo7m/i/zYHhbi2Q3CnU25dldcJPkGKriO1v 5f4EmesP9Oi9nAK9thbC/dq7u6eR1gqV2W3at35rJsTkbT4xT5PO6EbmnfAiTcjLgA Sobt9Dj+v246NlbvY3gnSh/SMw+vHAnZoQXR54/Y= 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 22D7A3853D2E for ; Sat, 10 Jun 2023 00:35:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 22D7A3853D2E Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-416-FPeJDyWqPQ6aBHjvHu0SSg-1; Fri, 09 Jun 2023 20:35:04 -0400 X-MC-Unique: FPeJDyWqPQ6aBHjvHu0SSg-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-3f9e2f5a2b4so5309121cf.1 for ; Fri, 09 Jun 2023 17:35:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686357303; x=1688949303; 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=IaSMTR0kccsFCwr/zasK1Dx7v36PhqAPEwo84nu5ugg=; b=g3ktvrtsBRVxE4X8VK0TjcBz1MD2lFhMbvMSaoqcNdw99ek3vWcrusAnunbEm4HyhZ C2Vupbt0fFddlzu3tTyRXlctI5sE+qfVyLdC2ARxuANKjRe5owOVQvcWfiF1FTK+/EEh bvSrgDdRDI2QXWb3NXQKS3vIZmea9HxelksOy/66y+nvC0JFSr6SukS7ZwkZ516J0+eY W53n58bjYW8IwyZ9t9fQqd6zbllGryWBLUO+cVtslHLajZ5sZ4aYlW1iAoelS847y1rX +L8wC6faW1fvuocT5+p6pzdEkZulqi1EtpmY9/84ISGjN3ch00lJDjri1VR+MJxGCYUd ijWg== X-Gm-Message-State: AC+VfDyp80Cs2DE3AKoRlIou1LnPU6h2GnM3mLabmeE0XgDlRSYnukz6 H27rPwJq5L932m3LrWbSpbRV47Y6LY6DyMCDKeAorlcu74jnx3FeQ9whSh2KP/FC3+rsrtGV6wk /X089GA5gFX6A3pN1L/v2qBbKPV1uTgMstoTlDn03T+Alc9rQ+W7pt8DQCwIbN1BT92zFOgKfiV M9Zg== X-Received: by 2002:a05:622a:448:b0:3f2:31e:e783 with SMTP id o8-20020a05622a044800b003f2031ee783mr3254647qtx.50.1686357302960; Fri, 09 Jun 2023 17:35:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7M3PC5rHXE0HXtHvhYSb6MD8rhW64Iwnerz6Mcn39I+79qrte7izCa1LzRiWYBExTjYPjkJA== X-Received: by 2002:a05:622a:448:b0:3f2:31e:e783 with SMTP id o8-20020a05622a044800b003f2031ee783mr3254636qtx.50.1686357302694; Fri, 09 Jun 2023 17:35:02 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id cb5-20020a05622a1f8500b003e388264753sm1564008qtb.65.2023.06.09.17.35.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 17:35:02 -0700 (PDT) Message-ID: <08fec1b6-91e9-e7bc-3122-9529ebf1f862@redhat.com> Date: Fri, 9 Jun 2023 20:35:01 -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 7/15] Unify GE_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, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, 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 GE_EXPR the range operator Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed. Andrew From 364b936b8d82e86c73b2b964d4c8a2c16dcbedf8 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 9 Jun 2023 13:33:33 -0400 Subject: [PATCH 07/31] Unify GE_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_ge): Remove. Move prototypes to range-op-mixed.h (operator_ge::fold_range): Rename from foperator_ge. (operator_ge::op1_range): Ditto. (float_table::float_table): Remove GE_EXPR. * range-op-mixed.h (class operator_ge): Combined from integer and float files. * range-op.cc (op_ge): New object. (unified_table::unified_table): Add GE_EXPR. (class operator_ge): Move to range-op-mixed.h. (ge_op1_op2_relation): Fold into operator_ge::op1_op2_relation. (integral_table::integral_table): Remove GE_EXPR. (pointer_table::pointer_table): Remove GE_EXPR. * range-op.h (ge_op1_op2_relation): Delete. --- gcc/range-op-float.cc | 54 +++++++++++-------------------------------- gcc/range-op-mixed.h | 33 ++++++++++++++++++++++++++ gcc/range-op.cc | 39 +++++++------------------------ gcc/range-op.h | 3 --- 4 files changed, 55 insertions(+), 74 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 2f090e75245..4faca62c48f 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -1059,32 +1059,10 @@ operator_gt::op2_range (frange &r, return true; } -class foperator_ge : 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 ge_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_ge; - bool -foperator_ge::fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio rel) const +operator_ge::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_GE)) return true; @@ -1102,11 +1080,11 @@ foperator_ge::fold_range (irange &r, tree type, } bool -foperator_ge::op1_range (frange &r, - tree type, - const irange &lhs, - const frange &op2, - relation_trio) const +operator_ge::op1_range (frange &r, + tree type, + const irange &lhs, + const frange &op2, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -1137,10 +1115,10 @@ foperator_ge::op1_range (frange &r, } bool -foperator_ge::op2_range (frange &r, tree type, - const irange &lhs, - const frange &op1, - relation_trio) const +operator_ge::op2_range (frange &r, tree type, + const irange &lhs, + const frange &op1, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -1813,7 +1791,8 @@ public: op1_no_nan.clear_nan (); if (op2.maybe_isnan ()) op2_no_nan.clear_nan (); - if (!fop_ge.fold_range (r, type, op1_no_nan, op2_no_nan, rel)) + if (!range_op_handler (GE_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. @@ -2720,11 +2699,6 @@ float_table::float_table () set (OBJ_TYPE_REF, fop_identity); set (REAL_CST, fop_identity); - // All the relational operators are expected to work, because the - // calculation of ranges on outgoing edges expect the handlers to be - // present. - set (GE_EXPR, fop_ge); - set (ABS_EXPR, fop_abs); set (NEGATE_EXPR, fop_negate); set (PLUS_EXPR, fop_plus); diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 1c68d54b085..d6cd3683932 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -235,4 +235,37 @@ public: relation_kind op1_op2_relation (const irange &lhs) const final override; void update_bitmask (irange &r, const irange &lh, const irange &rh) const; }; + +class operator_ge : 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 e971bf4cd33..a127da22006 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -67,6 +67,7 @@ operator_not_equal op_not_equal; operator_lt op_lt; operator_le op_le; operator_gt op_gt; +operator_ge op_ge; // Invoke the initialization routines for each class of range. @@ -81,6 +82,7 @@ unified_table::unified_table () set (LT_EXPR, op_lt); set (LE_EXPR, op_le); set (GT_EXPR, op_gt); + set (GE_EXPR, op_ge); } // The tables are hidden and accessed via a simple extern function. @@ -1388,34 +1390,17 @@ operator_gt::op2_range (irange &r, tree type, } -class operator_ge : public range_operator +void +operator_ge::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, GE_EXPR, lh, rh); } -} op_ge; + update_known_bitmask (r, GE_EXPR, lh, rh); +} // Check if the LHS range indicates a relation between OP1 and OP2. relation_kind -ge_op1_op2_relation (const irange &lhs) +operator_ge::op1_op2_relation (const irange &lhs) const { if (lhs.undefined_p ()) return VREL_UNDEFINED; @@ -1430,12 +1415,6 @@ ge_op1_op2_relation (const irange &lhs) return VREL_VARYING; } -relation_kind -operator_ge::op1_op2_relation (const irange &lhs) const -{ - return ge_op1_op2_relation (lhs); -} - bool operator_ge::fold_range (irange &r, tree type, const irange &op1, @@ -4783,7 +4762,6 @@ pointer_or_operator::wi_fold (irange &r, tree type, integral_table::integral_table () { - set (GE_EXPR, op_ge); set (PLUS_EXPR, op_plus); set (MINUS_EXPR, op_minus); set (MIN_EXPR, op_min); @@ -4832,7 +4810,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (GE_EXPR, op_ge); set (SSA_NAME, op_ident); set (INTEGER_CST, op_integer_cst); set (ADDR_EXPR, op_addr); diff --git a/gcc/range-op.h b/gcc/range-op.h index 411ab5e4a0a..20a77e1165e 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -265,9 +265,6 @@ extern void wi_set_zero_nonzero_bits (tree type, wide_int &maybe_nonzero, wide_int &mustbe_nonzero); -// op1_op2_relation methods that are the same across irange and frange. -relation_kind ge_op1_op2_relation (const irange &lhs); - // This implements the range operator tables as local objects. class range_op_table -- 2.40.1