https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92007

--- Comment #17 from iii at gcc dot gnu.org ---
Author: iii
Date: Mon Oct 28 10:04:31 2019
New Revision: 277507

URL: https://gcc.gnu.org/viewcvs?rev=277507&root=gcc&view=rev
Log:
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  <i...@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  <i...@linux.ibm.com>

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

Added:
    trunk/gcc/testsuite/g++.dg/opt/pr92007.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cfgcleanup.c
    trunk/gcc/passes.def
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-pass.h

Reply via email to