Currently we scale the number of stmts allowed for forward jump threading to limit those for backwards jump threading by applying a factor of two to the counted stmts. That doesn't allow fine-grained adjustments, like by a single stmt as needed for PR109893. The following changes the factor to be a percentage of the forward threading number.
Bootstrapped and tested on x86_64-unknown-linux-gnu. Any opinion on whether I should change the param name when I change its meaning? * params.opt (fsm-scale-path-stmts): Change to percentage. * doc/invoke.texi (--param fsm-scale-path-stmts): Adjust. * tree-ssa-threadbackward.cc (back_threader_profitability::possibly_profitable_path_p): Adjust param_fsm_scale_path_stmts uses. (back_threader_profitability::profitable_path_p): Likewise. --- gcc/doc/invoke.texi | 4 ++-- gcc/params.opt | 4 ++-- gcc/tree-ssa-threadbackward.cc | 17 +++++++++-------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 74f5ee26042..1a0a507dddc 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -17462,8 +17462,8 @@ Maximum number of arrays per scop. Max. size of loc list for which reverse ops should be added. @item fsm-scale-path-stmts -Scale factor to apply to the number of statements in a threading path -crossing a loop backedge when comparing to +Percentage of max-jump-thread-duplication-stmts to allow for the number of +statements in a threading path crossing a loop backedge. @option{--param=max-jump-thread-duplication-stmts}. @item uninit-control-dep-attempts diff --git a/gcc/params.opt b/gcc/params.opt index 31aa0bd5753..0a1dfb46dd1 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -143,8 +143,8 @@ Common Joined UInteger Var(param_file_cache_lines) Init(0) Param Max number of lines to index into file cache. When 0 this is automatically sized. -param=fsm-scale-path-stmts= -Common Joined UInteger Var(param_fsm_scale_path_stmts) Init(2) IntegerRange(1, 10) Param Optimization -Scale factor to apply to the number of statements in a threading path crossing a loop backedge when comparing to max-jump-thread-duplication-stmts. +Common Joined UInteger Var(param_fsm_scale_path_stmts) Init(50) IntegerRange(1, 100) Param Optimization +Percentage of max-jump-thread-duplication-stmts to allow for the number of statements in a threading path crossing a loop backedge. -param=fully-pipelined-fma= Common Joined UInteger Var(param_fully_pipelined_fma) Init(0) IntegerRange(0, 1) Param Optimization diff --git a/gcc/tree-ssa-threadbackward.cc b/gcc/tree-ssa-threadbackward.cc index 3adb83e9712..ce765cb5ded 100644 --- a/gcc/tree-ssa-threadbackward.cc +++ b/gcc/tree-ssa-threadbackward.cc @@ -739,8 +739,8 @@ back_threader_profitability::possibly_profitable_path_p if ((!m_threaded_multiway_branch || !loop->latch || loop->latch->index == EXIT_BLOCK) - && (m_n_insns * param_fsm_scale_path_stmts - >= param_max_jump_thread_duplication_stmts)) + && (m_n_insns * 100 >= (param_max_jump_thread_duplication_stmts + * param_fsm_scale_path_stmts))) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, @@ -749,8 +749,9 @@ back_threader_profitability::possibly_profitable_path_p return false; } *large_non_fsm = (!(m_threaded_through_latch && m_threaded_multiway_branch) - && (m_n_insns * param_fsm_scale_path_stmts - >= param_max_jump_thread_duplication_stmts)); + && (m_n_insns * 100 + >= (param_max_jump_thread_duplication_stmts + * param_fsm_scale_path_stmts))); if (dump_file && (dump_flags & TDF_DETAILS)) fputc ('\n', dump_file); @@ -823,8 +824,8 @@ back_threader_profitability::profitable_path_p (const vec<basic_block> &m_path, if (!m_threaded_multiway_branch && *creates_irreducible_loop && (!(cfun->curr_properties & PROP_loop_opts_done) - || (m_n_insns * param_fsm_scale_path_stmts - >= param_max_jump_thread_duplication_stmts))) + || (m_n_insns * 100 >= (param_max_jump_thread_duplication_stmts + * param_fsm_scale_path_stmts)))) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, @@ -839,8 +840,8 @@ back_threader_profitability::profitable_path_p (const vec<basic_block> &m_path, case, drastically reduce the number of statements we are allowed to copy. */ if (!(m_threaded_through_latch && m_threaded_multiway_branch) - && (m_n_insns * param_fsm_scale_path_stmts - >= param_max_jump_thread_duplication_stmts)) + && (m_n_insns * 100 >= (param_max_jump_thread_duplication_stmts + * param_fsm_scale_path_stmts))) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, -- 2.43.0