public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/53774] Reassociator generates non-canonical addition
Date: Wed, 27 Jun 2012 08:28:00 -0000	[thread overview]
Message-ID: <bug-53774-4-cuIwyAtFzQ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-53774-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53774

--- Comment #5 from rguenther at suse dot de <rguenther at suse dot de> 2012-06-27 08:28:27 UTC ---
On Tue, 26 Jun 2012, wschmidt at gcc dot gnu.org wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53774
> 
> --- Comment #3 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-06-26 18:42:41 UTC ---
> I wonder why fp_6(D) gets a rank of zero.  Is it an uninitialized variable or a
> parameter?  Parms are supposed to get small positive numbers for ranks.  Maybe
> the "right" fix is to force fp_6(D) to get a nonzero rank?

Yes, fp_6(D) is not initialized.

It also seems that ranks for non-constants are based on zero, too,
as for example loop-carried PHIs also might get a rank of zero.

Parameters get ranks starting off 3 (see init_reassoc).  I suppose
we could instead of walking over DECL_ARGUMENTS simply walk over all
SSA names and assign ranks to all default-defs instead.  I'm going
to test that.

Ah, it's

      if (TREE_CODE (SSA_NAME_VAR (e)) == PARM_DECL
          && SSA_NAME_IS_DEFAULT_DEF (e))
        return find_operand_rank (e);

      stmt = SSA_NAME_DEF_STMT (e);
      if (gimple_bb (stmt) == NULL)
        return 0;

in get_rank - that will return zero for all non-param default-defs,
even for the static chain we try to setup properly :/

Yeah, the following works - thanks for the hint ;)

Index: gcc/tree-ssa-reassoc.c
===================================================================
--- gcc/tree-ssa-reassoc.c      (revision 188987)
+++ gcc/tree-ssa-reassoc.c      (working copy)
@@ -383,14 +383,10 @@ get_rank (tree e)
       int i, n;
       tree op;

-      if (TREE_CODE (SSA_NAME_VAR (e)) == PARM_DECL
-         && SSA_NAME_IS_DEFAULT_DEF (e))
+      if (SSA_NAME_IS_DEFAULT_DEF (e))
        return find_operand_rank (e);

       stmt = SSA_NAME_DEF_STMT (e);
-      if (gimple_bb (stmt) == NULL)
-       return 0;
-
       if (gimple_code (stmt) == GIMPLE_PHI)
        return phi_rank (stmt);

@@ -3647,7 +3643,6 @@ init_reassoc (void)
 {
   int i;
   long rank = 2;
-  tree param;
   int *bbs = XNEWVEC (int, last_basic_block + 1);

   /* Find the loops, so that we can prevent moving calculations in
@@ -3666,24 +3661,13 @@ init_reassoc (void)
   bb_rank = XCNEWVEC (long, last_basic_block + 1);
   operand_rank = pointer_map_create ();

-  /* Give each argument a distinct rank.   */
-  for (param = DECL_ARGUMENTS (current_function_decl);
-       param;
-       param = DECL_CHAIN (param))
-    {
-      if (gimple_default_def (cfun, param) != NULL)
-       {
-         tree def = gimple_default_def (cfun, param);
-         insert_operand_rank (def, ++rank);
-       }
-    }
-
-  /* Give the chain decl a distinct rank. */
-  if (cfun->static_chain_decl != NULL)
-    {
-      tree def = gimple_default_def (cfun, cfun->static_chain_decl);
-      if (def != NULL)
-       insert_operand_rank (def, ++rank);
+  /* Give each default definition a distinct rank.  This includes
+     parameters and the static chain.  */
+  for (i = 1; i < (int) num_ssa_names; ++i)
+    {
+      tree name = ssa_name (i);
+      if (name && SSA_NAME_IS_DEFAULT_DEF (name))
+       insert_operand_rank (name, ++rank);
     }

   /* Set up rank for each BB  */


  parent reply	other threads:[~2012-06-27  8:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-25 22:21 [Bug tree-optimization/53774] New: " wschmidt at gcc dot gnu.org
2012-06-26  8:56 ` [Bug tree-optimization/53774] " rguenth at gcc dot gnu.org
2012-06-26 14:24 ` rguenth at gcc dot gnu.org
2012-06-26 18:42 ` wschmidt at gcc dot gnu.org
2012-06-26 18:52 ` wschmidt at gcc dot gnu.org
2012-06-27  8:28 ` rguenther at suse dot de [this message]
2012-06-27 11:29 ` rguenth at gcc dot gnu.org
2012-06-27 11:30 ` rguenth at gcc dot gnu.org
2012-06-27 11:30 ` rguenth at gcc dot gnu.org

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=bug-53774-4-cuIwyAtFzQ@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).