From: Richard Henderson <rth@twiddle.net>
To: dberlin@dberlin.org
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>, law@redhat.com
Subject: asm goto vs simulate_block
Date: Fri, 28 Aug 2009 06:17:00 -0000 [thread overview]
Message-ID: <4A96C126.7080204@twiddle.net> (raw)
[-- 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.
next reply other threads:[~2009-08-27 17:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-28 6:17 Richard Henderson [this message]
2009-08-28 13:59 ` Daniel Berlin
2009-09-01 0:07 ` Richard Henderson
2009-09-01 14:59 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A96C126.7080204@twiddle.net \
--to=rth@twiddle.net \
--cc=dberlin@dberlin.org \
--cc=gcc@gcc.gnu.org \
--cc=law@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).