https://gcc.gnu.org/g:afa9dd3769077c50180865f53bf2ff8abb0a2f97
commit r17-4226-gafa9dd3769077c50180865f53bf2ff8abb0a2f97 Author: xiezhiheng <[email protected]> Date: Mon Sep 14 02:23:06 2026 +0000 sched: Cap max_lookahead_tries Issue_rate values on modern cores keep increasing, and the maximum issue_rate in the AArch64 backend has reached 10, causing an overflow in the calculation of max_lookahead_tries. Fix it. gcc/ChangeLog: * haifa-sched.cc (max_issue): Cap max_lookahead_tries Diff: --- gcc/haifa-sched.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gcc/haifa-sched.cc b/gcc/haifa-sched.cc index 879749e9785d..17457dd0ac48 100644 --- a/gcc/haifa-sched.cc +++ b/gcc/haifa-sched.cc @@ -5956,9 +5956,14 @@ max_issue (struct ready_list *ready, int privileged_n, state_t state, /* Init MAX_LOOKAHEAD_TRIES. */ if (max_lookahead_tries == 0) { - max_lookahead_tries = 100; + int64_t max_tries = 100; for (i = 0; i < issue_rate; i++) - max_lookahead_tries *= dfa_lookahead; + { + max_tries *= dfa_lookahead; + if (max_tries > INT_MAX) + break; + } + max_lookahead_tries = MIN (max_tries, INT_MAX); } /* Init max_points. */ @@ -6054,7 +6059,9 @@ max_issue (struct ready_list *ready, int privileged_n, state_t state, else if (!ready_try [i]) { tries_num++; - if (tries_num > max_lookahead_tries) + /* max_lookahead_tries is capped at INT_MAX, use the >= comparison + to prevent tries_num from overflowing. */ + if (tries_num >= max_lookahead_tries) break; insn = ready_element (ready, i); delay = state_transition (state, insn);
