tree-ssa-live.c (var_map_base_init): Handle SSA names with DECL_IGNORED_P base VAR_DE...
authorRichard Biener <rguenther@suse.de>
Thu, 26 Sep 2013 13:18:31 +0000 (13:18 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 26 Sep 2013 13:18:31 +0000 (13:18 +0000)
2013-09-26  Richard Biener  <rguenther@suse.de>

* tree-ssa-live.c (var_map_base_init): Handle SSA names with
DECL_IGNORED_P base VAR_DECLs like anonymous SSA names.
(loe_visit_block): Use gcc_checking_assert.
* tree-ssa-coalesce.c (create_outofssa_var_map): Use
gimple_assign_ssa_name_copy_p.
(gimple_can_coalesce_p): Adjust according to the var_map_base_init
change.

* gcc.dg/tree-ssa/coalesce-2.c: New testcase.

From-SVN: r202944

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/coalesce-2.c [new file with mode: 0644]
gcc/tree-ssa-coalesce.c
gcc/tree-ssa-live.c

index 77254a8..7d5e2c5 100644 (file)
@@ -1,3 +1,13 @@
+2013-09-26  Richard Biener  <rguenther@suse.de>
+
+       * tree-ssa-live.c (var_map_base_init): Handle SSA names with
+       DECL_IGNORED_P base VAR_DECLs like anonymous SSA names.
+       (loe_visit_block): Use gcc_checking_assert.
+       * tree-ssa-coalesce.c (create_outofssa_var_map): Use
+       gimple_assign_ssa_name_copy_p.
+       (gimple_can_coalesce_p): Adjust according to the var_map_base_init
+       change.
+
 2013-09-26  David Edelsohn  <dje.gcc@gmail.com>
 
        * config/rs6000/t-rs6000 (rs6000.o): Remove.
index 065eebd..9c95ef0 100644 (file)
@@ -1,5 +1,9 @@
 2013-09-26  Richard Biener  <rguenther@suse.de>
 
+       * gcc.dg/tree-ssa/coalesce-2.c: New testcase.
+
+2013-09-26  Richard Biener  <rguenther@suse.de>
+
        PR tree-optimization/58539
        * gcc.dg/torture/pr58539.c: New testcase.
 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/coalesce-2.c b/gcc/testsuite/gcc.dg/tree-ssa/coalesce-2.c
new file mode 100644 (file)
index 0000000..56c5ccc
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-rtl-expand-details" } */
+
+float total = 0.2;
+void foo(int n)
+{
+  int i;
+  for (i = 0; i < n; i++)
+    total += i;
+}
+
+/* Verify that out-of-ssa coalescing did its job by verifying there are not
+   any partition copies inserted.  */
+
+/* { dg-final { scan-rtl-dump-not "partition copy" "expand"} } */
+/* { dg-final { cleanup-rtl-dump "expand" } } */
index d86e0b8..cfcd1e0 100644 (file)
@@ -980,10 +980,7 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
              {
                tree lhs = gimple_assign_lhs (stmt);
                tree rhs1 = gimple_assign_rhs1 (stmt);
-
-               if (gimple_assign_copy_p (stmt)
-                    && TREE_CODE (lhs) == SSA_NAME
-                   && TREE_CODE (rhs1) == SSA_NAME
+               if (gimple_assign_ssa_name_copy_p (stmt)
                    && gimple_can_coalesce_p (lhs, rhs1))
                  {
                    v1 = SSA_NAME_VERSION (lhs);
@@ -1347,7 +1344,11 @@ gimple_can_coalesce_p (tree name1, tree name2)
 {
   /* First check the SSA_NAME's associated DECL.  We only want to
      coalesce if they have the same DECL or both have no associated DECL.  */
-  if (SSA_NAME_VAR (name1) != SSA_NAME_VAR (name2))
+  tree var1 = SSA_NAME_VAR (name1);
+  tree var2 = SSA_NAME_VAR (name2);
+  var1 = (var1 && (!VAR_P (var1) || !DECL_IGNORED_P (var1))) ? var1 : NULL_TREE;
+  var2 = (var2 && (!VAR_P (var2) || !DECL_IGNORED_P (var2))) ? var2 : NULL_TREE;
+  if (var1 != var2)
     return false;
 
   /* Now check the types.  If the types are the same, then we should
index c21b2e8..eb36a90 100644 (file)
@@ -104,7 +104,9 @@ var_map_base_init (var_map map)
       struct tree_int_map **slot;
       unsigned baseindex;
       var = partition_to_var (map, x);
-      if (SSA_NAME_VAR (var))
+      if (SSA_NAME_VAR (var)
+         && (!VAR_P (SSA_NAME_VAR (var))
+             || !DECL_IGNORED_P (SSA_NAME_VAR (var))))
        m->base.from = SSA_NAME_VAR (var);
       else
        /* This restricts what anonymous SSA names we can coalesce
@@ -990,9 +992,10 @@ loe_visit_block (tree_live_info_p live, basic_block bb, sbitmap visited,
   edge_iterator ei;
   basic_block pred_bb;
   bitmap loe;
-  gcc_assert (!bitmap_bit_p (visited, bb->index));
 
+  gcc_checking_assert (!bitmap_bit_p (visited, bb->index));
   bitmap_set_bit (visited, bb->index);
+
   loe = live_on_entry (live, bb);
 
   FOR_EACH_EDGE (e, ei, bb->preds)