As the PR shows, we were missing code to update debug uses in the load/store pair fusion pass. This patch fixes that. Note that this patch depends on the following patch to create new uses in RTL-SSA, submitted as part of the fixes for PR113070: https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642919.html The patch tries to give a complete treatment of the debug uses that will be affected by the changes we make, and in particular makes an effort to preserve debug info where possible, e.g. when re-ordering an update of a base register by a constant over a debug use of that register. When re-ordering loads over a debug use of a transfer register, we reset the debug insn. Likewise when re-ordering stores over debug uses of mem. While doing this I noticed that try_promote_writeback used a strange choice of move_range for the pair insn, in that it chose the previous nondebug insn instead of the insn itself. Since the insn is being changed, these move ranges are equivalent (at least in terms of nondebug insn placement as far as RTL-SSA is concerned), but I think it is more natural to choose the pair insn itself. This is needed to avoid incorrectly updating some debug uses. Notes on testing: - The series was bootstrapped/regtested on top of the fixes for PR113070 and PR113356. It seemed to make more sense to test with correct use/def info, and as mentioned above, this patch depends on one of the PR113070 patches. - I also ran the testsuite with -g -funroll-loops -mearly-ldp-fusion -mlate-ldp-fusion to try and flush out more issues, and worked through some examples where writeback updates were triggered to make sure it was doing the right thing. - The patches also survived an LTO+PGO bootstrap with --enable-languages=all (with the passes enabled). Bootstrapped/regtested as a series on aarch64-linux-gnu (with/without the pass enabled). OK for trunk? Thanks, Alex gcc/ChangeLog: PR target/113089 * config/aarch64/aarch64-ldp-fusion.cc (reset_debug_use): New. (fixup_debug_use): New. (fixup_debug_uses_trailing_add): New. (fixup_debug_uses): New. Use it ... (ldp_bb_info::fuse_pair): ... here. (try_promote_writeback): Call fixup_debug_uses_trailing_add to fix up debug uses of the base register that are affected by folding in the trailing add insn. gcc/testsuite/ChangeLog: PR target/113089 * gcc.c-torture/compile/pr113089.c: New test. --- gcc/config/aarch64/aarch64-ldp-fusion.cc | 332 +++++++++++++++++- .../gcc.c-torture/compile/pr113089.c | 26 ++ 2 files changed, 351 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr113089.c