]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/100934 - properly mark irreducible regions for DOM
authorRichard Biener <rguenther@suse.de>
Mon, 14 Jun 2021 12:57:26 +0000 (14:57 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 16 Jun 2021 12:06:50 +0000 (14:06 +0200)
The jump threading code requires marked irreducible regions for the
purpose of validating jump threading paths but DOM fails to provide
that resulting in mised number of iteration upper bounds clearing.

2021-06-14  Richard Biener  <rguenther@suse.de>

PR tree-optimization/100934
* tree-ssa-dom.c (pass_dominator::execute): Properly
mark irreducible regions.

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

(cherry picked from commit 788bb7edb3975b80c4cb16323e7a5e55a2471e46)

gcc/testsuite/gcc.dg/torture/pr100934.c [new file with mode: 0644]
gcc/tree-ssa-dom.c

diff --git a/gcc/testsuite/gcc.dg/torture/pr100934.c b/gcc/testsuite/gcc.dg/torture/pr100934.c
new file mode 100644 (file)
index 0000000..43b7884
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+
+int a, b, c, d, e;
+int main()
+{
+  int f = 0, g = 0;
+  for (; f < 2; f++)
+    {
+      int h, i;
+      for (h = 0; h < 2; h++)
+       {
+         b = e = g ? a % g : 0;
+         c = d;
+         for (i = 0; i < 1; i++)
+           g = 0;
+         for (; g < 2; g++)
+           ;
+       }
+    }
+  return 0;
+}
index 81abf35ac02411b02f337318cd3ee6c0dfe0247e..4786dbd3849bc91ed950b93a7fe49ddee39857a9 100644 (file)
@@ -695,7 +695,8 @@ pass_dominator::execute (function *fun)
      gcc.dg/tree-ssa/pr21417.c can't be threaded if loop preheader is
      missing.  We should improve jump threading in future then
      LOOPS_HAVE_PREHEADERS won't be needed here.  */
-  loop_optimizer_init (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_SIMPLE_LATCHES);
+  loop_optimizer_init (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_SIMPLE_LATCHES
+                      | LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS);
 
   /* Initialize the value-handle array.  */
   threadedge_initialize_values ();