re PR tree-optimization/83695 (ICE on valid code at -O3: Segmentation fault)
authorBin Cheng <bin.cheng@arm.com>
Thu, 11 Jan 2018 15:41:41 +0000 (15:41 +0000)
committerBin Cheng <amker@gcc.gnu.org>
Thu, 11 Jan 2018 15:41:41 +0000 (15:41 +0000)
PR tree-optimization/83695
* gimple-loop-linterchange.cc
(tree_loop_interchange::interchange_loops): Call scev_reset_htab to
reset cached scev information after interchange.
(pass_linterchange::execute): Remove call to scev_reset_htab.

gcc/testsuite
PR tree-optimization/83695
* gcc.dg/tree-ssa/pr83695.c: New test.

From-SVN: r256541

gcc/ChangeLog
gcc/gimple-loop-interchange.cc
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr83695.c [new file with mode: 0644]

index a23405a744d48b3be0a60a6886400db74be8edc3..878d72c22399f01d0b33e07361cec1bf7b168d5a 100644 (file)
@@ -1,3 +1,11 @@
+2018-01-11  Bin Cheng  <bin.cheng@arm.com>
+
+       PR tree-optimization/83695
+       * gimple-loop-linterchange.cc
+       (tree_loop_interchange::interchange_loops): Call scev_reset_htab to
+       reset cached scev information after interchange.
+       (pass_linterchange::execute): Remove call to scev_reset_htab.
+
 2018-01-11  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * config/arm/arm_neon.h (vfmlal_lane_low_u32, vfmlal_lane_high_u32,
index 01a26c07c421ff0728f1a5b983cf30e5dc8d5d71..eb35263e69c835723b2d77be598f36af4ed4024e 100644 (file)
@@ -1119,6 +1119,10 @@ tree_loop_interchange::interchange_loops (loop_cand &iloop, loop_cand &oloop)
   oloop.m_loop->any_likely_upper_bound = false;
   free_numbers_of_iterations_estimates (oloop.m_loop);
 
+  /* Clear all cached scev information.  This is expensive but shouldn't be
+     a problem given we interchange in very limited times.  */
+  scev_reset_htab ();
+
   /* ???  The association between the loop data structure and the
      CFG changed, so what was loop N at the source level is now
      loop M.  We should think of retaining the association or breaking
@@ -2070,9 +2074,6 @@ pass_linterchange::execute (function *fun)
       loop_nest.release ();
     }
 
-  if (changed_p)
-    scev_reset_htab ();
-
   return changed_p ? (TODO_update_ssa_only_virtuals) : 0;
 }
 
index b3d2fcbc1243d716134c08bef4e32e55c4bdca73..7681b0eb78ddd2baa6d5d7e3fee1708da491ebd1 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-11  Bin Cheng  <bin.cheng@arm.com>
+
+       PR tree-optimization/83695
+       * gcc.dg/tree-ssa/pr83695.c: New test.
+
 2018-01-11  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * gcc.target/arm/simd/fp16fml_lane_high.c: New test.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr83695.c b/gcc/testsuite/gcc.dg/tree-ssa/pr83695.c
new file mode 100644 (file)
index 0000000..af56a31
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+int a[3][3][3], b, d;
+short c;
+unsigned char e;
+
+static void f ()
+{
+  for (c = 0; c < 2; c++)
+      for (e = 0; e < 3; e++)
+        for (b = 0; b < 3; b++)
+          a[b][e][b] = 0;
+  while (1)
+    ;
+}
+
+int main ()
+{
+  if (d)
+    f ();
+  return 0;
+}