summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog.graphite10
-rw-r--r--gcc/graphite-sese-to-poly.c43
-rw-r--r--gcc/testsuite/gcc.dg/graphite/pr42530.c18
-rw-r--r--gcc/testsuite/gcc.dg/graphite/pr42914.c21
4 files changed, 86 insertions, 6 deletions
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 41f05b0fbb5..d7eb169c81c 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,15 @@
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
* graphite-clast-to-gimple.c (gloog): Call rename_sese_parameters.
* graphite-clast-to-gimple.h (gloog): Update declaration.
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 614232b118c..d4889b044d6 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -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
index 00000000000..c0fa299ce97
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/pr42530.c
@@ -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
index 00000000000..606ee0871f4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/pr42914.c
@@ -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;
+ }
+}