]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/114589 - remove profile based sink heuristics
authorRichard Biener <rguenther@suse.de>
Fri, 3 May 2024 12:04:41 +0000 (14:04 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 15 May 2024 16:13:09 +0000 (18:13 +0200)
commit99b1daae18c095d6c94d32efb77442838e11cbfb
treefeab3dd1868aa58c11d22c0d447623caebc2cec7
parentab25eef36400e8c1d28e3ed059c5f95a38b45f17
tree-optimization/114589 - remove profile based sink heuristics

The following removes the profile based heuristic limiting sinking
and instead uses post-dominators to avoid sinking to places that
are executed under the same conditions as the earlier location which
the profile based heuristic should have guaranteed as well.

To avoid regressing this moves the empty-latch check to cover all
sink cases.

It also stream-lines the resulting select_best_block a bit but avoids
adjusting heuristics more with this change.  gfortran.dg/streamio_9.f90
starts execute failing with this on x86_64 with -m32 because the
(float)i * 9.9999...e-7 compute is sunk across a STOP causing it
to be no longer spilled and thus the compare failing due to excess
precision.  The patch adds -ffloat-store to avoid this, following
other similar testcases.

This change fixes the testcase in the PR only when using -fno-ivopts
as otherwise VRP is confused.

PR tree-optimization/114589
* tree-ssa-sink.cc (select_best_block): Remove profile-based
heuristics.  Instead reject sink locations that sink
to post-dominators.  Move empty latch check here from
statement_sink_location.  Also consider early_bb for the
loop depth check.
(statement_sink_location): Remove superfluous check.  Remove
empty latch check.
(pass_sink_code::execute): Compute/release post-dominators.

* gfortran.dg/streamio_9.f90: Use -ffloat-store to avoid
excess precision when not spilling.
* g++.dg/tree-ssa/pr114589.C: New testcase.
gcc/testsuite/g++.dg/tree-ssa/pr114589.C [new file with mode: 0644]
gcc/testsuite/gfortran.dg/streamio_9.f90
gcc/tree-ssa-sink.cc