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]

Fix PR33576 ICE in lamdba


Hi,

This patch fixes the ICE of PR33576.  The ICE is due to the fact that
we were removing dead induction variables that were still referenced
in chrecs.  I caused this PR with one of the code transforms to have
the generated code from lambda being vectorized.

This patch collects all the dead ivs, and removes them only after
loop linear finishes.  The patch bootstraps and passes check on
amd64-linux.  Okay for trunk?

Sebastian

	PR tree-optimization/33576
	* testsuite/gcc.dg/tree-ssa/pr33576.c: New.
	* tree-loop-linear.c (linear_transform_loops): Call remove_iv.
	* lambda.h (lambda_loopnest_to_gcc_loopnest): New parameter.
	(remove_iv): Declared.
	* lambda-code.c (remove_iv): Not static.
	(lambda_loopnest_to_gcc_loopnest): New parameter remove_ivs.
	Don't remove ivs there, save ivs in the buffer.
	PR tree-optimization/33576
	* testsuite/gcc.dg/tree-ssa/pr33576.c: New.
	* tree-loop-linear.c (linear_transform_loops): Call remove_iv.
	* lambda.h (lambda_loopnest_to_gcc_loopnest): New parameter.
	(remove_iv): Declared.
	* lambda-code.c (remove_iv): Not static.
	(lambda_loopnest_to_gcc_loopnest): New parameter remove_ivs.
	Don't remove ivs there, save ivs in the buffer.

Index: tree-loop-linear.c
===================================================================
--- tree-loop-linear.c	(revision 128899)
+++ tree-loop-linear.c	(working copy)
@@ -253,7 +253,10 @@ linear_transform_loops (void)
   loop_iterator li;
   VEC(tree,heap) *oldivs = NULL;
   VEC(tree,heap) *invariants = NULL;
+  VEC(tree,heap) *remove_ivs = VEC_alloc (tree, heap, 3);
   struct loop *loop_nest;
+  tree oldiv_stmt;
+  unsigned i;
 
   FOR_EACH_LOOP (li, loop_nest, 0)
     {
@@ -351,6 +354,7 @@ linear_transform_loops (void)
 	}
 
       lambda_loopnest_to_gcc_loopnest (loop_nest, oldivs, invariants,
+				       &remove_ivs,
                                        after, trans, &lambda_obstack);
       modified = true;
 
@@ -363,8 +367,12 @@ linear_transform_loops (void)
       free_data_refs (datarefs);
     }
 
+  for (i = 0; VEC_iterate (tree, remove_ivs, i, oldiv_stmt); i++)
+    remove_iv (oldiv_stmt);
+
   VEC_free (tree, heap, oldivs);
   VEC_free (tree, heap, invariants);
+  VEC_free (tree, heap, remove_ivs);
   scev_reset ();
 
   if (modified)
Index: testsuite/gcc.dg/tree-ssa/pr33576.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/pr33576.c	(revision 0)
+++ testsuite/gcc.dg/tree-ssa/pr33576.c	(revision 0)
@@ -0,0 +1,20 @@
+/* { dg-do compile } */ 
+/* { dg-options "-O2 -ftree-loop-linear" } */
+
+int a1[6][4][4];
+short b1[16];
+
+int c1;
+void CalculateQuantParam(void)
+{
+  int i, j, k, temp;
+
+   for(k=0; k<6; k++)
+      for(j=0; j<4; j++)
+        for(i=0; i<4; i++)
+        {
+          temp = (i<<2)+j;
+          a1[k][j][i]  = c1/b1[temp];
+        }
+}
+
Index: lambda.h
===================================================================
--- lambda.h	(revision 128899)
+++ lambda.h	(working copy)
@@ -206,8 +206,10 @@ lambda_loopnest gcc_loopnest_to_lambda_l
                                                  struct obstack *);
 void lambda_loopnest_to_gcc_loopnest (struct loop *,
 				      VEC(tree,heap) *, VEC(tree,heap) *,
+				      VEC(tree,heap) **,
                                       lambda_loopnest, lambda_trans_matrix,
                                       struct obstack *);
+void remove_iv (tree);
 
 static inline void lambda_vector_negate (lambda_vector, lambda_vector, int);
 static inline void lambda_vector_mult_const (lambda_vector, lambda_vector, int, int);
Index: lambda-code.c
===================================================================
--- lambda-code.c	(revision 128899)
+++ lambda-code.c	(working copy)
@@ -1639,7 +1639,7 @@ lle_to_gcc_expression (lambda_linear_exp
 
 /* Remove the induction variable defined at IV_STMT.  */
 
-static void
+void
 remove_iv (tree iv_stmt)
 {
   if (TREE_CODE (iv_stmt) == PHI_NODE)
@@ -1692,6 +1692,7 @@ void
 lambda_loopnest_to_gcc_loopnest (struct loop *old_loopnest,
 				 VEC(tree,heap) *old_ivs,
 				 VEC(tree,heap) *invariants,
+				 VEC(tree,heap) **remove_ivs,
 				 lambda_loopnest new_loopnest,
                                  lambda_trans_matrix transform,
                                  struct obstack * lambda_obstack)
@@ -1861,7 +1862,7 @@ lambda_loopnest_to_gcc_loopnest (struct 
 	}
 
       /* Remove the now unused induction variable.  */
-      remove_iv (oldiv_stmt);
+      VEC_safe_push (tree, heap, *remove_ivs, oldiv_stmt);
     }
   VEC_free (tree, heap, new_ivs);
 }

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