From: Sebastian Pop Date: Thu, 11 Feb 2010 19:42:45 +0000 (+0000) Subject: Fix PR42914 and PR42530. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a4681954cf1472940e8fa1d0ea98f869db02a894;p=gcc.git Fix PR42914 and PR42530. 2010-02-10 Sebastian Pop 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 --- diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index 41f05b0fbb5..d7eb169c81c 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,3 +1,13 @@ +2010-02-10 Sebastian Pop + + 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 PR middle-end/42771 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; + } +}