aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSegher Boessenkool <segher@kernel.crashing.org>2015-10-11 11:03:09 +0200
committerSegher Boessenkool <segher@gcc.gnu.org>2015-10-11 11:03:09 +0200
commitc70f0ca26b5843498c2d1258865c77b1da545e27 (patch)
tree04a5840f8567588820334a1cb08eabe841a9300d /gcc
parentfac812f0bdd174e727899f2557580418ccf62c55 (diff)
downloadgcc-c70f0ca26b5843498c2d1258865c77b1da545e27.zip
gcc-c70f0ca26b5843498c2d1258865c77b1da545e27.tar.gz
gcc-c70f0ca26b5843498c2d1258865c77b1da545e27.tar.bz2
bb-reorder: Improve the simple algorithm for -Os (PR67864)
As the PR points out, the "simple" reorder algorithm makes bigger code than the STC algorithm did, for -Os, for x86. I now tested it for many different targets and it turns out to be worse everywhere. This simple patch tunes "simple" a bit; this makes it better than STC almost everywhere. The only exceptions (for the targets where I have results) are x86 and mn10300. For those targets it may be best to switch the default algorithm for -Os to STC. 2015-10-11 Segher Boessenkool <segher@kernel.crashing.org> PR rtl-optimization/67864 * gcc/bb-reorder (reorder_basic_blocks_simple): Prefer existing fallthrough edges for conditional jumps. Don't sort candidate edges if not optimizing for speed. From-SVN: r228692
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/bb-reorder.c16
2 files changed, 19 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0599481..3cc9c5c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2015-10-11 Segher Boessenkool <segher@kernel.crashing.org>
+
+ PR rtl-optimization/67864
+ * gcc/bb-reorder (reorder_basic_blocks_simple): Prefer existing
+ fallthrough edges for conditional jumps. Don't sort candidate
+ edges if not optimizing for speed.
+
2015-10-10 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* defaults.h (REVERSE_CONDITION): New default definition.
diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
index cb001e8..3b7098e 100644
--- a/gcc/bb-reorder.c
+++ b/gcc/bb-reorder.c
@@ -2318,16 +2318,24 @@ reorder_basic_blocks_simple (void)
if (any_condjump_p (end))
{
- edges[n++] = EDGE_SUCC (bb, 0);
- edges[n++] = EDGE_SUCC (bb, 1);
+ edge e0 = EDGE_SUCC (bb, 0);
+ edge e1 = EDGE_SUCC (bb, 1);
+ /* When optimizing for size it is best to keep the original
+ fallthrough edges. */
+ if (e1->flags & EDGE_FALLTHRU)
+ std::swap (e0, e1);
+ edges[n++] = e0;
+ edges[n++] = e1;
}
else if (single_succ_p (bb))
edges[n++] = EDGE_SUCC (bb, 0);
}
- /* Sort the edges, the most desirable first. */
+ /* Sort the edges, the most desirable first. When optimizing for size
+ all edges are equally desirable. */
- std::stable_sort (edges, edges + n, edge_order);
+ if (optimize_function_for_speed_p (cfun))
+ std::stable_sort (edges, edges + n, edge_order);
/* Now decide which of those edges to make fallthrough edges. We set
BB_VISITED if a block already has a fallthrough successor assigned