Move jump threading before reload
authorIlya Leoshkevich <iii@linux.ibm.com>
Mon, 28 Oct 2019 10:04:31 +0000 (10:04 +0000)
committerIlya Leoshkevich <iii@gcc.gnu.org>
Mon, 28 Oct 2019 10:04:31 +0000 (10:04 +0000)
commit216779db90e32a7a7f8be2b322208c80666f1e52
treed74628b35ba0dcb86e89d6029f2d3c4c549e4bb8
parent5a0236f8ca9d239bb62ef54c9273e6ca3f068f87
Move jump threading before reload

r266734 has introduced a new instance of jump threading pass in order to
take advantage of opportunities that combine opens up.  It was perceived
back then that it was beneficial to delay it after reload, since that
might produce even more such opportunities.

Unfortunately jump threading interferes with hot/cold partitioning.  In
the code from PR92007, it converts the following

  +-------------------------- 2/HOT ------------------------+
  |                                                         |
  v                                                         v
3/HOT --> 5/HOT --> 8/HOT --> 11/COLD --> 6/HOT --EH--> 16/HOT
            |                               ^
            |                               |
            +-------------------------------+

into the following:

  +---------------------- 2/HOT ------------------+
  |                                               |
  v                                               v
3/HOT --> 8/HOT --> 11/COLD --> 6/COLD --EH--> 16/HOT

This makes hot bb 6 dominated by cold bb 11, and because of this
fixup_partitions makes bb 6 cold as well, which in turn makes EH edge
6->16 a crossing one.  Not only can't we have crossing EH edges, we are
also not allowed to introduce new crossing edges after reload in
general, since it might require extra registers on some targets.

Therefore, move the jump threading pass between combine and hot/cold
partitioning.  Building SPEC 2006 and SPEC 2017 with the old and the new
code indicates that:

* When doing jump threading right after reload, 3889 edges are threaded.
* When doing jump threading right after combine, 3918 edges are
  threaded.

This means this change will not introduce performance regressions.

gcc/ChangeLog:

2019-10-28  Ilya Leoshkevich  <iii@linux.ibm.com>

PR rtl-optimization/92007
* cfgcleanup.c (thread_jump): Add an assertion that we don't
call it after reload if hot/cold partitioning has been done.
(class pass_postreload_jump): Rename to
pass_jump_after_combine.
(make_pass_postreload_jump): Rename to
make_pass_jump_after_combine.
* passes.def(pass_postreload_jump): Move before reload, rename
to pass_jump_after_combine.
* tree-pass.h (make_pass_postreload_jump): Rename to
make_pass_jump_after_combine.

gcc/testsuite/ChangeLog:

2019-10-28  Ilya Leoshkevich  <iii@linux.ibm.com>

PR rtl-optimization/92007
* g++.dg/opt/pr92007.C: New test (from Arseny Solokha).

From-SVN: r277507
gcc/ChangeLog
gcc/cfgcleanup.c
gcc/passes.def
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr92007.C [new file with mode: 0644]
gcc/tree-pass.h