public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/53774] Reassociator generates non-canonical addition
Date: Tue, 26 Jun 2012 14:24:00 -0000	[thread overview]
Message-ID: <bug-53774-4-snqrJ6COZv@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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-06-26 14:24:13 UTC ---
I am testing instead

@@ -2299,8 +2299,16 @@ rewrite_expr_tree (gimple stmt, unsigned
              print_gimple_stmt (dump_file, stmt, 0, 0);
            }

-         gimple_assign_set_rhs1 (stmt, oe1->op);
-         gimple_assign_set_rhs2 (stmt, oe2->op);
+         if (tree_swap_operands_p (oe1->op, oe2->op, true))
+           {
+             gimple_assign_set_rhs1 (stmt, oe2->op);
+             gimple_assign_set_rhs2 (stmt, oe1->op);
+           }
+         else
+           {
+             gimple_assign_set_rhs1 (stmt, oe1->op);
+             gimple_assign_set_rhs2 (stmt, oe2->op);
+           }
          update_stmt (stmt);
          if (rhs1 != oe1->op && rhs1 != oe2->op)
            remove_visited_stmt_chain (rhs1);

which fixes it.  OTOH there are many other places reassoc adjusts
stmt operands (but it eventually relies on operand order).  Adding
a canonicalize_operand_order_and_update_stmt () wherever we
call update_stmt afer adjusting operands might be better ... or
simply calling fold_stmt on all stmts we touch which does the re-ordering, too.

Well, I'm not really sure where we should enforce canonical ordering ...


  parent reply	other threads:[~2012-06-26 14:24 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 [this message]
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
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-snqrJ6COZv@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).