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 PR31183 in tree-loop-linear


Hi,

Here is a fix that uses host_integerp () for checking that the
strides and the array sizes fit in HWI.  I also have modified the
types for the other integer variables to HWI.
I'm testing the attached patch on i386-apple-darwin8.8.1.
Okay for trunk after bootstrap and test?

Sebastian
	* tree-loop-linear.c (gather_interchange_stats): Use HOST_WIDE_INT
	instead of int for representing dependence_steps, 
	nb_deps_not_carried_by_loop and access_strides.  Check host_integerp
	before taking the values of int_cst_value.
	* testsuite/gcc.dg/tree-ssa/pr31183.c: New.

Index: tree-loop-linear.c
===================================================================
--- tree-loop-linear.c	(revision 122954)
+++ tree-loop-linear.c	(working copy)
@@ -93,9 +93,9 @@ gather_interchange_stats (VEC (ddr_p, he
 			  VEC (data_reference_p, heap) *datarefs,
 			  struct loop *loop,
 			  struct loop *first_loop,
-			  unsigned int *dependence_steps, 
-			  unsigned int *nb_deps_not_carried_by_loop, 
-			  unsigned int *access_strides)
+			  unsigned HOST_WIDE_INT *dependence_steps, 
+			  unsigned HOST_WIDE_INT *nb_deps_not_carried_by_loop, 
+			  unsigned HOST_WIDE_INT *access_strides)
 {
   unsigned int i, j;
   struct data_dependence_relation *ddr;
@@ -152,8 +152,8 @@ gather_interchange_stats (VEC (ddr_p, he
 
 	  if (tstride == NULL_TREE
 	      || array_size == NULL_TREE 
-	      || TREE_CODE (tstride) != INTEGER_CST
-	      || TREE_CODE (array_size) != INTEGER_CST)
+	      || !host_integerp (tstride, 1)
+	      || !host_integerp (array_size, 1))
 	    continue;
 
 	  (*access_strides) += 
@@ -179,9 +179,9 @@ try_interchange_loops (lambda_trans_matr
 {
   struct loop *loop_i;
   struct loop *loop_j;
-  unsigned int dependence_steps_i, dependence_steps_j;
-  unsigned int access_strides_i, access_strides_j;
-  unsigned int nb_deps_not_carried_by_i, nb_deps_not_carried_by_j;
+  unsigned HOST_WIDE_INT dependence_steps_i, dependence_steps_j;
+  unsigned HOST_WIDE_INT access_strides_i, access_strides_j;
+  unsigned HOST_WIDE_INT nb_deps_not_carried_by_i, nb_deps_not_carried_by_j;
   struct data_dependence_relation *ddr;
 
   if (VEC_length (ddr_p, dependence_relations) == 0)
Index: testsuite/gcc.dg/tree-ssa/pr31183.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/pr31183.c	(revision 0)
+++ testsuite/gcc.dg/tree-ssa/pr31183.c	(revision 0)
@@ -0,0 +1,14 @@
+/* { dg-do compile } */ 
+/* { dg-options "-O2 -ftree-loop-linear" } */
+
+int buf[256 * 9];
+int f() 
+{
+  int i, j;
+
+  for (i = 0; i < 256; ++i)
+    for (j = 0; j < 8; ++j)
+      buf[j + 1] = buf[j] + 1;
+
+  return buf[10];
+}

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