summaryrefslogtreecommitdiff
path: root/gcc/bb-reorder.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2016-04-17 11:37:12 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2016-04-17 11:37:12 +0000
commit10bc620ff573f2d1059378d0684bdf985028fe6d (patch)
tree2686bd58e4311af8f17902454d2c7509c057d67c /gcc/bb-reorder.c
parentbd356bb6d247b18723734d4d1d0b32191cfb1a9a (diff)
downloadgcc-10bc620ff573f2d1059378d0684bdf985028fe6d.tar.gz
2016-04-17 Basile Starynkevitch <basile@starynkevitch.net>
{{merging with even more of GCC 6, using subversion 1.9 svn merge -r233051:233720 ^/trunk }} git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@235079 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/bb-reorder.c')
-rw-r--r--gcc/bb-reorder.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
index 8cbde89b5e1..5fb60bde762 100644
--- a/gcc/bb-reorder.c
+++ b/gcc/bb-reorder.c
@@ -157,6 +157,10 @@ struct bbro_basic_block_data
/* Which trace was this bb visited in? */
int visited;
+ /* Cached maximum frequency of interesting incoming edges.
+ Minus one means not yet computed. */
+ int priority;
+
/* Which heap is BB in (if any)? */
bb_heap_t *heap;
@@ -775,7 +779,15 @@ find_traces_1_round (int branch_th, int exec_th, gcov_type count_th,
while (best_edge);
trace->last = bb;
bbd[trace->first->index].start_of_trace = *n_traces - 1;
- bbd[trace->last->index].end_of_trace = *n_traces - 1;
+ if (bbd[trace->last->index].end_of_trace != *n_traces - 1)
+ {
+ bbd[trace->last->index].end_of_trace = *n_traces - 1;
+ /* Update the cached maximum frequency for interesting predecessor
+ edges for successors of the new trace end. */
+ FOR_EACH_EDGE (e, ei, trace->last->succs)
+ if (EDGE_FREQUENCY (e) > bbd[e->dest->index].priority)
+ bbd[e->dest->index].priority = EDGE_FREQUENCY (e);
+ }
/* The trace is terminated so we have to recount the keys in heap
(some block can have a lower key because now one of its predecessors
@@ -845,6 +857,7 @@ copy_bb (basic_block old_bb, edge e, basic_block bb, int trace)
bbd[i].end_of_trace = -1;
bbd[i].in_trace = -1;
bbd[i].visited = 0;
+ bbd[i].priority = -1;
bbd[i].heap = NULL;
bbd[i].node = NULL;
}
@@ -875,7 +888,6 @@ bb_to_key (basic_block bb)
{
edge e;
edge_iterator ei;
- int priority = 0;
/* Use index as key to align with its original order. */
if (optimize_function_for_size_p (cfun))
@@ -889,17 +901,23 @@ bb_to_key (basic_block bb)
/* Prefer blocks whose predecessor is an end of some trace
or whose predecessor edge is EDGE_DFS_BACK. */
- FOR_EACH_EDGE (e, ei, bb->preds)
+ int priority = bbd[bb->index].priority;
+ if (priority == -1)
{
- if ((e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun)
- && bbd[e->src->index].end_of_trace >= 0)
- || (e->flags & EDGE_DFS_BACK))
+ priority = 0;
+ FOR_EACH_EDGE (e, ei, bb->preds)
{
- int edge_freq = EDGE_FREQUENCY (e);
+ if ((e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun)
+ && bbd[e->src->index].end_of_trace >= 0)
+ || (e->flags & EDGE_DFS_BACK))
+ {
+ int edge_freq = EDGE_FREQUENCY (e);
- if (edge_freq > priority)
- priority = edge_freq;
+ if (edge_freq > priority)
+ priority = edge_freq;
+ }
}
+ bbd[bb->index].priority = priority;
}
if (priority)
@@ -2253,6 +2271,7 @@ reorder_basic_blocks_software_trace_cache (void)
bbd[i].end_of_trace = -1;
bbd[i].in_trace = -1;
bbd[i].visited = 0;
+ bbd[i].priority = -1;
bbd[i].heap = NULL;
bbd[i].node = NULL;
}