]> gcc.gnu.org Git - gcc.git/commit
tree-optimization/108352 - FSM threads creating irreducible loops
authorRichard Biener <rguenther@suse.de>
Wed, 11 Jan 2023 11:07:16 +0000 (12:07 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 11 Jan 2023 11:59:12 +0000 (12:59 +0100)
commit7c9f20fcfdc2d8453df88ceb7e693debfcd678c0
treeae9ddd3b4be364259c04da871207ce9c95921efd
parent445a48a226ffd530b37bcdc13b6bdca94ba2e122
tree-optimization/108352 - FSM threads creating irreducible loops

The following relaxes a heuristic that prevents creating irreducible
loops from FSM threads not covering multi-way branches.  Instead of
allowing threads that adhere to

      && (n_insns * (unsigned) param_fsm_scale_path_stmts
          > (m_path.length () *
             (unsigned) param_fsm_scale_path_blocks))

with reasoning "We also consider it worth creating an irreducible inner loop if
the number of copied statement is low relative to the length of the path --
in that case there's little the traditional loop optimizer would have done
anyway, so an irreducible loop is not so bad." that I cannot make much
sense of the following patch changes that to only allow those after
loop optimization and when they are (scaled) short:

      && (!(cfun->curr_properties & PROP_loop_opts_done)
          || (m_n_insns * param_fsm_scale_path_stmts
              >= param_max_jump_thread_duplication_stmts)))

This allows us to get rid of --param fsm-scale-path-blocks which
previous to the bisected revision allowed an enlarged path covering
the original allowance (but we do not consider that enlarged path
now because enlarging it doesn't add any information).

PR tree-optimization/108352
* tree-ssa-threadbackward.cc
(back_threader_profitability::profitable_path_p): Adjust
heuristic that allows non-multi-way branch threads creating
irreducible loops.
* doc/invoke.texi (--param fsm-scale-path-blocks): Remove.
(--param fsm-scale-path-stmts): Adjust.
* params.opt (--param=fsm-scale-path-blocks=): Remove.
(-param=fsm-scale-path-stmts=): Adjust description.

* gcc.dg/tree-ssa/ssa-thread-21.c: New testcase.
* gcc.dg/tree-ssa/vrp46.c: Remove --param fsm-scale-path-blocks=1.
gcc/doc/invoke.texi
gcc/params.opt
gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-21.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/vrp46.c
gcc/tree-ssa-threadbackward.cc
This page took 0.06556 seconds and 5 git commands to generate.