Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2018-01-31  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/84132
        * tree-data-ref.c (analyze_miv_subscript): Properly
        check whether evolution_function_is_affine_multivariate_p
        before calling gcd_of_steps_may_divide_p.

        * g++.dg/torture/pr84132.C: New testcase.

Index: gcc/tree-data-ref.c
===================================================================
--- gcc/tree-data-ref.c (revision 257181)
+++ gcc/tree-data-ref.c (working copy)
@@ -3976,9 +3976,8 @@ analyze_miv_subscript (tree chrec_a,
     }
 
   else if (evolution_function_is_constant_p (difference)
-          /* For the moment, the following is verified:
-             evolution_function_is_affine_multivariate_p (chrec_a,
-             loop_nest->num) */
+          && evolution_function_is_affine_multivariate_p (chrec_a,
+                                                          loop_nest->num)
           && !gcd_of_steps_may_divide_p (chrec_a, difference))
     {
       /* testsuite/.../ssa-chrec-33.c
Index: gcc/testsuite/g++.dg/torture/pr84132.C
===================================================================
--- gcc/testsuite/g++.dg/torture/pr84132.C      (nonexistent)
+++ gcc/testsuite/g++.dg/torture/pr84132.C      (working copy)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+struct g {
+    char b;
+    unsigned char *d[];
+} e;
+unsigned char f;
+void i()
+{
+  for (int h;; h++)
+    {
+      unsigned a = h;
+      for (int c = 0; c < 256; c += 6)
+       for (int h = c; h < c + 6; h++)
+         e.d[h + a] = &f;
+    }
+}

Reply via email to