]> git.ipfire.org Git - thirdparty/gcc.git/commit
bb-reorder: Improve compgotos pass (PR71785)
authorsegher <segher@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Nov 2016 09:14:52 +0000 (09:14 +0000)
committersegher <segher@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Nov 2016 09:14:52 +0000 (09:14 +0000)
commit4a5bbe87d7386bf3016adf9f131b32ef6182f782
treeebde0fe578dbf7c9d17463b5f7cca801f81a5bb9
parent8882c20b351d864bc16bfcf12f68d2f826667fd0
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242584 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/bb-reorder.c