Fix PR42914 and PR42530.
authorSebastian Pop <seb@napoca>
Thu, 11 Feb 2010 19:42:45 +0000 (19:42 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Thu, 11 Feb 2010 19:42:45 +0000 (19:42 +0000)
2010-02-10  Sebastian Pop  <seb@napoca>

PR middle-end/42914
PR middle-end/42530
* graphite-sese-to-poly.c (remove_phi): New.
(translate_scalar_reduction_to_array): Call remove_phi.

* gcc.dg/graphite/pr42530.c: New.
* gcc.dg/graphite/pr42914.c: New.

From-SVN: r156712

gcc/ChangeLog.graphite
gcc/graphite-sese-to-poly.c
gcc/testsuite/gcc.dg/graphite/pr42530.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/graphite/pr42914.c [new file with mode: 0644]

index 41f05b0fbb55480b9db4d8b3aa330daae49b4b21..d7eb169c81c91b75ab6ddef8124a5cd356e44546 100644 (file)
@@ -1,3 +1,13 @@
+2010-02-10  Sebastian Pop  <seb@napoca>
+
+       PR middle-end/42914
+       PR middle-end/42530
+       * graphite-sese-to-poly.c (remove_phi): New.
+       (translate_scalar_reduction_to_array): Call remove_phi.
+
+       * gcc.dg/graphite/pr42530.c: New.
+       * gcc.dg/graphite/pr42914.c: New.
+
 2010-02-10  Sebastian Pop  <seb@napoca>
 
        PR middle-end/42771
index 614232b118ccafc24e7356c9e1f4d80b9726a65f..d4889b044d629935e0e63e61a44b5ece48519055 100644 (file)
@@ -2719,6 +2719,41 @@ insert_copyin (tree red, gimple loop_phi)
   gsi_insert_seq_on_edge (edge_initial_value_for_loop_phi (loop_phi), stmts);
 }
 
+/* Removes the PHI node and resets all the debug stmts that are using
+   the PHI_RESULT.  */
+
+static void
+remove_phi (gimple phi)
+{
+  imm_use_iterator imm_iter;
+  tree def;
+  use_operand_p use_p;
+  gimple_stmt_iterator gsi;
+  VEC (gimple, heap) *update = VEC_alloc (gimple, heap, 3);
+  unsigned int i;
+  gimple stmt;
+
+  def = PHI_RESULT (phi);
+  FOR_EACH_IMM_USE_FAST (use_p, imm_iter, def)
+    {
+      stmt = USE_STMT (use_p);
+
+      if (is_gimple_debug (stmt))
+       {
+         gimple_debug_bind_reset_value (stmt);
+         VEC_safe_push (gimple, heap, update, stmt);
+       }
+    }
+
+  for (i = 0; VEC_iterate (gimple, update, i, stmt); i++)
+    update_stmt (stmt);
+
+  VEC_free (gimple, heap, update);
+
+  gsi = gsi_for_phi_node (phi);
+  remove_phi_node (&gsi, false);
+}
+
 /* Rewrite out of SSA the reduction described by the loop phi nodes
    IN, and the close phi nodes OUT.  IN and OUT are structured by loop
    levels like this:
@@ -2737,7 +2772,6 @@ translate_scalar_reduction_to_array (VEC (gimple, heap) *in,
   unsigned int i;
   gimple loop_phi;
   tree red;
-  gimple_stmt_iterator gsi;
 
   for (i = 0; VEC_iterate (gimple, in, i, loop_phi); i++)
     {
@@ -2764,11 +2798,8 @@ translate_scalar_reduction_to_array (VEC (gimple, heap) *in,
          insert_copyin (red, loop_phi);
        }
 
-      gsi = gsi_for_phi_node (loop_phi);
-      remove_phi_node (&gsi, false);
-
-      gsi = gsi_for_phi_node (close_phi);
-      remove_phi_node (&gsi, false);
+      remove_phi (loop_phi);
+      remove_phi (close_phi);
     }
 }
 
diff --git a/gcc/testsuite/gcc.dg/graphite/pr42530.c b/gcc/testsuite/gcc.dg/graphite/pr42530.c
new file mode 100644 (file)
index 0000000..c0fa299
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-options "-O2 -g -ffast-math -floop-parallelize-all" } */
+
+int array[2][2];
+
+void foo(int *a)
+{
+  int i, j;
+  int sum, tmp = 0;
+
+  for (i=0; i<2; i++)
+    for (j=0; j<2; j++)
+      sum += array[i][j];
+
+  if (sum > 0) {
+    tmp = sum;
+    *a = tmp;
+  }
+}
diff --git a/gcc/testsuite/gcc.dg/graphite/pr42914.c b/gcc/testsuite/gcc.dg/graphite/pr42914.c
new file mode 100644 (file)
index 0000000..606ee08
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-options "-O2 -g -ffast-math -fgraphite-identity" } */
+
+int find_sad_16x16(int *mode)
+{
+  int current, best;
+  int M1[16][16],M0[4][4][4][4],M3[4],M4[4][4];
+  int i,j,k;
+  int ii,jj;
+
+  for (jj=0;jj<4;jj++)
+    for (ii=0;ii<4;ii++)
+      for (j=0;j<4;j++)
+       for (j=0;j<4;j++)
+         current += abs(M0[i][ii][j][jj]);
+
+  if(current < best)
+    {
+      best = current;
+      *mode = k;
+    }
+}