On Fri, 17 May 2019 at 11:24, Richard Biener <[email protected]> wrote:
>
>
> Bootstrap / testing in progress on x86_64-unknown-linux-gnu.
>
> Richard.
>
> 2019-05-17 Richard Biener <[email protected]>
>
> 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.
>
Hi,
This causes an ICE on arm:
/gcc/testsuite/gcc.dg/gimplefe-41.c: In function '_mm_add_sd':
/gcc/testsuite/gcc.dg/gimplefe-41.c:39:1: error: vectors with
different element number found in vector permute expression
__v2df
__v2df
vector(2) double
__v2di
z_6 = VEC_PERM_EXPR <x_4(D), _7, { 2, 1, 0, 0 }>;
during IPA pass: *free_lang_data
/gcc/testsuite/gcc.dg/gimplefe-41.c:39:1: internal compiler error:
verify_gimple failed
0xc47110 verify_gimple_in_cfg(function*, bool)
/gcc/tree-cfg.c:5396
0xb0b673 execute_function_todo
/gcc/passes.c:1963
0xb0bf3d do_per_function
/gcc/passes.c:1645
0xb0c009 execute_todo
/gcc/passes.c:2017
Christophe
> Index: gcc/c/gimple-parser.c
> ===================================================================
> --- gcc/c/gimple-parser.c (revision 271315)
> +++ gcc/c/gimple-parser.c (working copy)
> @@ -746,8 +746,9 @@ c_parser_gimple_statement (gimple_parser
> 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_expres
> 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
> 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,
> Index: gcc/gimple-pretty-print.c
> ===================================================================
> --- gcc/gimple-pretty-print.c (revision 271315)
> +++ gcc/gimple-pretty-print.c (working copy)
> @@ -529,13 +529,19 @@ dump_ternary_rhs (pretty_printer *buffer
> 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:
> Index: gcc/testsuite/gcc.dg/gimplefe-41.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/gimplefe-41.c (nonexistent)
> +++ gcc/testsuite/gcc.dg/gimplefe-41.c (working copy)
> @@ -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 <double> (x_4(D), 64u, 0u);
> + _2 = __BIT_FIELD_REF <double> (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 <double> (x_4(D), 64u, 0u);
> + _2 = __BIT_FIELD_REF <double> (y_5(D), 64u, 0u);
> + _3 = _1 + _2;
> + z_6 = __BIT_INSERT (x_4(D), _3, 0);
> + return z_6;
> +}