From patchwork Wed May 10 15:23:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 92175 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3709055vqo; Wed, 10 May 2023 08:25:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6hxjoVZg7Cfj6ccwqv+JyvS/9X/t6ZCTGvxXggdBpswcuwQJHQ9en4y+6PrQoTekDAedpt X-Received: by 2002:a17:907:5c5:b0:965:9edf:f0d0 with SMTP id wg5-20020a17090705c500b009659edff0d0mr15251826ejb.13.1683732348337; Wed, 10 May 2023 08:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683732348; cv=none; d=google.com; s=arc-20160816; b=zY1az8SckdaJXyQa0IeyEto7H+Elawg0JWG4pmwH/a4OIwqkMlc+RabiKOzvQGfiON lfuxoGjGuMFvSTwM0mSZHJd5U26gkH6i3FtgIByY/b23eNgG87gBzYg2VGg4VDhvIfQC 5L1CcitKFHSvZrObLKXKl7M2Ex5jq4YFXdZlfbIrQn90ttID3QXMF92TsvS1LbbBmh8l gIUXSxhDJzhL0dFObWpL+SsB58mLSFKj/XC/BB9Qjf6YDLggHnqDUJC2Tlt/RQtnXUlb UistJb1R/+ggbQYwdgtTCCtqyhkuWs5d8eJ7M/u5EXp5TZALCC+rqugfEhdlM1a/ThMQ 3yGg== 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-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=gegQzoDXiZmKhuHCu0BwMc6neMPDwjEqZYO/utkPyC8=; b=w44om/OKhF9kKrM8tn1oag9zgxJAoJrvayjhnvvLuZyWAGwdRbWDgAQ2sZSuegX4MI HHAiZmuZSwe6EL13/gxBxBVZnK+US3sXHThU82N5I1Pi7S/66iYo4HbsO/s1aNGe7OuQ CLR3uKXv6xwPhVVBLO2NwkZ/XB37+kEpi5dDf4GM3Uz5uYtZaU5CSL+bDJBSwUYim1J/ XLbIBxe+gN7i7/jzssL8MCO/IBZzAwLucna8l4xk9WMXom0IeOkIBoQ0LF+Hgmho/bdq Gt0KkuRuFxYtGO8A/xgZT1KeeXC2zZKv2bha+DqNbtzO0UQ3wHu6mCudJQwhawKpYnt7 gX2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZXSY12WS; 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 u10-20020aa7d0ca000000b0050dc3b7eb61si1689592edo.123.2023.05.10.08.25.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 08:25:48 -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=ZXSY12WS; 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 A94FE385355C for ; Wed, 10 May 2023 15:25:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A94FE385355C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683732303; bh=gegQzoDXiZmKhuHCu0BwMc6neMPDwjEqZYO/utkPyC8=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=ZXSY12WSl/jcgZco9uFtiNaOOuqhnJ/6sL1TLG1FXqiuMjFKGYPmkfePqha3cDq0V kASBKaLWR+a3sR3D8MSZ3fGjUWlsscmn+O0N4YO1YGKe2A5aORfedktJoR4LDgq2qJ QGWBVlQWD14y/tKsJSoeBhIOJd1cETsVrRv4WC4Y= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id 614B33856947 for ; Wed, 10 May 2023 15:24:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 614B33856947 X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="436564081" X-IronPort-AV: E=Sophos;i="5.99,265,1677571200"; d="scan'208";a="436564081" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2023 08:24:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="788966875" X-IronPort-AV: E=Sophos;i="5.99,265,1677571200"; d="scan'208";a="788966875" Received: from shvmail02.sh.intel.com ([10.239.244.9]) by FMSMGA003.fm.intel.com with ESMTP; 10 May 2023 08:23:59 -0700 Received: from pli-ubuntu.sh.intel.com (pli-ubuntu.sh.intel.com [10.239.159.47]) by shvmail02.sh.intel.com (Postfix) with ESMTP id 7282310085DD; Wed, 10 May 2023 23:23:58 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@sifive.com, pan2.li@intel.com, yanzhang.wang@intel.com, jeffreyalaw@gmail.com, jakub@redhat.com, rguenther@suse.de, richard.sandiford@arm.com Subject: [PATCH v3] Var-Tracking: Typedef pointer_mux as decl_or_value Date: Wed, 10 May 2023 23:23:56 +0800 Message-Id: <20230510152356.2623391-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230510071758.2098860-1-pan2.li@intel.com> References: <20230510071758.2098860-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: Pan Li via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: pan2.li@intel.com 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?1765508271756051518?= X-GMAIL-MSGID: =?utf-8?q?1765521330911462217?= From: Pan Li The decl_or_value is defined as void * before this PATCH. It will take care of both the tree_node and rtx_def. Unfortunately, given a void pointer cannot tell the input is tree_node or rtx_def. Then we have some implicit structure layout requirement similar as below. Or we will touch unreasonable bits when cast void * to tree_node or rtx_def. +--------+-----------+----------+ | offset | tree_node | rtx_def | +--------+-----------+----------+ | 0 | code: 16 | code: 16 | <- require the location and bitssize +--------+-----------+----------+ | 16 | ... | mode: 8 | +--------+-----------+----------+ | ... | +--------+-----------+----------+ | 24 | ... | ... | +--------+-----------+----------+ This behavior blocks the PATCH that extend the rtx_def mode from 8 to 16 bits for running out of machine mode. This PATCH introduced the pointer_mux to tell the input is tree_node or rtx_def, and decouple the above implicition dependency. Signed-off-by: Pan Li Co-Authored-By: Richard Sandiford Co-Authored-By: Richard Biener Co-Authored-By: Jakub Jelinek gcc/ChangeLog: * mux-utils.h: Add overload operator == and != for pointer_mux. * var-tracking.cc: Included mux-utils.h for pointer_tmux. (decl_or_value): Changed from void * to pointer_mux. (dv_is_decl_p): Reconciled to the new type, aka pointer_mux. (dv_as_decl): Ditto. (dv_as_opaque): Removed due to unnecessary. (struct variable_hasher): Take decl_or_value as compare_type. (variable_hasher::equal): Diito. (dv_from_decl): Reconciled to the new type, aka pointer_mux. (dv_from_value): Ditto. (attrs_list_member): Ditto. (vars_copy): Ditto. (var_reg_decl_set): Ditto. (var_reg_delete_and_set): Ditto. (find_loc_in_1pdv): Ditto. (canonicalize_values_star): Ditto. (variable_post_merge_new_vals): Ditto. (dump_onepart_variable_differences): Ditto. (variable_different_p): Ditto. (variable_was_changed): Ditto. (set_slot_part): Ditto. (clobber_slot_part): Ditto. (clobber_variable_part): Ditto. (remove_value_from_changed_variables): Ditto. (notify_dependents_of_changed_value): Ditto. --- gcc/mux-utils.h | 12 ++++++ gcc/var-tracking.cc | 96 ++++++++++++++++++--------------------------- 2 files changed, 51 insertions(+), 57 deletions(-) diff --git a/gcc/mux-utils.h b/gcc/mux-utils.h index a2b6a316899..adf3d3b722b 100644 --- a/gcc/mux-utils.h +++ b/gcc/mux-utils.h @@ -72,6 +72,18 @@ public: // Return true unless the pointer is a null A pointer. explicit operator bool () const { return m_ptr; } + // Return true if class has the same m_ptr, or false. + bool operator == (const pointer_mux &other) const + { + return this->m_ptr == other.m_ptr; + } + + // Return true if class has the different m_ptr, or false. + bool operator != (const pointer_mux &other) const + { + return this->m_ptr != other.m_ptr; + } + // Assign A and B pointers respectively. void set_first (T1 *ptr) { *this = first (ptr); } void set_second (T2 *ptr) { *this = second (ptr); } diff --git a/gcc/var-tracking.cc b/gcc/var-tracking.cc index fae0c73e02f..7a35f49020a 100644 --- a/gcc/var-tracking.cc +++ b/gcc/var-tracking.cc @@ -116,6 +116,7 @@ #include "fibonacci_heap.h" #include "print-rtl.h" #include "function-abi.h" +#include "mux-utils.h" typedef fibonacci_heap bb_heap_t; @@ -197,14 +198,14 @@ struct micro_operation /* A declaration of a variable, or an RTL value being handled like a - declaration. */ -typedef void *decl_or_value; + declaration by pointer_mux. */ +typedef pointer_mux decl_or_value; /* Return true if a decl_or_value DV is a DECL or NULL. */ static inline bool dv_is_decl_p (decl_or_value dv) { - return !dv || (int) TREE_CODE ((tree) dv) != (int) VALUE; + return dv.is_first (); } /* Return true if a decl_or_value is a VALUE rtl. */ @@ -219,7 +220,7 @@ static inline tree dv_as_decl (decl_or_value dv) { gcc_checking_assert (dv_is_decl_p (dv)); - return (tree) dv; + return dv.known_first (); } /* Return the value in the decl_or_value. */ @@ -227,14 +228,7 @@ static inline rtx dv_as_value (decl_or_value dv) { gcc_checking_assert (dv_is_value_p (dv)); - return (rtx)dv; -} - -/* Return the opaque pointer in the decl_or_value. */ -static inline void * -dv_as_opaque (decl_or_value dv) -{ - return dv; + return dv.known_second (); } @@ -483,9 +477,9 @@ static void variable_htab_free (void *); struct variable_hasher : pointer_hash { - typedef void *compare_type; + typedef decl_or_value compare_type; static inline hashval_t hash (const variable *); - static inline bool equal (const variable *, const void *); + static inline bool equal (const variable *, const decl_or_value); static inline void remove (variable *); }; @@ -501,11 +495,9 @@ variable_hasher::hash (const variable *v) /* Compare the declaration of variable X with declaration Y. */ inline bool -variable_hasher::equal (const variable *v, const void *y) +variable_hasher::equal (const variable *v, const decl_or_value y) { - decl_or_value dv = CONST_CAST2 (decl_or_value, const void *, y); - - return (dv_as_opaque (v->dv) == dv_as_opaque (dv)); + return v->dv == y; } /* Free the element of VARIABLE_HTAB (its type is struct variable_def). */ @@ -1396,8 +1388,7 @@ onepart_pool_allocate (onepart_enum onepart) static inline decl_or_value dv_from_decl (tree decl) { - decl_or_value dv; - dv = decl; + decl_or_value dv = decl; gcc_checking_assert (dv_is_decl_p (dv)); return dv; } @@ -1406,8 +1397,7 @@ dv_from_decl (tree decl) static inline decl_or_value dv_from_value (rtx value) { - decl_or_value dv; - dv = value; + decl_or_value dv = value; gcc_checking_assert (dv_is_value_p (dv)); return dv; } @@ -1519,7 +1509,7 @@ static attrs * attrs_list_member (attrs *list, decl_or_value dv, HOST_WIDE_INT offset) { for (; list; list = list->next) - if (dv_as_opaque (list->dv) == dv_as_opaque (dv) && list->offset == offset) + if (list->dv == dv && list->offset == offset) return list; return NULL; } @@ -1831,8 +1821,7 @@ vars_copy (variable_table_type *dst, variable_table_type *src) { variable **dstp; var->refcount++; - dstp = dst->find_slot_with_hash (var->dv, dv_htab_hash (var->dv), - INSERT); + dstp = dst->find_slot_with_hash (var->dv, dv_htab_hash (var->dv), INSERT); *dstp = var; } } @@ -1866,8 +1855,7 @@ var_reg_decl_set (dataflow_set *set, rtx loc, enum var_init_status initialized, dv = dv_from_decl (var_debug_decl (dv_as_decl (dv))); for (node = set->regs[REGNO (loc)]; node; node = node->next) - if (dv_as_opaque (node->dv) == dv_as_opaque (dv) - && node->offset == offset) + if (node->dv == dv && node->offset == offset) break; if (!node) attrs_list_insert (&set->regs[REGNO (loc)], dv, offset, loc); @@ -1966,7 +1954,7 @@ var_reg_delete_and_set (dataflow_set *set, rtx loc, bool modify, for (node = *nextp; node; node = next) { next = node->next; - if (dv_as_opaque (node->dv) != decl || node->offset != offset) + if (node->dv.first_or_null () != decl || node->offset != offset) { delete_variable_part (set, node->loc, node->dv, node->offset); delete node; @@ -3242,7 +3230,7 @@ find_loc_in_1pdv (rtx loc, variable *var, variable_table_type *vars) if (!var->n_var_parts) return NULL; - gcc_checking_assert (loc != dv_as_opaque (var->dv)); + gcc_checking_assert (loc != var->dv.second_or_null ()); loc_code = GET_CODE (loc); for (node = var->var_part[0].loc_chain; node; node = node->next) @@ -3832,16 +3820,14 @@ canonicalize_values_star (variable **slot, dataflow_set *set) while (list) { - if (list->offset == 0 - && (dv_as_opaque (list->dv) == dv_as_opaque (dv) - || dv_as_opaque (list->dv) == dv_as_opaque (cdv))) + if (list->offset == 0 && (list->dv == dv || list->dv == cdv)) break; list = list->next; } gcc_assert (list); - if (dv_as_opaque (list->dv) == dv_as_opaque (dv)) + if (list->dv == dv) { list->dv = cdv; for (listp = &list->next; (list = *listp); listp = &list->next) @@ -3849,7 +3835,7 @@ canonicalize_values_star (variable **slot, dataflow_set *set) if (list->offset) continue; - if (dv_as_opaque (list->dv) == dv_as_opaque (cdv)) + if (list->dv == cdv) { *listp = list->next; delete list; @@ -3857,17 +3843,17 @@ canonicalize_values_star (variable **slot, dataflow_set *set) break; } - gcc_assert (dv_as_opaque (list->dv) != dv_as_opaque (dv)); + gcc_assert (list->dv != dv); } } - else if (dv_as_opaque (list->dv) == dv_as_opaque (cdv)) + else if (list->dv == cdv) { for (listp = &list->next; (list = *listp); listp = &list->next) { if (list->offset) continue; - if (dv_as_opaque (list->dv) == dv_as_opaque (dv)) + if (list->dv == dv) { *listp = list->next; delete list; @@ -3875,7 +3861,7 @@ canonicalize_values_star (variable **slot, dataflow_set *set) break; } - gcc_assert (dv_as_opaque (list->dv) != dv_as_opaque (cdv)); + gcc_assert (list->dv != cdv); } } else @@ -3884,9 +3870,7 @@ canonicalize_values_star (variable **slot, dataflow_set *set) if (flag_checking) while (list) { - if (list->offset == 0 - && (dv_as_opaque (list->dv) == dv_as_opaque (dv) - || dv_as_opaque (list->dv) == dv_as_opaque (cdv))) + if (list->offset == 0 && (list->dv == dv || list->dv == cdv)) gcc_unreachable (); list = list->next; @@ -4475,7 +4459,7 @@ variable_post_merge_new_vals (variable **slot, dfset_post_merge *dfpm) check_dupes = true; break; } - else if (dv_as_opaque (att->dv) == dv_as_opaque (var->dv)) + else if (att->dv == var->dv) curp = attp; } @@ -4485,7 +4469,7 @@ variable_post_merge_new_vals (variable **slot, dfset_post_merge *dfpm) while (*curp) if ((*curp)->offset == 0 && GET_MODE ((*curp)->loc) == GET_MODE (node->loc) - && dv_as_opaque ((*curp)->dv) == dv_as_opaque (var->dv)) + && (*curp)->dv == var->dv) break; else curp = &(*curp)->next; @@ -4989,7 +4973,7 @@ dump_onepart_variable_differences (variable *var1, variable *var2) gcc_assert (var1 != var2); gcc_assert (dump_file); - gcc_assert (dv_as_opaque (var1->dv) == dv_as_opaque (var2->dv)); + gcc_assert (var1->dv == var2->dv); gcc_assert (var1->n_var_parts == 1 && var2->n_var_parts == 1); @@ -5054,8 +5038,7 @@ variable_different_p (variable *var1, variable *var2) if (var1->onepart && var1->n_var_parts) { - gcc_checking_assert (dv_as_opaque (var1->dv) == dv_as_opaque (var2->dv) - && var1->n_var_parts == 1); + gcc_checking_assert (var1->dv == var2->dv && var1->n_var_parts == 1); /* One-part values have locations in a canonical order. */ return onepart_variable_different_p (var1, var2); } @@ -7520,9 +7503,10 @@ variable_was_changed (variable *var, dataflow_set *set) if (onepart == ONEPART_VALUE || onepart == ONEPART_DEXPR) { - dslot = dropped_values->find_slot_with_hash (var->dv, - dv_htab_hash (var->dv), - INSERT); + dslot + = dropped_values->find_slot_with_hash (var->dv, + dv_htab_hash (var->dv), + INSERT); empty_var = *dslot; if (empty_var) @@ -7656,7 +7640,7 @@ set_slot_part (dataflow_set *set, rtx loc, variable **slot, onepart = dv_onepart_p (dv); gcc_checking_assert (offset == 0 || !onepart); - gcc_checking_assert (loc != dv_as_opaque (dv)); + gcc_checking_assert (loc != dv.second_or_null ()); if (! flag_var_tracking_uninit) initialized = VAR_INIT_STATUS_INITIALIZED; @@ -7684,7 +7668,7 @@ set_slot_part (dataflow_set *set, rtx loc, variable **slot, { int r = -1, c = 0; - gcc_assert (dv_as_opaque (var->dv) == dv_as_opaque (dv)); + gcc_assert (var->dv == dv); pos = 0; @@ -7950,8 +7934,7 @@ clobber_slot_part (dataflow_set *set, rtx loc, variable **slot, for (anode = *anextp; anode; anode = anext) { anext = anode->next; - if (dv_as_opaque (anode->dv) == dv_as_opaque (var->dv) - && anode->offset == offset) + if (anode->dv == var->dv && anode->offset == offset) { delete anode; *anextp = anext; @@ -7980,8 +7963,7 @@ clobber_variable_part (dataflow_set *set, rtx loc, decl_or_value dv, { variable **slot; - if (!dv_as_opaque (dv) - || (!dv_is_value_p (dv) && ! DECL_P (dv_as_decl (dv)))) + if (!dv || (!dv_is_value_p (dv) && ! DECL_P (dv_as_decl (dv)))) return; slot = shared_hash_find_slot_noinsert (set->vars, dv); @@ -8960,7 +8942,7 @@ remove_value_from_changed_variables (rtx val) variable *var; slot = changed_variables->find_slot_with_hash (dv, dv_htab_hash (dv), - NO_INSERT); + NO_INSERT); var = *slot; var->in_changed_variables = false; changed_variables->clear_slot (slot); @@ -8981,7 +8963,7 @@ notify_dependents_of_changed_value (rtx val, variable_table_type *htab, decl_or_value dv = dv_from_rtx (val); slot = changed_variables->find_slot_with_hash (dv, dv_htab_hash (dv), - NO_INSERT); + NO_INSERT); if (!slot) slot = htab->find_slot_with_hash (dv, dv_htab_hash (dv), NO_INSERT); if (!slot)