From patchwork Mon Jun 12 15:32:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 106696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2678664vqr; Mon, 12 Jun 2023 08:44:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6o9rGA8L8GDUy71a4TUtA+gWtrYAaSG6xVBHwhebixhZhnp0RTuITMrRIM08N6wPWj2XSW X-Received: by 2002:a17:907:74a:b0:978:af67:c7f6 with SMTP id xc10-20020a170907074a00b00978af67c7f6mr9284426ejb.13.1686584669705; Mon, 12 Jun 2023 08:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584669; cv=none; d=google.com; s=arc-20160816; b=U5bBB+RCMYvkKusLcnnhx1l/g3hitPgTBoJ/ocq0Uaj1sK+cC6geWS5bw80L6nPB7s CmF/6OKoweFJnUtjx+EyKc3dchF9XHBMaRolJI6PF1CM/aiC+6oyE0ZB0hKp+naSFF+m gekGxdI1SMPkiNVEh2L6JCubXs4qqwQKycQ2IOnnUrOGEBMcb6Ps99KM/uKFhHhFQsuh k1jEDjl5aJDnUXTyudDJEnMHFmGL8SWdkuK8vNqkCmnCKJookpirrs12uOxgao8y3eKQ H4IavupLodk//cSK9phh53Ds/DnHEJWqVOEdi+q/aA85rZ1rhgPSTPArRhiWl3ohaVdJ NVpA== 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=AeM/9ZEjMz/7TxGw4FKU+IRjnExPbrIpcl3MFkAFHVE=; b=igG5OK7OIIYftYbdQobSulNzN9NMZU8GSmmm/LjYeSnT37wU1/wQXuLKXB9hueDgT+ 5/Bd1nqY9axWok9gnjRZHwndCiJsnEqAV3aOnTQDlF6D6TVsamIWX1I9PR2Ve0/ZWXEp VEdly5ela5QCFiDZ44NCJOpBpyRmguiRpIwDziBSIDcjbx7ywxQ5Ds7XPWd6bWzGhvaC MXusPayftBEaBItUUJnzd9UViDpW87g1j7ZvIDALKpZtfnwb2MjDH/3wm/Bakalx3MNl PDwI1JGmGv63xJogbxl+p+uFvjcL4FWvmfFU0GUG5UjGgud33QjvLIrpYrI/fDfMQELa +4Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QpoaE5Ru; 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 g8-20020a1709064e4800b0096f6d4fde85si1865298ejw.269.2023.06.12.08.44.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:44:29 -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=QpoaE5Ru; 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 3D6A6394202E for ; Mon, 12 Jun 2023 15:37:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D6A6394202E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584271; bh=AeM/9ZEjMz/7TxGw4FKU+IRjnExPbrIpcl3MFkAFHVE=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=QpoaE5RuR0FoRt+mm4aszz6XK48IxxLB1hy3sCGfrrXBhiiRSk7Bs0iYT0f4YozvJ QeRyYazBU9Mv3AUfLZWUT4rYMm0wqFqnW+VAhLVRF+C1eq7T7B3gUfsJlq8KL3S+Bu abIsPvSYk5Ly4hIaGIBeVMZtpnijf6mVetsASCXQ= 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 04CA7385558F for ; Mon, 12 Jun 2023 15:32:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04CA7385558F Received: from mail-ua1-f70.google.com (mail-ua1-f70.google.com [209.85.222.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-443-MEmgIM4nNY6fNqyebs261g-1; Mon, 12 Jun 2023 11:32:54 -0400 X-MC-Unique: MEmgIM4nNY6fNqyebs261g-1 Received: by mail-ua1-f70.google.com with SMTP id a1e0cc1a2514c-7834ce87f84so1633635241.2 for ; Mon, 12 Jun 2023 08:32:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583973; x=1689175973; 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=/k+N6diUEunezkrG/lOY5kJP5kRCTF22w3nKi0tbo9k=; b=BJSM0+CvjHvNJtY12SvYTNEBColYwV7G9mIx/zgRWXQiQ0TTC3zfIe7Az+AAmRVJkj W8myDJ83IGNOHgLxnwziuBQt7DwSr3kR2IsIlUKx/GPYnB/SABo0/wdjm26YUuGaXEHx agTuBz1kfLhT+UrKLDW7MFPrEz+Zk+3lnD7jWZrqIXe+FKa36du82acYB6fz6ayhuLVh gTmLkf6G1406Za71SwXdfjt2O81+NuognTNoU5n3pMWGfl7Erj38gYoo9sl+H1d//Aqm wNshrqZfvzV1hQGqJEXuKX255X3sFlR8X+3y3WyPyYQ9BojSQZYDwkcx8CpqPdzutxlJ Vk3Q== X-Gm-Message-State: AC+VfDyn8c2DcMJGYU76NxT10old2cYIkYx7C/r/DNrKbEPQq1OYjPW3 33Q82NDXgWjc58lZOzmKqnGeT5n/+WW9tSsY8Fdvd4icdXNTGzJp0QfsYRXQUsvfW2Mkzbvfazd EiccU0knc/Tot6j7yL8GbXLn/fYL9Si64VLzvs2nwQ2RXCOEwbGCNbQ1O5xsxZAdHmHzB3iKJbs vCMA== X-Received: by 2002:a67:e3a2:0:b0:43b:19f4:88d9 with SMTP id j2-20020a67e3a2000000b0043b19f488d9mr3574253vsm.21.1686583973464; Mon, 12 Jun 2023 08:32:53 -0700 (PDT) X-Received: by 2002:a67:e3a2:0:b0:43b:19f4:88d9 with SMTP id j2-20020a67e3a2000000b0043b19f488d9mr3574244vsm.21.1686583973052; Mon, 12 Jun 2023 08:32:53 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id mg9-20020a056214560900b006238b6bd191sm3233172qvb.145.2023.06.12.08.32.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:32:52 -0700 (PDT) Message-ID: <1d685c80-95a7-e640-c3d7-5fa909dd9de8@redhat.com> Date: Mon, 12 Jun 2023 11:32:51 -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 10/17] - Add a hybrid BIT_IOR_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.1 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?1768512206202578810?= X-GMAIL-MSGID: =?utf-8?q?1768512206202578810?= Add a hybrid operator to choose between integer and pointer versions at runtime. Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 80f402e832a2ce402ee1562030d5c67ebc276f7c Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:33:17 -0400 Subject: [PATCH 10/17] Add a hybrid BIT_IOR_EXPR operator for integer and pointer. This adds an operator to the unified table for BIT_IOR_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. * range-op-mixed.h (operator_bitwise_or): Remove final. * range-op-ptr.cc (pointer_table::pointer_table): Remove BIT_IOR_EXPR. (class hybrid_or_operator): New. (range_op_table::initialize_pointer_ops): Add hybrid_or_operator. * range-op.cc (unified_table::unified_table): Comment out BIT_IOR_EXPR. --- gcc/range-op-mixed.h | 10 ++++----- gcc/range-op-ptr.cc | 52 ++++++++++++++++++++++++++++++++++++++++++-- gcc/range-op.cc | 4 ++-- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 4177818e4b9..e4852e974c4 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -609,16 +609,16 @@ public: using range_operator::op2_range; bool op1_range (irange &r, tree type, const irange &lhs, const irange &op2, - relation_trio rel = TRIO_VARYING) const final override; + relation_trio rel = TRIO_VARYING) const override; bool op2_range (irange &r, tree type, const irange &lhs, const irange &op1, - relation_trio rel = TRIO_VARYING) const final override; + relation_trio rel = TRIO_VARYING) const override; 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; }; class operator_min : public range_operator diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index 941026994ed..7b22d0bf05b 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -184,9 +184,9 @@ pointer_and_operator::wi_fold (irange &r, tree type, class pointer_or_operator : public range_operator { +public: using range_operator::op1_range; using range_operator::op2_range; -public: virtual bool op1_range (irange &r, tree type, const irange &lhs, const irange &op2, @@ -270,7 +270,6 @@ operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type, pointer_table::pointer_table () { - set (BIT_IOR_EXPR, op_pointer_or); set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); } @@ -334,6 +333,54 @@ public: } } op_hybrid_and; +// Temporary class which dispatches routines to either the INT version or +// the pointer version depending on the type. Once PRANGE is a range +// class, we can remove the hybrid. + +class hybrid_or_operator : public operator_bitwise_or +{ +public: + using range_operator::op1_range; + using range_operator::op2_range; + using range_operator::lhs_op1_relation; + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio rel = TRIO_VARYING) const final override + { + if (INTEGRAL_TYPE_P (type)) + return operator_bitwise_or::op1_range (r, type, lhs, op2, rel); + else + return op_pointer_or.op1_range (r, type, lhs, op2, rel); + } + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &op1, + relation_trio rel = TRIO_VARYING) const final override + { + if (INTEGRAL_TYPE_P (type)) + return operator_bitwise_or::op2_range (r, type, lhs, op1, rel); + else + return op_pointer_or.op2_range (r, type, lhs, op1, rel); + } + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override + { + if (!r.undefined_p () && INTEGRAL_TYPE_P (r.type ())) + operator_bitwise_or::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_bitwise_or::wi_fold (r, type, lh_lb, lh_ub, + rh_lb, rh_ub); + else + return op_pointer_or.wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub); + } +} op_hybrid_or; + + // Initialize any pointer operators to the primary table @@ -343,4 +390,5 @@ range_op_table::initialize_pointer_ops () set (POINTER_PLUS_EXPR, op_pointer_plus); set (POINTER_DIFF_EXPR, op_pointer_diff); set (BIT_AND_EXPR, op_hybrid_and); + set (BIT_IOR_EXPR, op_hybrid_or); } diff --git a/gcc/range-op.cc b/gcc/range-op.cc index dcb922143ce..0a9a3297de7 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -121,8 +121,8 @@ unified_table::unified_table () // is used until there is a pointer range class. Then we can simply // uncomment the operator here and use the unified version. - //set (BIT_AND_EXPR, op_bitwise_and); - set (BIT_IOR_EXPR, op_bitwise_or); + // set (BIT_AND_EXPR, op_bitwise_and); + // set (BIT_IOR_EXPR, op_bitwise_or); set (MIN_EXPR, op_min); set (MAX_EXPR, op_max); } -- 2.40.1