From patchwork Mon Jun 12 15:33:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 106697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2679117vqr; Mon, 12 Jun 2023 08:45:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5gb6p98YZKFuRoY9o11LCEDlGuIQw/GGBImNlMLuHxDLrHWXQXerZXK/KBWEZfOTYvd8XA X-Received: by 2002:a17:907:2da1:b0:973:84b0:b077 with SMTP id gt33-20020a1709072da100b0097384b0b077mr10591976ejc.33.1686584713893; Mon, 12 Jun 2023 08:45:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584713; cv=none; d=google.com; s=arc-20160816; b=imn7JPyueIgq1WFTCLYD3frVsMg+zZ11fb43DXgFmnj6EDRUu4r/Df+TWziqGccmec JtRWtrYbgcZgFKNgIhPe3qa/HkL14bjDglWm3MycvfMsi5NzfIn1cLMh61K7nukXQEf+ CwCQ009VWm3whgCr7a88v3NFWC5xBcvDT3fXVck99zELyiZ2pt4V3TtvFfo2xLsF2UJ6 /KGf7coqs7O2d1zKdyeSexrRYinZm1F8GD8nb+oWjj7RC1700DTJJdJOl9POfedf3KTF AVvyhQ4L94/oaM/tcK0woUpI2GTniC6XV9GKZysDRTGvucZDtwuvU2ONX65YHUSDO5mO wXmg== 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:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=8OH7Vk3JdxFUwWY3S1IMh8qV5Id7NXYIFRDIj75FDVo=; b=RTJkyqedLVxkKYOaqOKfcNgU5UpIvrXdMVy4VWl9sWF7MQVihyk0vom9/2Pt16hPSP 9Hw7Mv6onawTjdoSbUX+53CW+3KW1FtNY/cLQ3KCEwwMovNdHOX6Ynw412XvR/uNftwr zlaO1sbcU8oue9rXbnUL2FIOTXLfKGt4WOTMHBn9BVmy5WcIRsVJNJCQ+LWzH+VKhNya HyNc8yepQSuKmtx05EdtZTVxsU09URkrRPQUVANIh/sY38Gckt82gO6chf5cLBZo2BMZ vaajXGzTCuzk5ZSZ5i+H0Pf3fzUKW+mmMnCxjPz1yalb1kOurD2PUHr1hQW1rp9UHzVN uJeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="n/grQcR7"; 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 ka22-20020a170907991600b00977d0db2c6asi5033356ejc.63.2023.06.12.08.45.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:45:13 -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="n/grQcR7"; 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 226C33858C74 for ; Mon, 12 Jun 2023 15:38:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 226C33858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584330; bh=8OH7Vk3JdxFUwWY3S1IMh8qV5Id7NXYIFRDIj75FDVo=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=n/grQcR7OUWU6avpuTGP8H9oVkF+fxjDKpEF+8Wm2NzK1Z29NNU1ZKbTJLFO9yXfc MVd8LMRAFV4sxO8iNKPVPxoYvlc6rq+YaR/pcFnGpCSYFScwOCtLZW3SPNl9lgCBLr 9zbGkoSxD0C6cAdo++owalvErgRmdWfDnZwYQvyE= 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 F07563856636 for ; Mon, 12 Jun 2023 15:33:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F07563856636 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-JH7NYplEPO2p1LWxbppGzw-1; Mon, 12 Jun 2023 11:33:06 -0400 X-MC-Unique: JH7NYplEPO2p1LWxbppGzw-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-62dec6b082bso123546d6.0 for ; Mon, 12 Jun 2023 08:33:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583984; x=1689175984; 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=rYVRfkErd6/iNmdpN8G0vZ9M5DwvKHQfpwWFhAhqUno=; b=PtWwf4eUiCvx6Foh7KCpNxUe4kFT97LI6NnaJN836oHlFKxb+JbEtluGr9Xa3n4sEF R4zp+O/1W709WV776otSvi8j5xVR0bgdPLU/wbsSXGi/FDQZ0t+5i/7mszYobf+i4YVF kodrdIPanYaWJeNprpQWYwHdz0GqQXhy84+nrizZlPIpkfgMyvQnW+kokn1d653ZOEpH GiWCCToBJgd48cFysEX+L3r5Bd9PNkhoRwVVzhL6tYzetwFMKdVGvyuT5qt79EPnzjdh TIRCGiEzzJdK7rmX54QYv+aovWW6WId+i3P+TGvwfC7m+RjAimMyLX0NOculQ2O1HwuY m8Zg== X-Gm-Message-State: AC+VfDzG+UAKTjLDaVvAnqcPkXd0ZtqRU4lkutXhDONjZOKniaFFpt3J KkKcCMf1dcfUPgI6Ebrc6MkCmR0VbWtABcVKKxnJS+obkUJVNRZ8CcaXAGj519SyFVDGQwaUOdr IqAF0nc03qy9DaPRqibFh7Rwm/Ky1s6VRKqjYN8cbRehAQMPcGdA1CTOYq0LQbzTH0AF0iwLX1O uZRA== X-Received: by 2002:a05:6214:c22:b0:626:299b:68ee with SMTP id a2-20020a0562140c2200b00626299b68eemr12611272qvd.55.1686583984184; Mon, 12 Jun 2023 08:33:04 -0700 (PDT) X-Received: by 2002:a05:6214:c22:b0:626:299b:68ee with SMTP id a2-20020a0562140c2200b00626299b68eemr12611244qvd.55.1686583983829; Mon, 12 Jun 2023 08:33:03 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id x16-20020a0ce0d0000000b0062627f71b07sm1303885qvk.125.2023.06.12.08.33.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:33:03 -0700 (PDT) Message-ID: Date: Mon, 12 Jun 2023 11:33:02 -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 12/17] - Add a hybrid MAX_EXPR operator for integer and pointer. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.2 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768512253210910029?= X-GMAIL-MSGID: =?utf-8?q?1768512253210910029?= Add a hybrid operator to choose between integer and pointer versions at runtime. This is the last use of the pointer table, so it is also removed. Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From cd194f582c5be3cc91e025e304e2769f61ceb6b6 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:35:18 -0400 Subject: [PATCH 12/17] Add a hybrid MAX_EXPR operator for integer and pointer. This adds an operator to the unified table for MAX_EXPR which will select either the pointer or integer version based on the type passed to the method. This is for use until we have a seperate PRANGE class. THIs also removes the pointer table which is no longer needed. * range-op-mixed.h (operator_max): Remove final. * range-op-ptr.cc (pointer_table::pointer_table): Remove MAX_EXPR. (pointer_table::pointer_table): Remove. (class hybrid_max_operator): New. (range_op_table::initialize_pointer_ops): Add hybrid_max_operator. * range-op.cc (pointer_tree_table): Remove. (unified_table::unified_table): Comment out MAX_EXPR. (get_op_handler): Remove check of pointer table. * range-op.h (class pointer_table): Remove. --- gcc/range-op-mixed.h | 6 +++--- gcc/range-op-ptr.cc | 30 ++++++++++++++++++++---------- gcc/range-op.cc | 10 ++-------- gcc/range-op.h | 9 --------- 4 files changed, 25 insertions(+), 30 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index a65935435c2..bdc488b8754 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -636,10 +636,10 @@ class operator_max : public range_operator { public: void update_bitmask (irange &r, const irange &lh, - const irange &rh) const final override; -private: + const irange &rh) const override; +protected: void wi_fold (irange &r, tree type, const wide_int &lh_lb, const wide_int &lh_ub, const wide_int &rh_lb, - const wide_int &rh_ub) const final override; + const wide_int &rh_ub) const override; }; #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index 483e43ca994..ea66fe9056b 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -157,7 +157,6 @@ pointer_min_max_operator::wi_fold (irange &r, tree type, r.set_varying (type); } - class pointer_and_operator : public range_operator { public: @@ -265,14 +264,6 @@ operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type, rel); } -// When PRANGE is implemented, these are all the opcodes which are currently -// expecting routines with PRANGE signatures. - -pointer_table::pointer_table () -{ - set (MAX_EXPR, op_ptr_min_max); -} - // ---------------------------------------------------------------------- // Hybrid operators for the 4 operations which integer and pointers share, // but which have different implementations. Simply check the type in @@ -404,8 +395,26 @@ public: } } op_hybrid_min; +class hybrid_max_operator : public operator_max +{ +public: + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override + { + if (!r.undefined_p () && INTEGRAL_TYPE_P (r.type ())) + operator_max::update_bitmask (r, lh, rh); + } - + void wi_fold (irange &r, tree type, const wide_int &lh_lb, + const wide_int &lh_ub, const wide_int &rh_lb, + const wide_int &rh_ub) const final override + { + if (INTEGRAL_TYPE_P (type)) + return operator_max::wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub); + else + return op_ptr_min_max.wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub); + } +} op_hybrid_max; // Initialize any pointer operators to the primary table @@ -417,4 +426,5 @@ range_op_table::initialize_pointer_ops () set (BIT_AND_EXPR, op_hybrid_and); set (BIT_IOR_EXPR, op_hybrid_or); set (MIN_EXPR, op_hybrid_min); + set (MAX_EXPR, op_hybrid_max); } diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 481f3b1324d..046b7691bb6 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -49,8 +49,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-ccp.h" #include "range-op-mixed.h" -pointer_table pointer_tree_table; - // Instantiate a range_op_table for unified operations. class unified_table : public range_op_table { @@ -124,18 +122,14 @@ unified_table::unified_table () // set (BIT_AND_EXPR, op_bitwise_and); // set (BIT_IOR_EXPR, op_bitwise_or); // set (MIN_EXPR, op_min); - set (MAX_EXPR, op_max); + // set (MAX_EXPR, op_max); } // The tables are hidden and accessed via a simple extern function. range_operator * -get_op_handler (enum tree_code code, tree type) +get_op_handler (enum tree_code code, tree) { - // If this is pointer type and there is pointer specifc routine, use it. - if (POINTER_TYPE_P (type) && pointer_tree_table[code]) - return pointer_tree_table[code]; - return unified_tree_table[code]; } diff --git a/gcc/range-op.h b/gcc/range-op.h index 08c51bace40..15c45137af2 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -299,15 +299,6 @@ range_op_table::set (enum tree_code code, range_operator &op) m_range_tree[code] = &op; } -// Instantiate a range op table for pointer operations. - -class pointer_table : public range_op_table -{ -public: - pointer_table (); -}; -extern pointer_table pointer_tree_table; - extern range_operator *ptr_op_widen_mult_signed; extern range_operator *ptr_op_widen_mult_unsigned; extern range_operator *ptr_op_widen_plus_signed; -- 2.40.1