The narrow_gp_writes pass uses RTL-SSA and updates DF state via
df_insn_rescan / df_insn_delete. Both routines look up the insn's bb via
BLOCK_FOR_INSN to mark it dirty after a change, but pass_free_cfg has already
cleared those per-insn pointers by the time narrow_gp_writes runs. When
BLOCK_FOR_INSN returns NULL, the dirty-marking step is silently skipped,
leaving the DF stale.
Move the pass to run before pass_free_cfg.
Bootstrapped and regtested on aarch64-linux-gnu.
SPEC CPU 2017 shows no codegen differences (compared to previous placement).
OK for trunk?
Signed-off-by: Soumya AR <soumyaa@nvidia.com>
PR target/124895
gcc/ChangeLog:
* config/aarch64/aarch64-passes.def (pass_narrow_gp_writes): Move pass
before pass_free_cfg.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/narrow-gp-writes-8.c: New test.
INSERT_PASS_BEFORE (pass_shorten_branches, 1, pass_insert_bti);
INSERT_PASS_BEFORE (pass_early_remat, 1, pass_ldp_fusion);
INSERT_PASS_BEFORE (pass_peephole2, 1, pass_ldp_fusion);
-INSERT_PASS_BEFORE (pass_cleanup_barriers, 1, pass_narrow_gp_writes);
+INSERT_PASS_BEFORE (pass_free_cfg, 1, pass_narrow_gp_writes);
--- /dev/null
+/* PR target/124895 */
+/* { dg-do compile } */
+/* { dg-options "-Os -fpath-coverage -fno-tree-ccp -fprofile-generate -mnarrow-gp-writes" } */
+
+void
+foo (unsigned u)
+{
+ while (u)
+ ;
+}