From: Richard Biener Date: Tue, 7 Feb 2017 11:26:08 +0000 (+0000) Subject: gimple-parser.c (c_parser_gimple_expr_list): Simplify. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7af4b20d83a8ce3033148f0d14c2e725791a7afd;p=gcc.git gimple-parser.c (c_parser_gimple_expr_list): Simplify. 2017-02-07 Richard Biener 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 --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 16fb6f8a9f9..1ab194a6310 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,10 @@ +2017-02-07 Richard Biener + + * 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 PR lto/79061 diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index 7feb6d09031..e167e420150 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -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 *c_parser_gimple_expr_list (c_parser *, - vec **, vec *); +static void c_parser_gimple_expr_list (c_parser *, vec *); /* 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 *exprlist; - vec *origtypes = NULL; - vec 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 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 * -c_parser_gimple_expr_list (c_parser *parser, vec **p_orig_types, - vec *locations) +static void +c_parser_gimple_expr_list (c_parser *parser, vec *ret) { - vec *ret; - vec *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. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e83e85f64c0..517d5621bac 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-02-07 Richard Biener + + * gcc.dg/gimplefe-23.c: New testcase. + * gcc.dg/gimplefe-24.c: Likewise. + 2017-02-07 Christophe Lyon * 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 index 00000000000..05f87ed4df4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-23.c @@ -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 index 00000000000..1f8dbb47253 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-24.c @@ -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; +}