In the AArch64 backend, dfa_lookahead generally returns issue_rate,
so max_lookahead_tries is set to 100 * issue_rate ** issue_rate.
As issue_rate values for modern AArch64 cores increase, this can become
very large. For example, the hip12 core has an issue_rate of 8, which
makes max_lookahead_tries 1,677,721,600 and causes very long compile times.
Another example is Cortex-X925, whose issue_rate is 10,
this causes an overflow in the computation, and max_lookahead_tries ends up
being 0. Therefore, this patch caps max_lookahead_tries at 1,000,000.
Not sure whether this value is appropriate, any comments?



With issue_rate values on modern cores continuing to increase,
max_lookahead_tries grows exponentially. Cap max_lookahead_tries
to avoid excessively long compile times.

Bootstrapped and tested on aarch64-linux-gnu and x86_64-linux-gnu, no 
regression.

gcc/ChangeLog:

        * haifa-sched.cc (max_issue): cap max_lookahead_tries
---
 gcc/haifa-sched.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/haifa-sched.cc b/gcc/haifa-sched.cc
index 879749e9785..7f3fd5b496a 100644
--- a/gcc/haifa-sched.cc
+++ b/gcc/haifa-sched.cc
@@ -5956,9 +5956,10 @@ 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;
+      max_lookahead_tries = MIN (max_tries, (int64_t) 1000000);
     }
 
   /* Init max_points.  */

Attachment: 0001-sched-Cap-max_lookahead_tries.patch
Description: 0001-sched-Cap-max_lookahead_tries.patch

Reply via email to