]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/87645 (gcc hangs up on vr_values::vrp_visit_assignment_or_call)
authorRichard Biener <rguenther@suse.de>
Mon, 26 Nov 2018 14:16:01 +0000 (14:16 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 26 Nov 2018 14:16:01 +0000 (14:16 +0000)
2018-10-19  Richard Biener  <rguenther@suse.de>

PR middle-end/87645
Backport from mainline
2018-07-12  Richard Biener  <rguenther@suse.de>

* gimple-match-head.c (gimple_resimplify1): Apply recursion
limit.
(gimple_resimplify2): Likewise.
(gimple_resimplify3): Likewise.
(gimple_resimplify4): Likewise.

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

From-SVN: r266461

gcc/ChangeLog
gcc/gimple-match-head.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr87645.c [new file with mode: 0644]

index 77d3a77c399b33446dc9291d4bbd64bac02bb477..68091e8c5848bb8b46f085ec173affe2edb1a6fe 100644 (file)
@@ -1,3 +1,15 @@
+2018-10-19  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/87645
+       Backport from mainline
+       2018-07-12  Richard Biener  <rguenther@suse.de>
+
+       * gimple-match-head.c (gimple_resimplify1): Apply recursion
+       limit.
+       (gimple_resimplify2): Likewise.
+       (gimple_resimplify3): Likewise.
+       (gimple_resimplify4): Likewise.
+
 2018-11-26  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
index e7e9839a4b84195cd6bf1c69f83e2d99d5f13d65..5a0d33174fbca7363e46105e9cfe61644860813d 100644 (file)
@@ -99,17 +99,34 @@ gimple_resimplify1 (gimple_seq *seq,
        }
     }
 
+  /* Limit recursion, there are cases like PR80887 and others, for
+     example when value-numbering presents us with unfolded expressions
+     that we are really not prepared to handle without eventual
+     oscillation like ((_50 + 0) + 8) where _50 gets mapped to _50
+     itself as available expression.  */
+  static unsigned depth;
+  if (depth > 10)
+    {
+      if (dump_file && (dump_flags & TDF_DETAILS))
+       fprintf (dump_file, "Aborting expression simplification due to "
+                "deep recursion\n");
+      return false;
+    }
+
+  ++depth;
   code_helper res_code2;
   tree res_ops2[3] = {};
   if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
                       *res_code, type, res_ops[0]))
     {
+      --depth;
       *res_code = res_code2;
       res_ops[0] = res_ops2[0];
       res_ops[1] = res_ops2[1];
       res_ops[2] = res_ops2[2];
       return true;
     }
+  --depth;
 
   return false;
 }
@@ -159,17 +176,30 @@ gimple_resimplify2 (gimple_seq *seq,
       canonicalized = true;
     }
 
+  /* Limit recursion, see gimple_resimplify1.  */
+  static unsigned depth;
+  if (depth > 10)
+    {
+      if (dump_file && (dump_flags & TDF_DETAILS))
+       fprintf (dump_file, "Aborting expression simplification due to "
+                "deep recursion\n");
+      return false;
+    }
+
+  ++depth;
   code_helper res_code2;
   tree res_ops2[3] = {};
   if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
                       *res_code, type, res_ops[0], res_ops[1]))
     {
+      --depth;
       *res_code = res_code2;
       res_ops[0] = res_ops2[0];
       res_ops[1] = res_ops2[1];
       res_ops[2] = res_ops2[2];
       return true;
     }
+  --depth;
 
   return canonicalized;
 }
@@ -218,18 +248,31 @@ gimple_resimplify3 (gimple_seq *seq,
       canonicalized = true;
     }
 
+  /* Limit recursion, see gimple_resimplify1.  */
+  static unsigned depth;
+  if (depth > 10)
+    {
+      if (dump_file && (dump_flags & TDF_DETAILS))
+       fprintf (dump_file, "Aborting expression simplification due to "
+                "deep recursion\n");
+      return false;
+    }
+
+  ++depth;
   code_helper res_code2;
   tree res_ops2[3] = {};
   if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
                       *res_code, type,
                       res_ops[0], res_ops[1], res_ops[2]))
     {
+      --depth;
       *res_code = res_code2;
       res_ops[0] = res_ops2[0];
       res_ops[1] = res_ops2[1];
       res_ops[2] = res_ops2[2];
       return true;
     }
+  --depth;
 
   return canonicalized;
 }
index c260750ffe4d3719b8347ca7e4d5468eb2a1bbc0..1c365d2fd7ebc95535d00ff2e82c4d60e5832e31 100644 (file)
@@ -1,3 +1,11 @@
+2018-10-19  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/87645
+       Backport from mainline
+       2018-07-12  Richard Biener  <rguenther@suse.de>
+
+       * gcc.dg/torture/pr87645.c: New testcase.
+
 2018-11-26  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.dg/torture/pr87645.c b/gcc/testsuite/gcc.dg/torture/pr87645.c
new file mode 100644 (file)
index 0000000..5360e38
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+typedef unsigned a[8];
+a b, g;
+int c, d, e, f;
+int h() {
+    unsigned i = 2;
+    for (; i < 8; i++)
+      b[i] = 0;
+    for (; f;) {
+       d = 1;
+       for (; d < 14; d += 3) {
+           e = 0;
+           for (; e < 8; e++) {
+               i = 2;
+               for (; i < 8; i++)
+                 b[i] = 5 - (c - g[e] + b[i]);
+           }
+       }
+    }
+}