From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7810) id C05813858409; Tue, 23 Jan 2024 13:24:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C05813858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706016282; bh=3owPpujo+OqzOC2QPXninJQl2tYvDKmQyzWMtdJjoMA=; h=From:To:Subject:Date:From; b=PlB9QMWajOJhmnnK3pXYRSJtKO9+HJA/2rplGfUkh/eP5/ib/uiLc44ZqagpIY8NT bJFYVYywmpb+UR2R7QO9xiJyh6NTGB18pUNobuxzjfQnPMDNTkNMXmOOg8XhceYjWU HP9fSVJYSSqJT4GACiYNQRrZT65PKsuEjun23+n0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Alex Coplan To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8359] rtl-ssa: Support for creating new uses [PR113070] X-Act-Checkin: gcc X-Git-Author: Alex Coplan X-Git-Refname: refs/heads/master X-Git-Oldrev: e0374b028a665a2ea8d6eb2b4e5862774e9e85c2 X-Git-Newrev: fce3994d04fc5d7d1c91f6db5a1f144aa291439a Message-Id: <20240123132442.C05813858409@sourceware.org> Date: Tue, 23 Jan 2024 13:24:42 +0000 (GMT) List-Id: https://gcc.gnu.org/g:fce3994d04fc5d7d1c91f6db5a1f144aa291439a commit r14-8359-gfce3994d04fc5d7d1c91f6db5a1f144aa291439a Author: Alex Coplan Date: Fri Jan 12 10:14:33 2024 +0000 rtl-ssa: Support for creating new uses [PR113070] This exposes an interface for users to create new uses in RTL-SSA. This is needed for updating uses after inserting a new store pair insn in the aarch64 load/store pair fusion pass. gcc/ChangeLog: PR target/113070 * rtl-ssa/accesses.cc (function_info::create_use): New. * rtl-ssa/changes.cc (function_info::finalize_new_accesses): Ensure new uses end up referring to permanent defs. * rtl-ssa/functions.h (function_info::create_use): Declare. Diff: --- gcc/rtl-ssa/accesses.cc | 10 ++++++++++ gcc/rtl-ssa/changes.cc | 20 ++++++++++++++++---- gcc/rtl-ssa/functions.h | 7 +++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/gcc/rtl-ssa/accesses.cc b/gcc/rtl-ssa/accesses.cc index ce4a8b8dc00..3f1304fc5bf 100644 --- a/gcc/rtl-ssa/accesses.cc +++ b/gcc/rtl-ssa/accesses.cc @@ -1466,6 +1466,16 @@ function_info::create_set (obstack_watermark &watermark, return set; } +use_info * +function_info::create_use (obstack_watermark &watermark, + insn_info *insn, + set_info *set) +{ + auto use = change_alloc (watermark, insn, set->resource (), set); + use->m_is_temp = true; + return use; +} + // Return true if ACCESS1 can represent ACCESS2 and if ACCESS2 can // represent ACCESS1. static bool diff --git a/gcc/rtl-ssa/changes.cc b/gcc/rtl-ssa/changes.cc index e538b637848..8181e5248c5 100644 --- a/gcc/rtl-ssa/changes.cc +++ b/gcc/rtl-ssa/changes.cc @@ -609,15 +609,27 @@ function_info::finalize_new_accesses (insn_change &change, insn_info *pos) m_temp_uses[i] = use = allocate (*use); use->m_is_temp = false; set_info *def = use->def (); - // Handle cases in which the value was previously not used - // within the block. - if (def && def->m_is_temp) + if (!def || !def->m_is_temp) + continue; + + if (auto phi = dyn_cast (def)) { - phi_info *phi = as_a (def); + // Handle cases in which the value was previously not used + // within the block. gcc_assert (phi->is_degenerate ()); phi = create_degenerate_phi (phi->ebb (), phi->input_value (0)); use->set_def (phi); } + else + { + // The temporary def may also be a set added with this change, in + // which case the permanent set is stored in the last_def link, + // and we need to update the use to refer to the permanent set. + gcc_assert (is_a (def)); + auto perm_set = as_a (def->last_def ()); + gcc_assert (!perm_set->is_temporary ()); + use->set_def (perm_set); + } } } diff --git a/gcc/rtl-ssa/functions.h b/gcc/rtl-ssa/functions.h index 58d0b50ea83..e00a398069a 100644 --- a/gcc/rtl-ssa/functions.h +++ b/gcc/rtl-ssa/functions.h @@ -73,6 +73,13 @@ public: insn_info *insn, resource_info resource); + // Create a temporary use of SET as part of a change to INSN. + // SET can be a pre-existing definition or one that is being created + // as part of the same change group. + use_info *create_use (obstack_watermark &watermark, + insn_info *insn, + set_info *set); + // Create a temporary insn with code INSN_CODE and pattern PAT. insn_info *create_insn (obstack_watermark &watermark, rtx_code insn_code,