]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Move pass_narrow_gp_writes above pass_free_cfg
authorSoumya AR <soumyaa@nvidia.com>
Wed, 6 May 2026 05:39:55 +0000 (05:39 +0000)
committerSoumya AR <soumyaa@nvidia.com>
Fri, 8 May 2026 06:58:48 +0000 (12:28 +0530)
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.

gcc/config/aarch64/aarch64-passes.def
gcc/testsuite/gcc.target/aarch64/narrow-gp-writes-8.c [new file with mode: 0644]

index f4307aab551c239738f0c0f0e4dc7a66f3627ad9..2df7459af92c251bb47b1c8b7464fd8738b324d6 100644 (file)
@@ -26,4 +26,4 @@ INSERT_PASS_BEFORE (pass_late_thread_prologue_and_epilogue, 1, pass_late_track_s
 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);
diff --git a/gcc/testsuite/gcc.target/aarch64/narrow-gp-writes-8.c b/gcc/testsuite/gcc.target/aarch64/narrow-gp-writes-8.c
new file mode 100644 (file)
index 0000000..94ef761
--- /dev/null
@@ -0,0 +1,10 @@
+/* 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)
+    ;
+}