]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Adjust rangers recomputation depth based on the number of BBs.
authorAndrew MacLeod <amacleod@redhat.com>
Thu, 8 Aug 2024 20:37:28 +0000 (16:37 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Fri, 9 Aug 2024 18:49:46 +0000 (14:49 -0400)
As the number of block increase, recomputations can become more
expensive.  Adjust the depth limit to avoid excessive compile time.

PR tree-optimization/114855
* gimple-range-gori.cc (gori_compute::gori_compute): Adjust
ranger_recompute_depth limit based on the number of BBs.
(gori_compute::may_recompute_p): Use previosuly calculated value.
* gimple-range-gori.h (gori_compute::m_recompute_depth): New.

gcc/gimple-range-gori.cc
gcc/gimple-range-gori.h

index a31e3be65f797243be1a5f6e1e6b82fa63dc22d9..f2e2b5049aaae08220f775237ce7b35ad7f90054 100644 (file)
@@ -567,6 +567,13 @@ gori_compute::gori_compute (gori_map &map, int not_executable_flag,
   m_bool_one = range_true ();
   if (dump_file && (param_ranger_debug & RANGER_DEBUG_GORI))
     tracer.enable_trace ();
+
+  // Reduce maximum recompute depth based on the size of the CFG to avoid
+  // excessive compuations in large CFGs.
+  m_recompute_depth = (int) param_ranger_recompute_depth
+                     - (int) last_basic_block_for_fn (cfun) / 4096;
+  if (m_recompute_depth < 1)
+    m_recompute_depth = 1;
 }
 
 gori_compute::~gori_compute ()
@@ -1327,10 +1334,7 @@ gori_compute::may_recompute_p (tree name, basic_block bb, int depth)
     {
       // -1 indicates a default param, convert it to the real default.
       if (depth == -1)
-       {
-         depth = (int)param_ranger_recompute_depth;
-         gcc_checking_assert (depth >= 1);
-       }
+       depth = m_recompute_depth;
 
       bool res = m_map.is_export_p (dep1, bb);
       if (res || depth <= 1)
index 11019e38471e067ca3681d23faebb90a0a16e2df..97e051cd31703e886a2abc0f1edbe89feeed2c42 100644 (file)
@@ -206,6 +206,7 @@ private:
 
   range_tracer tracer;
   int m_not_executable_flag;
+  int m_recompute_depth;
 };
 
 // These APIs are used to query GORI if there are ranges generated on an edge.