]> git.ipfire.org Git - thirdparty/gcc.git/commit
bb-reorder: Improve compgotos pass (PR71785)
authorSegher Boessenkool <segher@kernel.crashing.org>
Fri, 18 Nov 2016 09:14:52 +0000 (10:14 +0100)
committerSegher Boessenkool <segher@gcc.gnu.org>
Fri, 18 Nov 2016 09:14:52 +0000 (10:14 +0100)
commitcd36a4518d14aae18ac89a6232e009ee2bcb6008
treeebde0fe578dbf7c9d17463b5f7cca801f81a5bb9
parent9bd0f0bc6b3ff066b6a0e0fff1791d66545689fd
bb-reorder: Improve compgotos pass (PR71785)

For code like the testcase in PR71785 GCC factors all the indirect branches
to a single dispatcher that then everything jumps to.  This is because
having many indirect branches with each many jump targets does not scale
in large parts of the compiler.  Very late in the pass pipeline (right
before peephole2) the indirect branches are then unfactored again, by
the duplicate_computed_gotos pass.

This pass works by replacing branches to such a common dispatcher by a
copy of the dispatcher.  For code like this testcase this does not work
so well: most cases do a single addition instruction right before the
dispatcher, but not all, and we end up with only two indirect jumps: the
one without the addition, and the one with the addition in its own basic
block, and now everything else jumps _there_.

This patch rewrites the algorithm to deal with this.  It also makes it
simpler: it does not need the "candidates" array anymore, it does not
need RTL layout mode, it does not need cleanup_cfg, and it does not
need to keep track of what blocks it already visited.

PR rtl-optimization/71785
* bb-reorder.c (maybe_duplicate_computed_goto): New function.
(duplicate_computed_gotos): New function.
(pass_duplicate_computed_gotos::execute): Rewrite.

From-SVN: r242584
gcc/ChangeLog
gcc/bb-reorder.c