diff options
author | Richard Biener <rguenther@suse.de> | 2019-05-14 13:57:03 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2019-05-14 13:57:03 +0000 |
commit | 1158c5b424c9c3a24a47e6cdfce923b373d9b013 (patch) | |
tree | f39ff5f1467e061ddac32ce6a9d1bc7b552585a9 | |
parent | 22b6a9c1cd36af0db84954f104ff8448aa925f4d (diff) | |
download | gcc-1158c5b424c9c3a24a47e6cdfce923b373d9b013.zip gcc-1158c5b424c9c3a24a47e6cdfce923b373d9b013.tar.gz gcc-1158c5b424c9c3a24a47e6cdfce923b373d9b013.tar.bz2 |
gimple-parser.c (c_parser_gimple_statement): Remove questionable auto-promotion to VIEW_CONVERT_EXPR.
2019-05-14 Richard Biener <rguenther@suse.de>
* gimple-parser.c (c_parser_gimple_statement): Remove
questionable auto-promotion to VIEW_CONVERT_EXPR.
(c_parser_gimple_typespec): Split out from __MEM parsing.
(c_parser_gimple_postfix_expression): Handle __VIEW_CONVERT.
* tree-pretty-print.c (dump_generic_node): Dump VIEW_CONVERT_EXPR
as __VIEW_CONVERT with -gimple.
* gcc.dg/gimplefe-40.c: New testcase.
From-SVN: r271170
-rw-r--r-- | gcc/c/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/c/gimple-parser.c | 80 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/gimplefe-40.c | 15 |
4 files changed, 80 insertions, 28 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index cb8bfcb..493d588 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,12 @@ +2019-05-14 Richard Biener <rguenther@suse.de> + + * gimple-parser.c (c_parser_gimple_statement): Remove + questionable auto-promotion to VIEW_CONVERT_EXPR. + (c_parser_gimple_typespec): Split out from __MEM parsing. + (c_parser_gimple_postfix_expression): Handle __VIEW_CONVERT. + * tree-pretty-print.c (dump_generic_node): Dump VIEW_CONVERT_EXPR + as __VIEW_CONVERT with -gimple. + 2019-05-09 Martin Liska <mliska@suse.cz> * gimple-parser.c (c_parser_gimple_statement): Support __MIN and diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index 99f7647..7c1f1a9 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -724,14 +724,8 @@ c_parser_gimple_statement (gimple_parser &parser, gimple_seq *seq) && rhs.value != error_mark_node) { enum tree_code code = NOP_EXPR; - if (VECTOR_TYPE_P (TREE_TYPE (lhs.value))) - { - code = VIEW_CONVERT_EXPR; - rhs.value = build1 (VIEW_CONVERT_EXPR, - TREE_TYPE (lhs.value), rhs.value); - } - else if (FLOAT_TYPE_P (TREE_TYPE (lhs.value)) - && ! FLOAT_TYPE_P (TREE_TYPE (rhs.value))) + if (FLOAT_TYPE_P (TREE_TYPE (lhs.value)) + && ! FLOAT_TYPE_P (TREE_TYPE (rhs.value))) code = FLOAT_EXPR; else if (! FLOAT_TYPE_P (TREE_TYPE (lhs.value)) && FLOAT_TYPE_P (TREE_TYPE (rhs.value))) @@ -1247,6 +1241,36 @@ c_parser_gimple_call_internal (gimple_parser &parser) return expr; } +/* Parse '<' type [',' alignment] '>' and return a type on success + and NULL_TREE on error. */ + +static tree +c_parser_gimple_typespec (gimple_parser &parser) +{ + struct c_type_name *type_name = NULL; + tree alignment = NULL_TREE; + if (c_parser_require (parser, CPP_LESS, "expected %<<%>")) + { + type_name = c_parser_type_name (parser); + /* Optional alignment. */ + if (c_parser_next_token_is (parser, CPP_COMMA)) + { + c_parser_consume_token (parser); + alignment + = c_parser_gimple_postfix_expression (parser).value; + } + c_parser_skip_until_found (parser, + CPP_GREATER, "expected %<>%>"); + } + if (!type_name) + return NULL_TREE; + tree tem; + tree type = groktypename (type_name, &tem, NULL); + if (alignment) + type = build_aligned_type (type, tree_to_uhwi (alignment)); + return type; +} + /* Parse gimple postfix expression. gimple-postfix-expression: @@ -1316,21 +1340,7 @@ c_parser_gimple_postfix_expression (gimple_parser &parser) [ '+' number ] ')' */ location_t loc = c_parser_peek_token (parser)->location; c_parser_consume_token (parser); - struct c_type_name *type_name = NULL; - tree alignment = NULL_TREE; - if (c_parser_require (parser, CPP_LESS, "expected %<<%>")) - { - type_name = c_parser_type_name (parser); - /* Optional alignment. */ - if (c_parser_next_token_is (parser, CPP_COMMA)) - { - c_parser_consume_token (parser); - alignment - = c_parser_gimple_postfix_expression (parser).value; - } - c_parser_skip_until_found (parser, - CPP_GREATER, "expected %<>%>"); - } + tree type = c_parser_gimple_typespec (parser); struct c_expr ptr; ptr.value = error_mark_node; tree alias_off = NULL_TREE; @@ -1378,19 +1388,33 @@ c_parser_gimple_postfix_expression (gimple_parser &parser) c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); } - if (! type_name || c_parser_error (parser)) + if (! type || c_parser_error (parser)) { c_parser_set_error (parser, false); return expr; } - tree tem = NULL_TREE; - tree type = groktypename (type_name, &tem, NULL); - if (alignment) - type = build_aligned_type (type, tree_to_uhwi (alignment)); expr.value = build2_loc (loc, MEM_REF, type, ptr.value, alias_off); break; } + else if (strcmp (IDENTIFIER_POINTER (id), "__VIEW_CONVERT") == 0) + { + /* __VIEW_CONVERT '<' type-name [ ',' number ] '>' + '(' postfix-expression ')' */ + location_t loc = c_parser_peek_token (parser)->location; + c_parser_consume_token (parser); + tree type = c_parser_gimple_typespec (parser); + if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) + { + c_expr op = c_parser_gimple_postfix_expression (parser); + c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, + "expected %<)%>"); + if (type && op.value != error_mark_node) + expr.value = build1_loc (loc, VIEW_CONVERT_EXPR, + type, op.value); + } + break; + } else if (strcmp (IDENTIFIER_POINTER (id), "_Literal") == 0) { /* _Literal '(' type-name ')' ( [ '-' ] constant | constructor ) */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bec2168..5719425 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-05-14 Richard Biener <rguenther@suse.de> + + * gcc.dg/gimplefe-40.c: New testcase. + 2019-05-14 Paolo Carlini <paolo.carlini@oracle.com> PR preprocessor/90382 diff --git a/gcc/testsuite/gcc.dg/gimplefe-40.c b/gcc/testsuite/gcc.dg/gimplefe-40.c new file mode 100644 index 0000000..0ad142f --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-40.c @@ -0,0 +1,15 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-fgimple -Wno-psabi -w" } */ + +typedef float v4sf __attribute__((vector_size(16))); +v4sf __GIMPLE (ssa) +load (const void * p) +{ + __int128 unsigned _3; + v4sf _4; + + __BB(2): + _3 = __MEM <__int128 unsigned, 8> ((char *)p_2(D)); + _4 = __VIEW_CONVERT <v4sf>(_3); + return _4; +} |