public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@redhat.com>
To: Daniel Berlin <dberlin@dberlin.org>
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>,
	law@redhat.com,         gcc-patches@gcc.gnu.org
Subject: Re: asm goto vs simulate_block
Date: Tue, 01 Sep 2009 00:07:00 -0000	[thread overview]
Message-ID: <4A9C659A.4000406@redhat.com> (raw)
In-Reply-To: <4aca3dc20908272004g7496f82co441e61295e995166@mail.gmail.com>

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

> My guess, witjout seeing the testcase.
> In ccp_initialize we have:
>
>       for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
>         {
>           gimple stmt = gsi_stmt (i);
>           bool is_varying = surely_varying_stmt_p (stmt);
>
>           if (is_varying)
>             {
>               tree def;
>               ssa_op_iter iter;
>
>               /* If the statement will not produce a constant, mark
>                  all its outputs VARYING.  */
>               FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_ALL_DEFS)
>                 set_value_varying (def);
>             }
>           prop_set_simulate_again (stmt, !is_varying);
>
> This code looks clearly broken if the statement is control altering
> (like your asm), since it will cause us to never simulate it and add
> the outgoing edges (since the outgoing edges are only added in
> simulate_stmt).

Your guess is absolutely correct.  We already correctly
handle this case in init_copy_prop, but do not in two
other places.

And I just ran into this with my exception rewrite too,
which has an EH_DISPATCH control statement with multiple
normal edges plus a fallthru.  The only thing "weird"
about this statement is that it has multiple normal edges
and nothing currently visible in the program that determines
which edge will be taken.

The following patch appears to work for both.  I'll commit
it after a bootstrap and test cycle completes.


r~

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

	* tree-ssa-ccp.c (ccp_initialize): Make sure to simulate 
	stmt_ends_pp_p statements at least once.
	* tree-vrp.c (vrp_initialize): Likewise.

diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index b359d4c..949c4b5 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -650,7 +650,15 @@ ccp_initialize (void)
       for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
         {
 	  gimple stmt = gsi_stmt (i);
-	  bool is_varying = surely_varying_stmt_p (stmt);
+	  bool is_varying;
+
+	  /* If the statement is a control insn, then we do not
+	     want to avoid simulating the statement once.  Failure
+	     to do so means that those edges will never get added.  */
+	  if (stmt_ends_bb_p (stmt))
+	    is_varying = false;
+	  else
+	    is_varying = surely_varying_stmt_p (stmt);
 
 	  if (is_varying)
 	    {
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 5379b75..7e8a952 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -5317,7 +5317,12 @@ vrp_initialize (void)
         {
 	  gimple stmt = gsi_stmt (si);
 
-	  if (!stmt_interesting_for_vrp (stmt))
+ 	  /* If the statement is a control insn, then we do not
+ 	     want to avoid simulating the statement once.  Failure
+ 	     to do so means that those edges will never get added.  */
+	  if (stmt_ends_bb_p (stmt))
+	    prop_set_simulate_again (stmt, true);
+	  else if (!stmt_interesting_for_vrp (stmt))
 	    {
 	      ssa_op_iter i;
 	      tree def;
@@ -5326,9 +5331,7 @@ vrp_initialize (void)
 	      prop_set_simulate_again (stmt, false);
 	    }
 	  else
-	    {
-	      prop_set_simulate_again (stmt, true);
-	    }
+	    prop_set_simulate_again (stmt, true);
 	}
     }
 }

  reply	other threads:[~2009-09-01  0:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-28  6:17 Richard Henderson
2009-08-28 13:59 ` Daniel Berlin
2009-09-01  0:07   ` Richard Henderson [this message]
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=4A9C659A.4000406@redhat.com \
    --to=rth@redhat.com \
    --cc=dberlin@dberlin.org \
    --cc=gcc-patches@gcc.gnu.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).