Commit 8637b5b0 authored by yb9976's avatar yb9976
Browse files

Improve GCSE heuristic

We now also consider post dominance to find SESE regions
parent 4235d21d
......@@ -180,6 +180,8 @@ void optimize_graph_df(ir_graph *irg)
/* any optimized nodes are stored in the wait queue,
* so if it's not empty, the graph has been changed */
while (!deq_empty(&waitq)) {
assure_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_POSTDOMINANCE);
/* finish the wait queue */
while (!deq_empty(&waitq)) {
ir_node *n = deq_pop_pointer_left(ir_node, &waitq);
......
......@@ -7726,11 +7726,19 @@ static int identities_cmp(const void *elt, const void *key)
/* The optimistic approach would be to do nothing here.
* However doing GCSE optimistically produces a lot of partially dead code which appears
* to be worse in practice than the missed opportunities.
* So we use a very conservative variant here and only CSE if 1 value dominates the
* other. */
* So we use a very conservative variant here and only CSE if one value dominates the
* other or one value postdominates the common dominator. */
if (!block_dominates(block_a, block_b)
&& !block_dominates(block_b, block_a))
return 1;
&& !block_dominates(block_b, block_a)) {
if (get_Block_dom_depth(block_a) < 0
|| get_Block_dom_depth(block_b) < 0)
return 1;
ir_node *dom = ir_deepest_common_dominator(block_a, block_b);
if (!block_postdominates(block_a, dom)
&& !block_postdominates(block_b, dom))
return 1;
}
}
}
......
Supports Markdown
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