re PR tree-optimization/57337 (416.gamess ICE on x86 after r199048)
authorEaswaran Raman <eraman@gcc.gnu.org>
Tue, 28 May 2013 17:27:54 +0000 (17:27 +0000)
committerEaswaran Raman <eraman@gcc.gnu.org>
Tue, 28 May 2013 17:27:54 +0000 (17:27 +0000)
2013-05-28  Easwaran Raman  <eraman@google.com>

PR tree-optimization/57337
* tree-ssa-reassoc.c (appears_later_in_bb): New function.
(find_insert_point): Correctly identify the insertion point
when two statements with the same UID is compared.

From-SVN: r199385

gcc/ChangeLog
gcc/tree-ssa-reassoc.c

index 9f4f85e2fcb43fa3658f7f66498ca07a06264e34..015ccfb9005b1d7e452d3592e5b9482c6de5cbe7 100644 (file)
@@ -1,3 +1,10 @@
+2013-05-28  Easwaran Raman  <eraman@google.com>
+
+       PR tree-optimization/57337
+       * tree-ssa-reassoc.c (appears_later_in_bb): New function.
+       (find_insert_point): Correctly identify the insertion point
+       when two statements with the same UID is compared.
+
 2013-05-28  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/56787
        * config/rs6000/rs6000-opts.h (PROCESSOR_POWER8): Likewise.
        (enum rs6000_vector): Add power8 vector support.
 
+>>>>>>> .r199383
 2013-05-22  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
 
        PR target/19599
 2013-05-21  Easwaran Raman  <eraman@google.com>
 
        PR tree-optimization/57322
-       * (build_and_add_sum): If a BB is empty, set the UID of the statement
-       added to the BB to be 1.
+       * tree-ssa-reassoc.c (build_and_add_sum): If a BB is empty, set the
+       UID of the statement added to the BB to be 1.
 
 2013-05-21  Jakub Jelinek  <jakub@redhat.com>
 
index 8e13763062400eb83c05c4226a2bd9131ae3e3f2..24ad390333c5bdd06c377e2e8aa4db285056b8e4 100644 (file)
@@ -2866,6 +2866,31 @@ not_dominated_by (gimple a, gimple b)
 
 }
 
+/* Among STMT1 and STMT2, return the statement that appears later. Both
+   statements are in same BB and have the same UID.  */
+
+static gimple
+appears_later_in_bb (gimple stmt1, gimple stmt2)
+{
+  unsigned uid = gimple_uid (stmt1);
+  gimple_stmt_iterator gsi = gsi_for_stmt (stmt1);
+  gsi_next (&gsi);
+  if (gsi_end_p (gsi))
+    return stmt1;
+  for (; !gsi_end_p (gsi); gsi_next (&gsi))
+    {
+      gimple stmt = gsi_stmt (gsi);
+
+      /* If STMT has a different UID than STMT1 and we haven't seen
+         STMT2 during traversal, we know STMT1 appears later.  */
+      if (gimple_uid (stmt) != uid)
+        return stmt1;
+      else if (stmt == stmt2)
+        return stmt2;
+    }
+  gcc_unreachable ();
+}
+
 /* Find the statement after which STMT must be moved so that the
    dependency from DEP_STMT to STMT is maintained.  */
 
@@ -2875,7 +2900,11 @@ find_insert_point (gimple stmt, gimple dep_stmt)
   gimple insert_stmt = stmt;
   if (dep_stmt == NULL)
     return stmt;
-  if (not_dominated_by (insert_stmt, dep_stmt))
+  if (gimple_uid (insert_stmt) == gimple_uid (dep_stmt)
+      && gimple_bb (insert_stmt) == gimple_bb (dep_stmt)
+      && insert_stmt != dep_stmt)
+    insert_stmt = appears_later_in_bb (insert_stmt, dep_stmt);
+  else if (not_dominated_by (insert_stmt, dep_stmt))
     insert_stmt = dep_stmt;
   return insert_stmt;
 }