Fix attached: that's a bad typo.  This also fixes PR36286.
Sent to regstrap on gccfarm.  I will commit it just after it passes.

Sebastian
email: [EMAIL PROTECTED]
branch:trunk
revision:HEAD
configure:
make:
check:

2008-05-21  Sebastian Pop  <[EMAIL PROTECTED]>

	PR tree-optimization/36286
	* lambda-code.c (build_access_matrix): Do not use the loop->num
	for computing the number of induction variables: use the loop depth
	instead.

	* testsuite/gcc.dg/tree-ssa/pr36287.c: New.
	* testsuite/gfortran.dg/pr36286.f90: New.

Index: gcc/testsuite/gcc.dg/tree-ssa/pr36287.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/pr36287.c	(revision 0)
+++ gcc/testsuite/gcc.dg/tree-ssa/pr36287.c	(revision 0)
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O -ftree-loop-linear" } */
+
+int tab[2][2];
+
+int foo ()
+{
+  int i, j, k;
+
+  for (i = 0; i < 2; ++i)
+    for (j = 0; j < 2; ++j)
+      for (k = 0; k < 2; ++k) 
+	{}
+
+  for (i = 0; i < 2; ++i)
+    for (j = 0; j < 2; ++j)
+      if (i == 0)
+	tab[i][j] = 0;
+
+  return tab[0][1];
+}
+
Index: gcc/testsuite/gfortran.dg/pr36286.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr36286.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/pr36286.f90	(revision 0)
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! { dg-options "-O1 -ftree-loop-linear" }
+! PR tree-optimization/36286
+
+program test_count
+    integer, dimension(2,3) :: a, b
+    a = reshape( (/ 1, 3, 5, 2, 4, 6 /), (/ 2, 3 /))
+    b = reshape( (/ 0, 3, 5, 7, 4, 8 /), (/ 2, 3 /))
+    print '(3l6)', a.ne.b
+    print *, a(1,:).ne.b(1,:)
+    print *, a(2,:).ne.b(2,:)
+    print *, count(a.ne.b)
+end program test_count
+
Index: gcc/lambda-code.c
===================================================================
--- gcc/lambda-code.c	(revision 135673)
+++ gcc/lambda-code.c	(working copy)
@@ -2794,12 +2794,13 @@ build_access_matrix (data_reference_p da
   struct access_matrix *am = GGC_NEW (struct access_matrix);
   unsigned i, ndim = DR_NUM_DIMENSIONS (data_reference);
   struct loop *loop = bb_for_stmt (DR_STMT (data_reference))->loop_father;
-  unsigned nb_induction_vars = loop_depth (loop) - loop_nest_num + 1;
+  struct loop *loop_nest = get_loop (loop_nest_num);
+  unsigned nivs = loop_depth (loop) - loop_depth (loop_nest) + 1;
   unsigned lambda_nb_columns;
   lambda_vector_vec_p matrix;
 
   AM_LOOP_NEST_NUM (am) = loop_nest_num;
-  AM_NB_INDUCTION_VARS (am) = nb_induction_vars;
+  AM_NB_INDUCTION_VARS (am) = nivs;
   AM_PARAMETERS (am) = parameters;
 
   lambda_nb_columns = AM_NB_COLUMNS (am);

Reply via email to