]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/59817 (ICE in extract_affine_chrec with -O2 -ftree-loop-linear)
authorRichard Biener <rguenther@suse.de>
Mon, 14 Apr 2014 08:09:06 +0000 (08:09 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 14 Apr 2014 08:09:06 +0000 (08:09 +0000)
2014-04-14  Richard Biener  <rguenther@suse.de>

PR tree-optimization/59817
PR tree-optimization/60453
* graphite-scop-detection.c (graphite_can_represent_scev): Complete
recursion to catch all CHRECs in the scalar evolution and restrict
the predicate for the remains appropriately.

* gfortran.dg/graphite/pr59817.f: New testcase.
* gcc.dg/graphite/pr59817-1.c: Likewise.
* gcc.dg/graphite/pr59817-2.c: Likewise.

From-SVN: r209355

gcc/ChangeLog
gcc/graphite-scop-detection.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/graphite/pr59817-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/graphite/pr59817-2.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/graphite/pr59817.f [new file with mode: 0644]

index b343e00468e09e346633a1a49593ed0f44ed5b02..a80c21f27decbf74b998ee9a9ca743432dace37d 100644 (file)
@@ -1,3 +1,11 @@
+2014-04-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/59817
+       PR tree-optimization/60453
+       * graphite-scop-detection.c (graphite_can_represent_scev): Complete
+       recursion to catch all CHRECs in the scalar evolution and restrict
+       the predicate for the remains appropriately.
+
 2014-04-12  Catherine Moore  <clm@codesourcery.com>
 
        * config/mips/constraints.md: Add new register constraint "kb".
index b5e4a8c8cb3d4ad3d65800df917cf0fa43f6258f..821f0846ef2bbda19adef9badfba22d6f921a591 100644 (file)
@@ -219,7 +219,14 @@ graphite_can_represent_scev (tree scev)
 
   switch (TREE_CODE (scev))
     {
+    case NEGATE_EXPR:
+    case BIT_NOT_EXPR:
+    CASE_CONVERT:
+    case NON_LVALUE_EXPR:
+      return graphite_can_represent_scev (TREE_OPERAND (scev, 0));
+
     case PLUS_EXPR:
+    case POINTER_PLUS_EXPR:
     case MINUS_EXPR:
       return graphite_can_represent_scev (TREE_OPERAND (scev, 0))
        && graphite_can_represent_scev (TREE_OPERAND (scev, 1));
@@ -241,13 +248,15 @@ graphite_can_represent_scev (tree scev)
       if (!evolution_function_right_is_integer_cst (scev)
          || !graphite_can_represent_init (scev))
        return false;
+      return graphite_can_represent_scev (CHREC_LEFT (scev));
 
     default:
       break;
     }
 
   /* Only affine functions can be represented.  */
-  if (!scev_is_linear_expression (scev))
+  if (tree_contains_chrecs (scev, NULL)
+      || !scev_is_linear_expression (scev))
     return false;
 
   return true;
index cb235b32071d1caeea5b9d446f6967b318204b1d..e09c499db71a6d6e73e584dce9d6e34278d9964b 100644 (file)
@@ -1,3 +1,11 @@
+2014-04-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/59817
+       PR tree-optimization/60453
+       * gfortran.dg/graphite/pr59817.f: New testcase.
+       * gcc.dg/graphite/pr59817-1.c: Likewise.
+       * gcc.dg/graphite/pr59817-2.c: Likewise.
+
 2014-04-14  Jason Merrill  <jason@redhat.com>
 
        Revert:
diff --git a/gcc/testsuite/gcc.dg/graphite/pr59817-1.c b/gcc/testsuite/gcc.dg/graphite/pr59817-1.c
new file mode 100644 (file)
index 0000000..175fa16
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-interchange" } */
+
+int kd;
+
+void
+n2(void)
+{
+  static int so;
+  static short int i5;
+  int wj;
+  int *il;
+  int *nk = &so;
+  for (wj = 0; wj < 2; ++wj)
+    *nk = ((i5 += *il) || kd );
+}
diff --git a/gcc/testsuite/gcc.dg/graphite/pr59817-2.c b/gcc/testsuite/gcc.dg/graphite/pr59817-2.c
new file mode 100644 (file)
index 0000000..1395007
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-interchange" } */
+
+void
+xl(void)
+{
+  static int j3;
+  for (j3 = 0; j3 < 1; ++j3) {
+      static int f2;
+      static int w7;
+      short int b5;
+      int ok;
+      f2 = (b5 += ok) ? (w7 = 0): (w7 ? 0 : (f2 = ok));
+  }
+}
diff --git a/gcc/testsuite/gfortran.dg/graphite/pr59817.f b/gcc/testsuite/gfortran.dg/graphite/pr59817.f
new file mode 100644 (file)
index 0000000..a9ee8f1
--- /dev/null
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! { dg-options "-O2 -floop-interchange" }
+      SUBROUTINE PREPD(ICAST,ICAS,ICASX,ICAS1,ICAS2,NDET,NM,III,IMP,
+     *                 CASMIN)
+      LOGICAL CASMIN
+      DIMENSION ICAST(NDET,NM),IMP(NM)
+      IF(CASMIN) THEN
+         DO K=1,NDET
+            DO L=1,NM
+               IF(L.EQ.K-1) ICAST(K,L) = 1
+            END DO
+         END DO
+      END IF
+      END SUBROUTINE