public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* asm goto vs simulate_block
@ 2009-08-28  6:17 Richard Henderson
  2009-08-28 13:59 ` Daniel Berlin
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2009-08-28  6:17 UTC (permalink / raw)
  To: dberlin; +Cc: gcc, law

[-- Attachment #1: Type: text/plain, Size: 741 bytes --]

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~

[-- Attachment #2: d-asmgoto-5 --]
[-- Type: text/plain, Size: 1395 bytes --]

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-09-01 14:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-28  6:17 asm goto vs simulate_block Richard Henderson
2009-08-28 13:59 ` Daniel Berlin
2009-09-01  0:07   ` Richard Henderson
2009-09-01 14:59     ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).