tree-optimization/104676 - free nb_iterations after loop distribution
authorRichard Biener <rguenther@suse.de>
Thu, 24 Feb 2022 13:34:52 +0000 (14:34 +0100)
committerRichard Biener <rguenther@suse.de>
Thu, 24 Feb 2022 14:57:55 +0000 (15:57 +0100)
Loop distribution can release SSA names used in nb_iterations, make
sure to release those.

2022-02-24  Richard Biener  <rguenther@suse.de>

PR tree-optimization/104676
* tree-loop-distribution.cc (loop_distribution::execute):
Do a full scev_reset.

* gcc.dg/torture/pr104676.c: New testcase.

gcc/testsuite/gcc.dg/torture/pr104676.c [new file with mode: 0644]
gcc/tree-loop-distribution.cc

diff --git a/gcc/testsuite/gcc.dg/torture/pr104676.c b/gcc/testsuite/gcc.dg/torture/pr104676.c
new file mode 100644 (file)
index 0000000..50845bb
--- /dev/null
@@ -0,0 +1,35 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ftree-loop-distribution -ftree-parallelize-loops=2" } */
+
+struct S {
+  int f;
+};
+
+int n;
+
+int
+foo (struct S *s)
+{
+  int arr[3];
+  int v = 0;
+
+  for (n = 0; n < 2; ++n)
+    {
+      int i;
+
+      for (i = 0; i < 2; ++i)
+        {
+          int j;
+
+          for (j = 0; j < s->f; ++j)
+            ++v;
+        }
+
+      if (v)
+        arr[0] = 0;
+
+      arr[n + 1] = 0;
+    }
+
+  return arr[0];
+}
index c7b4285..8ee40d8 100644 (file)
@@ -3853,7 +3853,7 @@ loop_distribution::execute (function *fun)
 
       /* Cached scalar evolutions now may refer to wrong or non-existing
         loops.  */
-      scev_reset_htab ();
+      scev_reset ();
       mark_virtual_operands_for_renaming (fun);
       rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
     }