The kernel folk here at Red Hat have given me a test case (which I'll be
happy to forward, along a complete patch vs mainline) which gets
miscompiled because we never get around to adding all of the appropriate
blocks outgoing from an asm-goto to the simulation.
I can't figure out why the VARYING that we get in simulate_stmt and
subsequent calls to add_control_edge are not enough to DTRT. All I know
is that the attached patch does in fact work around the problem,
changing the .028t.ccp1 dump:
...
Lattice value changed to VARYING. Adding SSA edges to worklist.
+Adding Destination of edge (13 -> 14) to worklist
+
+
+Simulating block 14
...
Can someone give me a good explanation as to why this patch would be needed?
r~
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index a3a87cb..29d27aa 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -430,13 +430,14 @@ simulate_block (basic_block block)
unsigned int normal_edge_count;
edge e, normal_edge;
edge_iterator ei;
+ gimple stmt = NULL;
/* Note that we have simulated this block. */
SET_BIT (executable_blocks, block->index);
for (j = gsi_start_bb (block); !gsi_end_p (j); gsi_next (&j))
{
- gimple stmt = gsi_stmt (j);
+ stmt = gsi_stmt (j);
/* If this statement is already in the worklist then
"cancel" it. The reevaluation implied by the worklist
@@ -449,6 +450,17 @@ simulate_block (basic_block block)
simulate_stmt (stmt);
}
+ /* ??? I can't figure out why this wouldn't have been taken care
+ of in simulate_stmt, because the asm is considered VARYING.
+ But it's also true that we'll never be able to predict which
+ edge is going to be taken, so we might as well push them early. */
+ if (stmt && gimple_code (stmt) == GIMPLE_ASM && stmt_ends_bb_p (stmt))
+ {
+ FOR_EACH_EDGE (e, ei, block->succs)
+ add_control_edge (e);
+ return;
+ }
+
/* We can not predict when abnormal and EH edges will be executed, so
once a block is considered executable, we consider any
outgoing abnormal edges as executable.