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: 105853 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1273911vqr; Fri, 9 Jun 2023 17:42:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Sv15N4gNRnUI3H8Z+TT9uiXkec9xJ2xjUaZ8bbknd7LjzQF82XFuEkIEwq+HhSEbcWIct X-Received: by 2002:a17:907:984:b0:974:1c99:7d3 with SMTP id bf4-20020a170907098400b009741c9907d3mr2722804ejc.25.1686357741779; Fri, 09 Jun 2023 17:42:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686357741; cv=none; d=google.com; s=arc-20160816; b=ibptu40umxst3bLYOsnLli4dRMltlStNRaIwORs4GRJF/5zZbeCEMwsVlfh7sVXkvt Lg5r6hLhtx3WPEaGh94cnqNhQ3Rl2tlZtmexv7BZHfu0W6ov2t1ZsbPVBN6Yhfr318cB 9PdQoPmSX4pa/50uClLTgjj7TBlFcNdEWyCJSGuFLv97O7w9LJ9NOMSBmFSswzFNsOsW 3DY1k8kBCoDdDD8rCkQFVaxNkWOC/gy+SuRd8vRcAn6t+hTzRXDOUaMF+kykSbpXFsEX h1a1G5BDBiX3eGbtQDRwt2RiKvt7Swz/dCUIpXaF+DqntqX3p6Kg4a/EgyZiFpi6YHFt qqgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=yv7SsJSYN/j0UCqTfwnp14bhkMmdDmtMyTgrOCWxpMY=; b=N8l0LXFjwv8OjeGQCs5hx4OaVGgmlkYvLlRcdx2QUsL1hhnd8WqNAT4c3Qyc8usf25 QQdJgY6+YDxa/pQuEx7hpyqYqaR4VOgVluKQ9SJQapct5oYUisAfSz65pgvigSC9E/oE l7PB8srtSjpxBoJgcgGlwkzUJDQpjzQkWej03qqkkj4NytPZH2EJCGHNs9kwnK5nuYqx CuTK0Z5pH9xx/ivAP/r5yxZWo1Tpk75SugauDOSHVGJZO58GQ1TWU2TqRjR7psy6bZy8 zjcQ8FTdU84j0HhtAFOHhIKfj2iYG0KoOZYuttiKAtFNaLRPlOXNrNuRNZQn8zldWMJG uGGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FcjPe3gO; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id kb19-20020a1709070f9300b009572d0759a8si2072789ejc.225.2023.06.09.17.42.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 17:42:21 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FcjPe3gO; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AC3DE38930F2 for ; Sat, 10 Jun 2023 00:38:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC3DE38930F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357518; bh=yv7SsJSYN/j0UCqTfwnp14bhkMmdDmtMyTgrOCWxpMY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=FcjPe3gOS8IkNW56Zg+8xyLoKGjb12IQLxis59UJ+r7+TC3VraYo16MwLMinFhrom Emg3wKdoiI0S08Nsfw6GydpLp/s5sWNTGS33fA84CrRFicA5amnbhgRe0CmV4OQx3g k2SUpprTWWNTpr9FhVm3SjKf3PC7yS8GppXWYUWk= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768274255270838157?= X-GMAIL-MSGID: =?utf-8?q?1768274255270838157?= 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