aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-08-03 15:41:16 +0200
committerRichard Biener <rguenther@suse.de>2023-08-07 15:21:19 +0200
commitd8efc44d00ced7a45c2a1ea886e48f872cde9e0f (patch)
tree6f7563cc02844344bfb32566e246425f8a63d106 /gcc
parentaf6cfd7b663909688c6ca55b6e9f859cdde4310f (diff)
downloadgcc-d8efc44d00ced7a45c2a1ea886e48f872cde9e0f.zip
gcc-d8efc44d00ced7a45c2a1ea886e48f872cde9e0f.tar.gz
gcc-d8efc44d00ced7a45c2a1ea886e48f872cde9e0f.tar.bz2
Use RPO order for sinking
The following makes us use RPO order instead of walking post-dominators. This ensures we visit a block before any predecessors. I've seen some extra sinking because of this in a larger testcase but failed to reduce a smaller one (processing of post-dominator sons is unordered so I failed to have "luck"). * tree-ssa-sink.cc (pass_sink_code::execute): Do not calculate post-dominators. Calculate RPO on the inverted graph and process blocks in that order.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/tree-ssa-sink.cc19
1 files changed, 5 insertions, 14 deletions
diff --git a/gcc/tree-ssa-sink.cc b/gcc/tree-ssa-sink.cc
index 5cf9e73..6ad9d21 100644
--- a/gcc/tree-ssa-sink.cc
+++ b/gcc/tree-ssa-sink.cc
@@ -824,26 +824,17 @@ pass_sink_code::execute (function *fun)
connect_infinite_loops_to_exit ();
memset (&sink_stats, 0, sizeof (sink_stats));
calculate_dominance_info (CDI_DOMINATORS);
- calculate_dominance_info (CDI_POST_DOMINATORS);
virtual_operand_live vop_live;
- auto_vec<basic_block, 64> worklist;
- worklist.quick_push (EXIT_BLOCK_PTR_FOR_FN (fun));
- do
- {
- basic_block bb = worklist.pop ();
- todo |= sink_code_in_bb (bb, vop_live);
- for (basic_block son = first_dom_son (CDI_POST_DOMINATORS, bb);
- son;
- son = next_dom_son (CDI_POST_DOMINATORS, son))
- worklist.safe_push (son);
- }
- while (!worklist.is_empty ());
+ int *rpo = XNEWVEC (int, n_basic_blocks_for_fn (cfun));
+ int n = inverted_rev_post_order_compute (fun, rpo);
+ for (int i = 0; i < n; ++i)
+ todo |= sink_code_in_bb (BASIC_BLOCK_FOR_FN (fun, rpo[i]), vop_live);
+ free (rpo);
statistics_counter_event (fun, "Sunk statements", sink_stats.sunk);
statistics_counter_event (fun, "Commoned stores", sink_stats.commoned);
- free_dominance_info (CDI_POST_DOMINATORS);
remove_fake_exit_edges ();
loop_optimizer_finalize ();