From patchwork Sat Jun 10 00:34:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793263 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=2620:52:3:1:0:246e:9693:128c; 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=lYJlgEQy; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4QdJvr2l3Gz20Vx for ; Sat, 10 Jun 2023 10:38:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 487A8382798A for ; Sat, 10 Jun 2023 00:38:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 487A8382798A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357494; bh=yv7SsJSYN/j0UCqTfwnp14bhkMmdDmtMyTgrOCWxpMY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lYJlgEQyyAVBGa/UmoRy5XyTNvcKLLEy7Gm3Pe4J3Uo3PJfg/5KMA7oartFg7C69c IzK1zVOp/i2OcQRR6m96/ldE/rZfanhYTWOWLOOOk6ps1x8IOW45VZdZPKvVNV75Fo vV0a5/AmTMjAfnw8HspQuWbgAyc+8S2Fm766GfsM= 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 0B42C3854E5F for ; Sat, 10 Jun 2023 00:34:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B42C3854E5F Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-oyLeZoHaMvmSXliO3FXgpg-1; Fri, 09 Jun 2023 20:34:50 -0400 X-MC-Unique: oyLeZoHaMvmSXliO3FXgpg-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-3f9a53add26so19595231cf.0 for ; Fri, 09 Jun 2023 17:34:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686357289; x=1688949289; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=u1D3qLB9iMen2OSCPUekgtnxMFOFomuGkeNxOcMJYWY=; b=dMfkLv8tuQbkjuFrqDgTFpkkAEy/Mxfkaxuet9PkWmPk/BULbfIF/OmLELecW8H+pe 0cp3d66o84gbWbaNLp4Tm4BArymv8RKOGzYZxqC/lpMcPFtXAhTsL2o8ZuPNi+H1KaJP jvKToqmXo03FU681ayTzbWWFCwPlbHDWZTefDZE34XHHpmTtK4PAlK9yn9K2xpGJh6Mu xneMu6jHYQIXxVewuO079cazn8NX8lb+g1h4Kp8ndfSBTLVJsG/lyet0A5275U/yO7Oh T1zEeJ3n2s5MjIOx/bWDdZLxrZyy0bQEI3IXLos8xZsRrN0hq0NcksDw92H3N7q3u29R mr2Q== X-Gm-Message-State: AC+VfDy9eWfpNonBlgtdNcpic9LXpAIasybrx3U2ncdsbUn5vzXyAKAh jgcCbUvxME7/zj+M81C+souvL3NCmOydRwyAF1siadNVG9+/yNlRiSawLqCUD0TVDfcbx+NPxGR iK1ZSV12wDVI3COBs0IKvfuI2kUYgoSbwSMMq3RIjo5WfHd2qpVlCgPi6bQNgH/eo4xHDzpjRhh HHBg== X-Received: by 2002:a05:622a:508:b0:3f5:713:adb4 with SMTP id l8-20020a05622a050800b003f50713adb4mr4220493qtx.18.1686357289336; Fri, 09 Jun 2023 17:34:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7vqsYBm8jyiSPOMDY3rp14XxJkW1ZdcuPKif0D/Wj4//2N6HFcyKskEAiT2NJCC1BPDEP4Nw== X-Received: by 2002:a05:622a:508:b0:3f5:713:adb4 with SMTP id l8-20020a05622a050800b003f50713adb4mr4220484qtx.18.1686357289012; Fri, 09 Jun 2023 17:34:49 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id i6-20020ac84886000000b003f6bbd7863csm1545227qtq.86.2023.06.09.17.34.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 17:34:48 -0700 (PDT) Message-ID: <2d656c9e-010c-53c3-874e-5a409f7681a8@redhat.com> Date: Fri, 9 Jun 2023 20:34:47 -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 , "hernandez, aldy" Subject: [COMMITTED 6/15] Unify GT_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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Unify GT_EXPR theĀ  range operator Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed. Andrew From e5a4bb7c12d00926e0c7bbf0c77dd1be8f23a39a Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 9 Jun 2023 13:32:25 -0400 Subject: [PATCH 06/31] Unify GT_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_gt): Remove. Move prototypes to range-op-mixed.h (operator_gt::fold_range): Rename from foperator_gt. (operator_gt::op1_range): Ditto. (float_table::float_table): Remove GT_EXPR. * range-op-mixed.h (class operator_gt): Combined from integer and float files. * range-op.cc (op_gt): New object. (unified_table::unified_table): Add GT_EXPR. (class operator_gt): Move to range-op-mixed.h. (gt_op1_op2_relation): Fold into operator_gt::op1_op2_relation. (integral_table::integral_table): Remove GT_EXPR. (pointer_table::pointer_table): Remove GT_EXPR. * range-op.h (gt_op1_op2_relation): Delete. --- gcc/range-op-float.cc | 52 +++++++++++++------------------------------ gcc/range-op-mixed.h | 31 ++++++++++++++++++++++++++ gcc/range-op.cc | 40 +++++++-------------------------- gcc/range-op.h | 1 - 4 files changed, 54 insertions(+), 70 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index a480f1641d2..2f090e75245 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -961,32 +961,10 @@ operator_le::op2_range (frange &r, return true; } -class foperator_gt : 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 gt_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_gt; - bool -foperator_gt::fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio rel) const +operator_gt::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_GT)) return true; @@ -1004,11 +982,11 @@ foperator_gt::fold_range (irange &r, tree type, } bool -foperator_gt::op1_range (frange &r, - tree type, - const irange &lhs, - const frange &op2, - relation_trio) const +operator_gt::op1_range (frange &r, + tree type, + const irange &lhs, + const frange &op2, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -1043,11 +1021,11 @@ foperator_gt::op1_range (frange &r, } bool -foperator_gt::op2_range (frange &r, - tree type, - const irange &lhs, - const frange &op1, - relation_trio) const +operator_gt::op2_range (frange &r, + tree type, + const irange &lhs, + const frange &op1, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -1723,7 +1701,8 @@ public: op1_no_nan.clear_nan (); if (op2.maybe_isnan ()) op2_no_nan.clear_nan (); - if (!fop_gt.fold_range (r, type, op1_no_nan, op2_no_nan, rel)) + if (!range_op_handler (GT_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. @@ -2744,7 +2723,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 (GT_EXPR, fop_gt); set (GE_EXPR, fop_ge); set (ABS_EXPR, fop_abs); diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index dd42d98ca49..1c68d54b085 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -204,4 +204,35 @@ public: void update_bitmask (irange &r, const irange &lh, const irange &rh) const final override; }; + +class operator_gt : 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; + 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; + 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; + 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; +}; #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index c2e9927e774..e971bf4cd33 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -66,6 +66,7 @@ operator_equal op_equal; operator_not_equal op_not_equal; operator_lt op_lt; operator_le op_le; +operator_gt op_gt; // Invoke the initialization routines for each class of range. @@ -79,6 +80,7 @@ unified_table::unified_table () set (NE_EXPR, op_not_equal); set (LT_EXPR, op_lt); set (LE_EXPR, op_le); + set (GT_EXPR, op_gt); } // The tables are hidden and accessed via a simple extern function. @@ -1291,34 +1293,17 @@ operator_le::op2_range (irange &r, tree type, } -class operator_gt : public range_operator +void +operator_gt::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, GT_EXPR, lh, rh); } -} op_gt; + update_known_bitmask (r, GT_EXPR, lh, rh); +} // Check if the LHS range indicates a relation between OP1 and OP2. relation_kind -gt_op1_op2_relation (const irange &lhs) +operator_gt::op1_op2_relation (const irange &lhs) const { if (lhs.undefined_p ()) return VREL_UNDEFINED; @@ -1333,13 +1318,6 @@ gt_op1_op2_relation (const irange &lhs) return VREL_VARYING; } -relation_kind -operator_gt::op1_op2_relation (const irange &lhs) const -{ - return gt_op1_op2_relation (lhs); -} - - bool operator_gt::fold_range (irange &r, tree type, const irange &op1, const irange &op2, @@ -4805,7 +4783,6 @@ pointer_or_operator::wi_fold (irange &r, tree type, integral_table::integral_table () { - set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); set (PLUS_EXPR, op_plus); set (MINUS_EXPR, op_minus); @@ -4855,7 +4832,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); set (SSA_NAME, op_ident); set (INTEGER_CST, op_integer_cst); diff --git a/gcc/range-op.h b/gcc/range-op.h index 7d24b43a80e..411ab5e4a0a 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 gt_op1_op2_relation (const irange &lhs); relation_kind ge_op1_op2_relation (const irange &lhs); // This implements the range operator tables as local objects. -- 2.40.1