re PR tree-optimization/31183 (ICE in int_cst_value, at tree.c:7684 with -O3 -ftree...
authorSebastian Pop <sebastian.pop@inria.fr>
Fri, 16 Mar 2007 11:30:48 +0000 (12:30 +0100)
committerSebastian Pop <spop@gcc.gnu.org>
Fri, 16 Mar 2007 11:30:48 +0000 (11:30 +0000)
PR tree-optimization/31183
* tree-loop-linear.c (gather_interchange_stats, try_interchange_loops):
Use double_int instead of unsigned int for representing access_strides.
* testsuite/gcc.dg/tree-ssa/pr31183.c: New.

From-SVN: r122988

gcc/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr31183.c [new file with mode: 0644]
gcc/tree-loop-linear.c

index e85b40d..235258c 100644 (file)
@@ -1,3 +1,10 @@
+2007-03-16  Sebastian Pop  <sebastian.pop@inria.fr>
+
+       PR tree-optimization/31183
+       * tree-loop-linear.c (gather_interchange_stats, try_interchange_loops): 
+       Use double_int instead of unsigned int for representing access_strides.
+       * testsuite/gcc.dg/tree-ssa/pr31183.c: New.
+
 2007-03-16  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/31146
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr31183.c b/gcc/testsuite/gcc.dg/tree-ssa/pr31183.c
new file mode 100644 (file)
index 0000000..000d7b5
--- /dev/null
@@ -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 94f3d59..76bb2dd 100644 (file)
@@ -95,7 +95,7 @@ gather_interchange_stats (VEC (ddr_p, heap) *dependence_relations,
                          struct loop *first_loop,
                          unsigned int *dependence_steps, 
                          unsigned int *nb_deps_not_carried_by_loop, 
-                         unsigned int *access_strides)
+                         double_int *access_strides)
 {
   unsigned int i, j;
   struct data_dependence_relation *ddr;
@@ -103,7 +103,7 @@ gather_interchange_stats (VEC (ddr_p, heap) *dependence_relations,
 
   *dependence_steps = 0;
   *nb_deps_not_carried_by_loop = 0;
-  *access_strides = 0;
+  *access_strides = double_int_zero;
 
   for (i = 0; VEC_iterate (ddr_p, dependence_relations, i, ddr); i++)
     {
@@ -149,6 +149,7 @@ gather_interchange_stats (VEC (ddr_p, heap) *dependence_relations,
          tree chrec = DR_ACCESS_FN (dr, it);
          tree tstride = evolution_part_in_loop_num (chrec, loop->num);
          tree array_size = TYPE_SIZE (TREE_TYPE (ref));
+         double_int dstride;
 
          if (tstride == NULL_TREE
              || array_size == NULL_TREE 
@@ -156,8 +157,9 @@ gather_interchange_stats (VEC (ddr_p, heap) *dependence_relations,
              || TREE_CODE (array_size) != INTEGER_CST)
            continue;
 
-         (*access_strides) += 
-           int_cst_value (array_size) * int_cst_value (tstride);
+         dstride = double_int_mul (tree_to_double_int (array_size), 
+                                   tree_to_double_int (tstride));
+         (*access_strides) = double_int_add (*access_strides, dstride);
        }
     }
 }
@@ -180,7 +182,7 @@ try_interchange_loops (lambda_trans_matrix trans,
   struct loop *loop_i;
   struct loop *loop_j;
   unsigned int dependence_steps_i, dependence_steps_j;
-  unsigned int access_strides_i, access_strides_j;
+  double_int access_strides_i, access_strides_j;
   unsigned int nb_deps_not_carried_by_i, nb_deps_not_carried_by_j;
   struct data_dependence_relation *ddr;
 
@@ -225,7 +227,7 @@ try_interchange_loops (lambda_trans_matrix trans,
        */
        if (dependence_steps_i < dependence_steps_j 
            || nb_deps_not_carried_by_i > nb_deps_not_carried_by_j
-           || access_strides_i < access_strides_j)
+           || double_int_ucmp (access_strides_i, access_strides_j) < 0)
          {
            lambda_matrix_row_exchange (LTM_MATRIX (trans),
                                        loop_i->depth - first_loop->depth,