gimple-parser.c (c_parser_gimple_expr_list): Simplify.
authorRichard Biener <rguenther@suse.de>
Tue, 7 Feb 2017 11:26:08 +0000 (11:26 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 7 Feb 2017 11:26:08 +0000 (11:26 +0000)
2017-02-07  Richard Biener  <rguenther@suse.de>

c/
* gimple-parser.c (c_parser_gimple_expr_list): Simplify.
(c_parser_gimple_postfix_expression_after_primary):
Do not use c_build_function_call_vec to avoid folding and promotion.
Simplify.

* gcc.dg/gimplefe-23.c: New testcase.
* gcc.dg/gimplefe-24.c: Likewise.

From-SVN: r245244

gcc/c/ChangeLog
gcc/c/gimple-parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/gimplefe-23.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gimplefe-24.c [new file with mode: 0644]

index 16fb6f8..1ab194a 100644 (file)
@@ -1,3 +1,10 @@
+2017-02-07  Richard Biener  <rguenther@suse.de>
+
+       * gimple-parser.c (c_parser_gimple_expr_list): Simplify.
+       (c_parser_gimple_postfix_expression_after_primary):
+       Do not use c_build_function_call_vec to avoid folding and promotion.
+       Simplify.
+
 2017-01-25  Maxim Ostapenko  <m.ostapenko@samsung.com>
 
        PR lto/79061
index 7feb6d0..e167e42 100644 (file)
@@ -73,8 +73,7 @@ static void c_parser_gimple_switch_stmt (c_parser *, gimple_seq *);
 static void c_parser_gimple_return_stmt (c_parser *, gimple_seq *);
 static void c_finish_gimple_return (location_t, tree);
 static tree c_parser_gimple_paren_condition (c_parser *);
-static vec<tree, va_gc> *c_parser_gimple_expr_list (c_parser *,
-                   vec<tree, va_gc> **, vec<location_t> *);
+static void c_parser_gimple_expr_list (c_parser *, vec<tree> *);
 
 
 /* Parse the body of a function declaration marked with "__GIMPLE".  */
@@ -898,10 +897,6 @@ c_parser_gimple_postfix_expression_after_primary (c_parser *parser,
                                                  location_t expr_loc,
                                                  struct c_expr expr)
 {
-  struct c_expr orig_expr;
-  vec<tree, va_gc> *exprlist;
-  vec<tree, va_gc> *origtypes = NULL;
-  vec<location_t> arg_loc = vNULL;
   location_t start;
   location_t finish;
   tree ident;
@@ -936,34 +931,16 @@ c_parser_gimple_postfix_expression_after_primary (c_parser *parser,
          {
            /* Function call.  */
            c_parser_consume_token (parser);
-           if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
-             exprlist = NULL;
-           else
-             exprlist = c_parser_gimple_expr_list (parser, &origtypes,
-                                                   &arg_loc);
+           auto_vec<tree> exprlist;
+           if (! c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
+             c_parser_gimple_expr_list (parser, &exprlist);
            c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
                                       "expected %<)%>");
-           orig_expr = expr;
-           start = expr.get_start ();
-           finish = c_parser_tokens_buf (parser, 0)->get_finish ();
-           expr.value = c_build_function_call_vec (expr_loc, arg_loc,
-                                                   expr.value,
-                                                   exprlist, origtypes);
-           set_c_expr_source_range (&expr, start, finish);
-
+           expr.value = build_call_array_loc
+               (expr_loc, TREE_TYPE (TREE_TYPE (expr.value)),
+                expr.value, exprlist.length (), exprlist.address ());
            expr.original_code = ERROR_MARK;
-           if (TREE_CODE (expr.value) == INTEGER_CST
-               && TREE_CODE (orig_expr.value) == FUNCTION_DECL
-               && DECL_BUILT_IN_CLASS (orig_expr.value) == BUILT_IN_NORMAL
-               && DECL_FUNCTION_CODE (orig_expr.value) == BUILT_IN_CONSTANT_P)
-             expr.original_code = C_MAYBE_CONST_EXPR;
            expr.original_type = NULL;
-           if (exprlist)
-             {
-               release_tree_vector (exprlist);
-               release_tree_vector (origtypes);
-             }
-           arg_loc.release ();
            break;
          }
        case CPP_DOT:
@@ -1058,41 +1035,19 @@ c_parser_gimple_postfix_expression_after_primary (c_parser *parser,
 
  */
 
-static vec<tree, va_gc> *
-c_parser_gimple_expr_list (c_parser *parser, vec<tree, va_gc> **p_orig_types,
-                          vec<location_t> *locations)
+static void
+c_parser_gimple_expr_list (c_parser *parser, vec<tree> *ret)
 {
-  vec<tree, va_gc> *ret;
-  vec<tree, va_gc> *orig_types;
   struct c_expr expr;
-  location_t loc = c_parser_peek_token (parser)->location;
-
-  ret = make_tree_vector ();
-  if (p_orig_types == NULL)
-    orig_types = NULL;
-  else
-    orig_types = make_tree_vector ();
 
   expr = c_parser_gimple_unary_expression (parser);
-  vec_safe_push (ret, expr.value);
-  if (orig_types)
-    vec_safe_push (orig_types, expr.original_type);
-  if (locations)
-    locations->safe_push (loc);
+  ret->safe_push (expr.value);
   while (c_parser_next_token_is (parser, CPP_COMMA))
     {
       c_parser_consume_token (parser);
-      loc = c_parser_peek_token (parser)->location;
       expr = c_parser_gimple_unary_expression (parser);
-      vec_safe_push (ret, expr.value);
-      if (orig_types)
-       vec_safe_push (orig_types, expr.original_type);
-      if (locations)
-       locations->safe_push (loc);
+      ret->safe_push (expr.value);
     }
-  if (orig_types)
-    *p_orig_types = orig_types;
-  return ret;
 }
 
 /* Parse gimple label.
index e83e85f..517d562 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-07  Richard Biener  <rguenther@suse.de>
+
+       * gcc.dg/gimplefe-23.c: New testcase.
+       * gcc.dg/gimplefe-24.c: Likewise.
+
 2017-02-07  Christophe Lyon  <christophe.lyon@linaro.org>
 
        * gcc.target/aarch64/test_frame_1.c: Scan epilogue with
diff --git a/gcc/testsuite/gcc.dg/gimplefe-23.c b/gcc/testsuite/gcc.dg/gimplefe-23.c
new file mode 100644 (file)
index 0000000..05f87ed
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple" } */
+
+short int __GIMPLE ()
+foo (short int s)
+{
+  short int D_1803;
+
+bb_2:
+  D_1803 = s;
+
+L0:
+  return D_1803;
+
+}
+
+int __GIMPLE ()
+main (int argc, char * * argv)
+{
+  short int s;
+  int D_1805;
+  int _1;
+  short _2;
+
+bb_2:
+  s = (short int) argc;
+  _1 = (int) s;
+  _2 = foo (_1);
+  D_1805 = (int) _2;
+
+L0:
+  return D_1805;
+}
diff --git a/gcc/testsuite/gcc.dg/gimplefe-24.c b/gcc/testsuite/gcc.dg/gimplefe-24.c
new file mode 100644 (file)
index 0000000..1f8dbb4
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple" } */
+
+int __GIMPLE foo(int a)
+{
+  int t1;
+  t1_1 = __builtin_abs (a);
+  return t1_1;
+}