https://gcc.gnu.org/g:9e4da946c4263a4c89d5fc365b3c97ae244c5018
commit r15-2858-g9e4da946c4263a4c89d5fc365b3c97ae244c5018 Author: Andrew MacLeod <amacl...@redhat.com> Date: Thu Aug 8 16:37:28 2024 -0400 Adjust rangers recomputation depth based on the number of BBs. 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. Diff: --- gcc/gimple-range-gori.cc | 12 ++++++++---- gcc/gimple-range-gori.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index a31e3be65f79..f2e2b5049aaa 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -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) diff --git a/gcc/gimple-range-gori.h b/gcc/gimple-range-gori.h index 11019e38471e..97e051cd3170 100644 --- a/gcc/gimple-range-gori.h +++ b/gcc/gimple-range-gori.h @@ -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.