Commit 375374ad by Richard Biener Committed by Richard Biener

re PR rtl-optimization/69609 (block reordering consumes an inordinate amount of…

re PR rtl-optimization/69609 (block reordering consumes an inordinate amount of time, REE consumes much memory)

2016-02-17  Richard Biener  <rguenther@suse.de>

	PR rtl-optimization/69609
	* bb-reorder.c (struct bbro_basic_block_data): Add priority member.
	(find_traces_1_round): When ending a trace update cached priority
	of successors.
	(bb_to_key): Use cached priority when available.
	(copy_bb): Initialize cached priority.
	(reorder_basic_blocks_software_trace_cache): Likewise.

From-SVN: r233498
parent 57bfb134
2016-02-17 Richard Biener <rguenther@suse.de>
PR rtl-optimization/69609
* bb-reorder.c (struct bbro_basic_block_data): Add priority member.
(find_traces_1_round): When ending a trace update cached priority
of successors.
(bb_to_key): Use cached priority when available.
(copy_bb): Initialize cached priority.
(reorder_basic_blocks_software_trace_cache): Likewise.
2016-02-17 Kyrylo Tkachov <kyrylo.tkachov@arm.com> 2016-02-17 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR target/69161 PR target/69161
......
...@@ -157,6 +157,10 @@ struct bbro_basic_block_data ...@@ -157,6 +157,10 @@ struct bbro_basic_block_data
/* Which trace was this bb visited in? */ /* Which trace was this bb visited in? */
int visited; int visited;
/* Cached maximum frequency of interesting incoming edges.
Minus one means not yet computed. */
int priority;
/* Which heap is BB in (if any)? */ /* Which heap is BB in (if any)? */
bb_heap_t *heap; bb_heap_t *heap;
...@@ -775,7 +779,15 @@ find_traces_1_round (int branch_th, int exec_th, gcov_type count_th, ...@@ -775,7 +779,15 @@ find_traces_1_round (int branch_th, int exec_th, gcov_type count_th,
while (best_edge); while (best_edge);
trace->last = bb; trace->last = bb;
bbd[trace->first->index].start_of_trace = *n_traces - 1; bbd[trace->first->index].start_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; 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 /* 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 (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) ...@@ -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].end_of_trace = -1;
bbd[i].in_trace = -1; bbd[i].in_trace = -1;
bbd[i].visited = 0; bbd[i].visited = 0;
bbd[i].priority = -1;
bbd[i].heap = NULL; bbd[i].heap = NULL;
bbd[i].node = NULL; bbd[i].node = NULL;
} }
...@@ -875,7 +888,6 @@ bb_to_key (basic_block bb) ...@@ -875,7 +888,6 @@ bb_to_key (basic_block bb)
{ {
edge e; edge e;
edge_iterator ei; edge_iterator ei;
int priority = 0;
/* Use index as key to align with its original order. */ /* Use index as key to align with its original order. */
if (optimize_function_for_size_p (cfun)) if (optimize_function_for_size_p (cfun))
...@@ -889,6 +901,10 @@ bb_to_key (basic_block bb) ...@@ -889,6 +901,10 @@ bb_to_key (basic_block bb)
/* Prefer blocks whose predecessor is an end of some trace /* Prefer blocks whose predecessor is an end of some trace
or whose predecessor edge is EDGE_DFS_BACK. */ or whose predecessor edge is EDGE_DFS_BACK. */
int priority = bbd[bb->index].priority;
if (priority == -1)
{
priority = 0;
FOR_EACH_EDGE (e, ei, bb->preds) FOR_EACH_EDGE (e, ei, bb->preds)
{ {
if ((e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun) if ((e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun)
...@@ -901,6 +917,8 @@ bb_to_key (basic_block bb) ...@@ -901,6 +917,8 @@ bb_to_key (basic_block bb)
priority = edge_freq; priority = edge_freq;
} }
} }
bbd[bb->index].priority = priority;
}
if (priority) if (priority)
/* The block with priority should have significantly lower key. */ /* The block with priority should have significantly lower key. */
...@@ -2253,6 +2271,7 @@ reorder_basic_blocks_software_trace_cache (void) ...@@ -2253,6 +2271,7 @@ reorder_basic_blocks_software_trace_cache (void)
bbd[i].end_of_trace = -1; bbd[i].end_of_trace = -1;
bbd[i].in_trace = -1; bbd[i].in_trace = -1;
bbd[i].visited = 0; bbd[i].visited = 0;
bbd[i].priority = -1;
bbd[i].heap = NULL; bbd[i].heap = NULL;
bbd[i].node = NULL; bbd[i].node = NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment