This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch][graphite] Fix PR42284


Hi,

This patch fixes a compile problem in CPU2000 gzip like this:

2009-12-12  Sebastian Pop  <sebpop@gmail.com>

	* graphite-sese-to-poly.c (rewrite_close_phi_out_of_ssa): Call
	insert_out_of_ssa_copy_on_edge for anything else than SSA_NAMEs.
	(detect_commutative_reduction_arg): Simplified.
	(detect_commutative_reduction): Early return when the argument of
	the close phi is not of an SSA_NAME.
	* testsuite/gcc.dg/graphite/pr42284.c: New.

I am committing this to the graphite branch for full cpu2k6, bootstrap and test.
I will commit this to trunk if no regressions.

Sebastian
From 87d976211b1a3a100a3bc028a0bb0b1422f98f3c Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Sat, 12 Dec 2009 14:33:26 -0600
Subject: [PATCH] Fix PR42284.

2009-12-12  Sebastian Pop  <sebpop@gmail.com>

	* graphite-sese-to-poly.c (rewrite_close_phi_out_of_ssa): Call
	insert_out_of_ssa_copy_on_edge for anything else than SSA_NAMEs.
	(detect_commutative_reduction_arg): Simplified.
	(detect_commutative_reduction): Early return when the argument of
	the close phi is not of an SSA_NAME.
	* testsuite/gcc.dg/graphite/pr42284.c: New.
---
 gcc/graphite-sese-to-poly.c             |   34 +++++++++++++++++++-----------
 gcc/testsuite/gcc.dg/graphite/pr42284.c |   27 ++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 13 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/graphite/pr42284.c

diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 37b2035..1eb0696 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2186,7 +2186,11 @@ rewrite_close_phi_out_of_ssa (gimple_stmt_iterator *psi)
   gimple stmt = gimple_build_assign (res, zero_dim_array);
   tree arg = gimple_phi_arg_def (phi, 0);
 
-  insert_out_of_ssa_copy (zero_dim_array, arg);
+  if (TREE_CODE (arg) == SSA_NAME)
+    insert_out_of_ssa_copy (zero_dim_array, arg);
+  else
+    insert_out_of_ssa_copy_on_edge (single_pred_edge (gimple_bb (phi)),
+				    zero_dim_array, arg);
 
   remove_phi_node (psi, false);
   gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
@@ -2511,7 +2515,7 @@ follow_ssa_with_commutative_ops (tree arg, tree lhs)
 }
 
 /* Detect commutative and associative scalar reductions starting at
-   the STMT.  */
+   the STMT.  Return the phi node of the reduction cycle, or NULL.  */
 
 static gimple
 detect_commutative_reduction_arg (tree lhs, gimple stmt, tree arg,
@@ -2520,18 +2524,16 @@ detect_commutative_reduction_arg (tree lhs, gimple stmt, tree arg,
 {
   gimple phi = follow_ssa_with_commutative_ops (arg, lhs);
 
-  if (phi)
-    {
-      VEC_safe_push (gimple, heap, *in, stmt);
-      VEC_safe_push (gimple, heap, *out, stmt);
-      return phi;
-    }
+  if (!phi)
+    return NULL;
 
-  return NULL;
+  VEC_safe_push (gimple, heap, *in, stmt);
+  VEC_safe_push (gimple, heap, *out, stmt);
+  return phi;
 }
 
 /* Detect commutative and associative scalar reductions starting at
-   the STMT.  */
+   the STMT.  Return the phi node of the reduction cycle, or NULL.  */
 
 static gimple
 detect_commutative_reduction_assign (gimple stmt, VEC (gimple, heap) **in,
@@ -2619,7 +2621,8 @@ initial_value_for_loop_phi (gimple phi)
 }
 
 /* Detect commutative and associative scalar reductions starting at
-   the loop closed phi node CLOSE_PHI.  */
+   the loop closed phi node CLOSE_PHI.  Return the phi node of the
+   reduction cycle, or NULL.  */
 
 static gimple
 detect_commutative_reduction (gimple stmt, VEC (gimple, heap) **in,
@@ -2628,8 +2631,13 @@ detect_commutative_reduction (gimple stmt, VEC (gimple, heap) **in,
   if (scalar_close_phi_node_p (stmt))
     {
       tree arg = gimple_phi_arg_def (stmt, 0);
-      gimple def = SSA_NAME_DEF_STMT (arg);
-      gimple loop_phi = detect_commutative_reduction (def, in, out);
+      gimple def, loop_phi;
+
+      if (TREE_CODE (arg) != SSA_NAME)
+	return NULL;
+
+      def = SSA_NAME_DEF_STMT (arg);
+      loop_phi = detect_commutative_reduction (def, in, out);
 
       if (loop_phi)
 	{
diff --git a/gcc/testsuite/gcc.dg/graphite/pr42284.c b/gcc/testsuite/gcc.dg/graphite/pr42284.c
new file mode 100644
index 0000000..854c251
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/pr42284.c
@@ -0,0 +1,27 @@
+/* { dg-options "-O2 -fgraphite-identity" } */
+
+int
+huft_build (unsigned *b)
+{
+  int k;
+  for (k = 0; k <= 10; k++)
+    if (foo ());
+}
+int
+inflate_fixed ()
+{
+  int i;
+  unsigned l[288];
+  for (i = 0; i < 144; i++)
+    l[i] = 8;
+  for (; i < 256; i++)
+    l[i] = 9;
+  for (; i < 280; i++)
+    l[i] = 7;
+  for (; i < 288; i++)
+    l[i] = 8;
+  if ((i = huft_build (l)) != 0)
+    return i;
+  for (i = 0; i < 30; i++)
+    l[i] = 5;
+}
-- 
1.6.0.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]