re PR tree-optimization/90021 (ICE in index_in_loop_nest, at tree-data-ref.h:587...
authorBin Cheng <bin.cheng@linux.alibaba.com>
Tue, 23 Apr 2019 03:54:59 +0000 (03:54 +0000)
committerBin Cheng <amker@gcc.gnu.org>
Tue, 23 Apr 2019 03:54:59 +0000 (03:54 +0000)
PR tree-optimization/92001
* tree-chrec.c (evolution_function_is_univariate_p): New parameter
and check univariate against it.
* tree-chrec.h (evolution_function_is_univariate_p): New parameter.
* tree-data-ref.c (add_other_self_distances): Pass new argument.

gcc/testsuite
* gcc/testsuite/gfortran.dg/pr90021.f90: New test.

From-SVN: r270499

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr90021.f90 [new file with mode: 0644]
gcc/tree-chrec.c
gcc/tree-chrec.h
gcc/tree-data-ref.c

index d2446815605357952c6fce76e4290c465efcb51c..e52b4c45cd6bb5a5900c967225fb2924b69e3f74 100644 (file)
@@ -1,3 +1,11 @@
+2019-04-23  Bin Cheng  <bin.cheng@linux.alibaba.com>
+
+       PR tree-optimization/92001
+       * tree-chrec.c (evolution_function_is_univariate_p): New parameter
+       and check univariate against it.
+       * tree-chrec.h (evolution_function_is_univariate_p): New parameter.
+       * tree-data-ref.c (add_other_self_distances): Pass new argument.
+
 2019-04-21  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/90178
index e22996fde9c6298751d307a73fb1ccac22c842b6..e855e15d93fbf52c044c9d0a18ba7efab951ba32 100644 (file)
@@ -1,3 +1,8 @@
+2018-04-23  Bin Cheng  <bin.cheng@linux.alibaba.com>
+
+       PR tree-optimization/92001
+       * gcc/testsuite/gfortran.dg/pr90021.f90: New test.
+
 2019-04-22  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/90166
diff --git a/gcc/testsuite/gfortran.dg/pr90021.f90 b/gcc/testsuite/gfortran.dg/pr90021.f90
new file mode 100644 (file)
index 0000000..4689e8b
--- /dev/null
@@ -0,0 +1,21 @@
+! { dg-do compile }
+! { dg-options "-fno-tree-loop-ivcanon -O1 -floop-interchange -fno-tree-ccp -fno-tree-ch -fipa-pta" }
+! PR tree-optimization/90021
+
+MODULE a
+  INTEGER b
+CONTAINS
+  SUBROUTINE bar(c)
+    REAL c(1)
+    INTEGER g, d, e, f 
+    DO g = 1,3
+      DO f = 1,1
+        DO e = 1,3
+          DO d = 1,1
+            c(f-1+d) = c(f-1+d)*b
+          END DO
+        END DO
+      END DO
+    END DO
+  END
+  END
index 8b5371a29a7d92ce0b03f8495e361a99eaf304c7..813b87fd00b312294eecf801f46bff85cfd399c0 100644 (file)
@@ -1142,23 +1142,30 @@ evolution_function_is_affine_multivariate_p (const_tree chrec, int loopnum)
 }
 
 /* Determine whether the given tree is a function in zero or one
-   variables.  */
+   variables with respect to loop specified by LOOPNUM.  Note only positive
+   LOOPNUM stands for a real loop.  */
 
 bool
-evolution_function_is_univariate_p (const_tree chrec)
+evolution_function_is_univariate_p (const_tree chrec, int loopnum)
 {
   if (chrec == NULL_TREE)
     return true;
 
+  tree sub_chrec;
   switch (TREE_CODE (chrec))
     {
     case POLYNOMIAL_CHREC:
       switch (TREE_CODE (CHREC_LEFT (chrec)))
        {
        case POLYNOMIAL_CHREC:
-         if (CHREC_VARIABLE (chrec) != CHREC_VARIABLE (CHREC_LEFT (chrec)))
+         sub_chrec = CHREC_LEFT (chrec);
+         if (CHREC_VARIABLE (chrec) != CHREC_VARIABLE (sub_chrec)
+             && (loopnum <= 0
+                 || CHREC_VARIABLE (sub_chrec) == (unsigned) loopnum
+                 || flow_loop_nested_p (get_loop (cfun, loopnum),
+                                        get_chrec_loop (sub_chrec))))
            return false;
-         if (!evolution_function_is_univariate_p (CHREC_LEFT (chrec)))
+         if (!evolution_function_is_univariate_p (sub_chrec, loopnum))
            return false;
          break;
 
@@ -1171,9 +1178,14 @@ evolution_function_is_univariate_p (const_tree chrec)
       switch (TREE_CODE (CHREC_RIGHT (chrec)))
        {
        case POLYNOMIAL_CHREC:
-         if (CHREC_VARIABLE (chrec) != CHREC_VARIABLE (CHREC_RIGHT (chrec)))
+         sub_chrec = CHREC_RIGHT (chrec);
+         if (CHREC_VARIABLE (chrec) != CHREC_VARIABLE (sub_chrec)
+             && (loopnum <= 0
+                 || CHREC_VARIABLE (sub_chrec) == (unsigned) loopnum
+                 || flow_loop_nested_p (get_loop (cfun, loopnum),
+                                        get_chrec_loop (sub_chrec))))
            return false;
-         if (!evolution_function_is_univariate_p (CHREC_RIGHT (chrec)))
+         if (!evolution_function_is_univariate_p (sub_chrec, loopnum))
            return false;
          break;
 
index 258b5d53f8be1dea169636a8dccf093474c2e46e..dbbc1b182ac3d40504b1aeb6199b1f5b476def30 100644 (file)
@@ -85,7 +85,7 @@ extern bool chrec_contains_symbols_defined_in_loop (const_tree, unsigned);
 extern bool chrec_contains_undetermined (const_tree);
 extern bool tree_contains_chrecs (const_tree, int *);
 extern bool evolution_function_is_affine_multivariate_p (const_tree, int);
-extern bool evolution_function_is_univariate_p (const_tree);
+extern bool evolution_function_is_univariate_p (const_tree, int = 0);
 extern unsigned nb_vars_in_chrec (tree);
 extern bool evolution_function_is_invariant_p (tree, int);
 extern bool scev_is_linear_expression (tree);
index 51da181c1f14ea49ae2d2c7f3b48fc3008528e2e..ccb1cfc53695a4bde30f92f9488fac0cf7a07bbf 100644 (file)
@@ -4431,7 +4431,7 @@ add_other_self_distances (struct data_dependence_relation *ddr)
 
       if (TREE_CODE (access_fun) == POLYNOMIAL_CHREC)
        {
-         if (!evolution_function_is_univariate_p (access_fun))
+         if (!evolution_function_is_univariate_p (access_fun, loop->num))
            {
              if (DDR_NUM_SUBSCRIPTS (ddr) != 1)
                {