From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7810) id DD7CA385841F; Tue, 23 Jan 2024 16:50:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DD7CA385841F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706028659; bh=SLTKSgQA19Q6w6LWP952gwU4EzTBNU9VkZhcC7HF0y8=; h=From:To:Subject:Date:From; b=m6bJV3jVzdIHJtMIOwjGPJ9XiIk5m0EWp88nS0y+m8a6ULa1puC/VT+/H1rN7pFCH dDrqh3NgOucnMAcJ/vpFXdhtti1ELPkeLx2ZEOvGwc7weRCceS2C91ZUy09TG77uTA X1tEBYYJVAwtlaQkcxowzYHQtDkixWtu6UYgCfZA= 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-8369] aarch64: Re-parent trailing nondebug base reg uses [PR113089] X-Act-Checkin: gcc X-Git-Author: Alex Coplan X-Git-Refname: refs/heads/master X-Git-Oldrev: cef6031694db1d68cf876e16e79dc5c2b9f649bd X-Git-Newrev: 49bfda6017e105df46fa8d12d7f067da423a1d3c Message-Id: <20240123165059.DD7CA385841F@sourceware.org> Date: Tue, 23 Jan 2024 16:50:59 +0000 (GMT) List-Id: https://gcc.gnu.org/g:49bfda6017e105df46fa8d12d7f067da423a1d3c commit r14-8369-g49bfda6017e105df46fa8d12d7f067da423a1d3c Author: Alex Coplan Date: Mon Jan 15 17:13:06 2024 +0000 aarch64: Re-parent trailing nondebug base reg uses [PR113089] While working on PR113089, I realised we where missing code to re-parent trailing nondebug uses of the base register in the case of cancelling writeback in the load/store pair pass. This patch fixes that. gcc/ChangeLog: PR target/113089 * config/aarch64/aarch64-ldp-fusion.cc (ldp_bb_info::fuse_pair): Update trailing nondebug uses of the base register in the case of cancelling writeback. Diff: --- gcc/config/aarch64/aarch64-ldp-fusion.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gcc/config/aarch64/aarch64-ldp-fusion.cc b/gcc/config/aarch64/aarch64-ldp-fusion.cc index bbb95d6c820..e3827e98010 100644 --- a/gcc/config/aarch64/aarch64-ldp-fusion.cc +++ b/gcc/config/aarch64/aarch64-ldp-fusion.cc @@ -1693,6 +1693,30 @@ ldp_bb_info::fuse_pair (bool load_p, if (trailing_add) changes.safe_push (make_delete (trailing_add)); + else if ((writeback & 2) && !writeback_effect) + { + // The second insn initially had writeback but now the pair does not, + // need to update any nondebug uses of the base register def in the + // second insn. We'll take care of debug uses later. + auto def = find_access (insns[1]->defs (), base_regno); + gcc_assert (def); + auto set = dyn_cast (def); + if (set && set->has_nondebug_uses ()) + { + auto orig_use = find_access (insns[0]->uses (), base_regno); + for (auto use : set->nondebug_insn_uses ()) + { + auto change = make_change (use->insn ()); + change->new_uses = check_remove_regno_access (attempt, + change->new_uses, + base_regno); + change->new_uses = insert_access (attempt, + orig_use, + change->new_uses); + changes.safe_push (change); + } + } + } auto is_changing = insn_is_changing (changes); for (unsigned i = 0; i < changes.length (); i++)