Commit 7679a65e authored by Andreas Zwinkau's avatar Andreas Zwinkau
Browse files

Fix "Some cleanup of cfopt."

The remove_empty_blocks function must be used for a pre-walker, otherwise
it might be called on blocks, which were optimized away. Consider infinite
loops and the Keep edges:

  \ ___
   B   |
    \  /
   / Keep Edge!

In this example, we must not call remove_empty_blocks on Empty,
after we called it on B, but a post walker would do that.
parent 1ff709a0
......@@ -681,7 +681,7 @@ static void optimize_ifs(ir_node *block, void *x)
* Post-Block walker: remove empty blocks that are
* Pre-Block walker: remove empty blocks that are
* predecessors of the current block.
static void remove_empty_blocks(ir_node *block, void *x)
......@@ -731,7 +731,7 @@ static void cfgopt_ignoring_phis(ir_graph *irg) {
irg_block_walk_graph(irg, NULL, optimize_ifs, &env);
/* Remove empty blocks */
irg_block_walk_graph(irg, NULL, remove_empty_blocks, &env);
irg_block_walk_graph(irg, remove_empty_blocks, NULL, &env);
if (env.changed) {
/* Removing blocks might enable more Cond optimizations */
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