https://gcc.gnu.org/g:d90c9f7ae7bf07902954265d62cfa679a7183e0c

commit r17-1916-gd90c9f7ae7bf07902954265d62cfa679a7183e0c
Author: Pengfei Li <[email protected]>
Date:   Sun Jun 21 14:42:12 2026 +0000

    AArch64: Make dispatch scheduling reachable on multi-issue cores
    
    Commit r16-4079-gc8bd7b2d550 added dispatch scheduling for AArch64.
    However, in choose_ready(), the dispatch scheduling path was only
    reachable when dfa_lookahead <= 0, or when the first ready insn was a
    SCHED_GROUP_P insn. Commit r16-6155-g40d0f79577e then made SCHED_GROUP_P
    insns bypass dispatch scheduling to prevent fusion pairs from being
    split. As a result, the DFA lookahead path is preferred and dispatch
    scheduling is effectively disabled for AArch64 multi-issue cores.
    
    dfa_lookahead comes from the hook first_cycle_multipass_dfa_lookahead.
    In current AArch64 implementation, it returns a positive issue rate
    value for multi-issue cores unless sched_fusion is true. This patch adds
    an IS_DISPATCH_ON check to that hook implementation so that the dispatch
    scheduling path is reachable on dispatch-enabled AArch64 cores.
    
    Bootstrapped and tested on aarch64-linux-gnu.
    
    gcc/ChangeLog:
    
            * config/aarch64/aarch64.cc
            (aarch64_sched_first_cycle_multipass_dfa_lookahead): Return 0
            when dispatch scheduling is enabled.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/aarch64/dispatch_sched_1.c: New test.

Diff:
---
 gcc/config/aarch64/aarch64.cc                       |  8 ++++++--
 gcc/testsuite/gcc.target/aarch64/dispatch_sched_1.c | 13 +++++++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 8dc3c43c8120..124e6dc37ccc 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -17191,9 +17191,13 @@ aarch64_sched_variable_issue (FILE *, int, rtx_insn 
*insn, int more)
 static int
 aarch64_sched_first_cycle_multipass_dfa_lookahead (void)
 {
-  int issue_rate = aarch64_sched_issue_rate ();
+  /* Do not use DFA lookahead during sched_fusion or when dispatch
+     scheduling is enabled.  */
+  if (sched_fusion || aarch64_sched_dispatch (NULL, IS_DISPATCH_ON))
+    return 0;
 
-  return issue_rate > 1 && !sched_fusion ? issue_rate : 0;
+  int issue_rate = aarch64_sched_issue_rate ();
+  return issue_rate > 1 ? issue_rate : 0;
 }
 
 
diff --git a/gcc/testsuite/gcc.target/aarch64/dispatch_sched_1.c 
b/gcc/testsuite/gcc.target/aarch64/dispatch_sched_1.c
new file mode 100644
index 000000000000..c2cb74e750db
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/dispatch_sched_1.c
@@ -0,0 +1,13 @@
+/* Check DFA lookahead is not reached when dispatch scheduling is enabled.  */
+/* { dg-do compile } */
+/* { dg-options "-O3 -mcpu=neoverse-v2 -fdump-rtl-sched2-details 
-fsched-verbose=2" } */
+
+void
+foo (int *restrict a, int *restrict b, int *restrict c, int n)
+{
+#pragma GCC unroll 64
+  for (int i = 0; i < n; i++)
+    c[i] += a[i] * b[i];
+}
+
+/* { dg-final { scan-rtl-dump-not "max_issue among" "sched2" } } */

Reply via email to