]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR bootstrap/80887 (gnat bootstrap fails at s-regpat.o: raised STORAGE_ERROR ...
authorRichard Biener <rguenther@suse.de>
Mon, 19 Jun 2017 15:01:13 +0000 (15:01 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 19 Jun 2017 15:01:13 +0000 (15:01 +0000)
2017-06-19  Richard Biener  <rguenther@suse.de>

PR tree-optimization/80887
        c/
* gimple-parser.c (c_parser_gimple_postfix_expression): Handle
negated _Literals to parse _Literal (int) -1.

* tree-ssa-sccvn.c (mprts_hook_cnt): New global.
(vn_lookup_simplify_result): Allow only mprts_hook_cnt succesful
simplified lookups, then reset mprts_hook.
(vn_nary_build_or_lookup_1): Set mprts_hook_cnt to 9 before
simplifying.
(try_to_simplify): Likewise.

* gcc.dg/tree-ssa/pr80887.c: New testcase.

From-SVN: r249373

gcc/ChangeLog
gcc/c/ChangeLog
gcc/c/gimple-parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr80887.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.c

index aab38b1ce78edeaa411a078ba43a27467eff608b..99a7242e5b25da8492991cde871c0bdda7e435b0 100644 (file)
@@ -1,3 +1,13 @@
+2017-06-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/80887
+       * tree-ssa-sccvn.c (mprts_hook_cnt): New global.
+       (vn_lookup_simplify_result): Allow only mprts_hook_cnt succesful
+       simplified lookups, then reset mprts_hook.
+       (vn_nary_build_or_lookup_1): Set mprts_hook_cnt to 9 before
+       simplifying.
+       (try_to_simplify): Likewise.
+
 2017-06-19  Martin Liska  <mliska@suse.cz>
 
        PR sanitizer/80879
index 173fa924a396044d9f00450799eeb0d666299e40..58d59a658710e5729dd76c5c5ed857779de0126d 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-19  Richard Biener  <rguenther@suse.de>
+
+       * gimple-parser.c (c_parser_gimple_postfix_expression): Handle
+       negated _Literals to parse _Literal (int) -1.
+
 2017-06-13  Martin Liska  <mliska@suse.cz>
 
        PR sanitize/78204
index 4a55904662e96cc3bb703ac3a9d27c1c289fc5fd..22f58f4e8207ba8b7fa252d94001cf7f5089bd3b 100644 (file)
@@ -850,7 +850,7 @@ c_parser_gimple_postfix_expression (c_parser *parser)
            }
          else if (strcmp (IDENTIFIER_POINTER (id), "_Literal") == 0)
            {
-             /* _Literal '(' type-name ')' number  */
+             /* _Literal '(' type-name ')' [ '-' ] constant */
              c_parser_consume_token (parser);
              tree type = NULL_TREE;
              if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
@@ -862,15 +862,27 @@ c_parser_gimple_postfix_expression (c_parser *parser)
                  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
                                             "expected %<)%>");
                }
+             bool neg_p;
+             if ((neg_p = c_parser_next_token_is (parser, CPP_MINUS)))
+               c_parser_consume_token (parser);
              tree val = c_parser_gimple_postfix_expression (parser).value;
              if (! type
                  || ! val
                  || val == error_mark_node
-                 || TREE_CODE (val) != INTEGER_CST)
+                 || ! CONSTANT_CLASS_P (val))
                {
                  c_parser_error (parser, "invalid _Literal");
                  return expr;
                }
+             if (neg_p)
+               {
+                 val = const_unop (NEGATE_EXPR, TREE_TYPE (val), val);
+                 if (! val)
+                   {
+                     c_parser_error (parser, "invalid _Literal");
+                     return expr;
+                   }
+               }
              expr.value = fold_convert (type, val);
              return expr;
            }
index f382a38d2d6b1819184913303bfdf3893014ba48..47e2a984f23d3062a9b0ef75a3d44a7c55fd8bc2 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/80887
+       * gcc.dg/tree-ssa/pr80887.c: New testcase.
+
 2017-06-19  Jakub Jelinek  <jakub@redhat.com>
 
        PR ipa/81112
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr80887.c b/gcc/testsuite/gcc.dg/tree-ssa/pr80887.c
new file mode 100644 (file)
index 0000000..df7a9d9
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple -O" } */
+
+int pos;
+void __GIMPLE (startwith("fre"))
+f()
+{
+  unsigned int t2;
+  unsigned int t1;
+  int a;
+  unsigned int u;
+  int _1;
+  int _2;
+  int _3;
+  unsigned int _4;
+  int _5;
+  unsigned int _6;
+
+bb_2:
+  _1 = pos;
+  _2 = _1 + 1;
+  pos = _2;
+  _3 = pos;
+  _4 = (unsigned int) _3;
+  u_9 = _4 + 4294967295u;
+  a_10 = pos;
+  _5 = a_10 + _Literal (int) -1;
+  t1_11 = (unsigned int) _5;
+  _6 = (unsigned int) a_10;
+  t2_12 = _6 + 4294967294u;
+  return;
+}
index 419da47b5b788c9d1a98e0a9c254fe693fa4fe4c..324cd73f513eb8b860f072825ccc191f27859947 100644 (file)
@@ -1639,6 +1639,7 @@ vn_reference_lookup_or_insert_for_pieces (tree vuse,
 }
 
 static vn_nary_op_t vn_nary_op_insert_stmt (gimple *stmt, tree result);
+static unsigned mprts_hook_cnt;
 
 /* Hook for maybe_push_res_to_seq, lookup the expression in the VN tables.  */
 
@@ -1648,8 +1649,22 @@ vn_lookup_simplify_result (code_helper rcode, tree type, tree *ops)
   if (!rcode.is_tree_code ())
     return NULL_TREE;
   vn_nary_op_t vnresult = NULL;
-  return vn_nary_op_lookup_pieces (TREE_CODE_LENGTH ((tree_code) rcode),
-                                  (tree_code) rcode, type, ops, &vnresult);
+  tree res = vn_nary_op_lookup_pieces (TREE_CODE_LENGTH ((tree_code) rcode),
+                                      (tree_code) rcode, type, ops, &vnresult);
+  /* We can end up endlessly recursing simplifications if the lookup above
+     presents us with a def-use chain that mirrors the original simplification.
+     See PR80887 for an example.  Limit successful lookup artificially
+     to 10 times if we are called as mprts_hook.  */
+  if (res
+      && mprts_hook
+      && --mprts_hook_cnt == 0)
+    {
+      if (dump_file && (dump_flags & TDF_DETAILS))
+       fprintf (dump_file, "Resetting mprts_hook after too many "
+                "invocations.\n");
+      mprts_hook = NULL;
+    }
+  return res;
 }
 
 /* Return a value-number for RCODE OPS... either by looking up an existing
@@ -1666,6 +1681,7 @@ vn_nary_build_or_lookup_1 (code_helper rcode, tree type, tree *ops,
      So first simplify and lookup this expression to see if it
      is already available.  */
   mprts_hook = vn_lookup_simplify_result;
+  mprts_hook_cnt = 9;
   bool res = false;
   switch (TREE_CODE_LENGTH ((tree_code) rcode))
     {
@@ -3896,6 +3912,7 @@ try_to_simplify (gassign *stmt)
 
   /* First try constant folding based on our current lattice.  */
   mprts_hook = vn_lookup_simplify_result;
+  mprts_hook_cnt = 9;
   tem = gimple_fold_stmt_to_constant_1 (stmt, vn_valueize, vn_valueize);
   mprts_hook = NULL;
   if (tem