From: Richard Biener Date: Fri, 17 May 2019 12:04:21 +0000 (+0000) Subject: gimple-parser.c (c_parser_gimple_statement): Handle __VEC_PERM. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c4499192638ad901fc03021834eec60399bfa736;p=gcc.git gimple-parser.c (c_parser_gimple_statement): Handle __VEC_PERM. 2019-05-17 Richard Biener c/ * gimple-parser.c (c_parser_gimple_statement): Handle __VEC_PERM. (c_parser_gimple_unary_expression): Likewise. (c_parser_gimple_parentized_ternary_expression): New function. * gimple-pretty-print.c (dump_ternary_rhs): Handle dumping VEC_PERM_EXPR as __VEC_PERM with -gimple. * gcc.dg/gimplefe-41.c: New testcase. From-SVN: r271320 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4f4711177cf..16b67c49da8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-05-17 Richard Biener + + * gimple-pretty-print.c (dump_ternary_rhs): Handle dumping + VEC_PERM_EXPR as __VEC_PERM with -gimple. + 2019-05-17 Andreas Krebbel * config/s390/s390-builtins.def (s390_vec_sldw_*): Use the diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index c42d67a3e32..863fabfffdd 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2019-05-17 Richard Biener + + * gimple-parser.c (c_parser_gimple_statement): Handle __VEC_PERM. + (c_parser_gimple_unary_expression): Likewise. + (c_parser_gimple_parentized_ternary_expression): New function. + 2019-05-16 Richard Biener * gimple-parser.c (c_parser_gimple_statement): Handle __BIT_INSERT. diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index 6a15b99c215..275ad911d08 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -746,8 +746,9 @@ c_parser_gimple_statement (gimple_parser &parser, gimple_seq *seq) if (strcmp (IDENTIFIER_POINTER (id), "__ABS") == 0 || strcmp (IDENTIFIER_POINTER (id), "__ABSU") == 0 || strcmp (IDENTIFIER_POINTER (id), "__MIN") == 0 + || strcmp (IDENTIFIER_POINTER (id), "__MAX") == 0 || strcmp (IDENTIFIER_POINTER (id), "__BIT_INSERT") == 0 - || strcmp (IDENTIFIER_POINTER (id), "__MAX") == 0) + || strcmp (IDENTIFIER_POINTER (id), "__VEC_PERM") == 0) goto build_unary_expr; break; } @@ -1012,6 +1013,38 @@ c_parser_gimple_parentized_binary_expression (gimple_parser &parser, return ret; } +/* Parse a gimple parentized binary expression. */ + +static c_expr +c_parser_gimple_parentized_ternary_expression (gimple_parser &parser, + location_t op_loc, + tree_code code) +{ + struct c_expr ret; + ret.set_error (); + + c_parser_consume_token (parser); + if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) + return ret; + c_expr op1 = c_parser_gimple_postfix_expression (parser); + if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>")) + return ret; + c_expr op2 = c_parser_gimple_postfix_expression (parser); + if (!c_parser_require (parser, CPP_COMMA, "expected %<)%>")) + return ret; + c_expr op3 = c_parser_gimple_postfix_expression (parser); + if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>")) + return ret; + + if (op1.value != error_mark_node + && op2.value != error_mark_node + && op3.value != error_mark_node) + ret.value = build3_loc (op_loc, + code, TREE_TYPE (op1.value), + op1.value, op2.value, op3.value); + return ret; +} + /* Parse gimple unary expression. gimple-unary-expression: @@ -1109,6 +1142,9 @@ c_parser_gimple_unary_expression (gimple_parser &parser) return c_parser_gimple_parentized_binary_expression (parser, op_loc, MAX_EXPR); + else if (strcmp (IDENTIFIER_POINTER (id), "__VEC_PERM") == 0) + return c_parser_gimple_parentized_ternary_expression + (parser, op_loc, VEC_PERM_EXPR); else if (strcmp (IDENTIFIER_POINTER (id), "__BIT_INSERT") == 0) { /* __BIT_INSERT '(' postfix-expression, postfix-expression, diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index c1c08644638..10f79ea619e 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -529,13 +529,19 @@ dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, break; case VEC_PERM_EXPR: - pp_string (buffer, "VEC_PERM_EXPR <"); + if (flags & TDF_GIMPLE) + pp_string (buffer, "__VEC_PERM ("); + else + pp_string (buffer, "VEC_PERM_EXPR <"); dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); pp_string (buffer, ", "); dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); pp_string (buffer, ", "); dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); - pp_greater (buffer); + if (flags & TDF_GIMPLE) + pp_right_paren (buffer); + else + pp_greater (buffer); break; case REALIGN_LOAD_EXPR: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 053a9492168..650c25a89e5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-05-17 Richard Biener + + * gcc.dg/gimplefe-41.c: New testcase. + 2019-05-17 Jun Ma PR tree-optimization/90106 diff --git a/gcc/testsuite/gcc.dg/gimplefe-41.c b/gcc/testsuite/gcc.dg/gimplefe-41.c new file mode 100644 index 00000000000..cd642d68fd0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-41.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -Wno-psabi -w" } */ + +typedef double __v2df __attribute__ ((__vector_size__ (16))); +typedef unsigned long __v2di __attribute__ ((__vector_size__ (16))); + +__v2df __GIMPLE (ssa) +_mm_add_sd (__v2df x, __v2df y) +{ + __v2df z; + double _1; + double _2; + double _3; + __v2df _7; + + __BB(2): + _1 = __BIT_FIELD_REF (x_4(D), 64u, 0u); + _2 = __BIT_FIELD_REF (y_5(D), 64u, 0u); + _3 = _1 + _2; + _7 = _Literal (__v2df) {_3, _3}; + z_6 = __VEC_PERM (x_4(D), _7, _Literal (__v2di) { 2ul, 1ul }); + return z_6; +} + +__v2df __GIMPLE (ssa) +_mm_add_sd2 (__v2df x, __v2df y) +{ + __v2df z; + double _1; + double _2; + double _3; + + __BB(2): + _1 = __BIT_FIELD_REF (x_4(D), 64u, 0u); + _2 = __BIT_FIELD_REF (y_5(D), 64u, 0u); + _3 = _1 + _2; + z_6 = __BIT_INSERT (x_4(D), _3, 0); + return z_6; +}