From eab1f16915926a935c4dcfce3f1026c5e80100ff Mon Sep 17 00:00:00 2001 From: Prathamesh Kulkarni Date: Sun, 19 Feb 2017 09:06:30 +0000 Subject: [PATCH] gimple-pretty-print.c (dump_ternary_rhs): Adjust gimple dump format for FMA_EXPR. 2017-02-19 Prathamesh Kulkarni * gimple-pretty-print.c (dump_ternary_rhs): Adjust gimple dump format for FMA_EXPR. c/ * gimple-parser.c (c_parser_gimple_postfix_expression): Handle FMA_EXPR. testsuite/ * gcc.dg/gimplefe-26.c: New test. From-SVN: r245570 --- gcc/ChangeLog | 5 +++++ gcc/c/ChangeLog | 5 +++++ gcc/c/gimple-parser.c | 22 ++++++++++++++++++++++ gcc/gimple-pretty-print.c | 23 ++++++++++++++++++----- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/gimplefe-26.c | 16 ++++++++++++++++ 6 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/gimplefe-26.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 86a4938edd1..4b7bc561707 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-02-19 Prathamesh Kulkarni + + * gimple-pretty-print.c (dump_ternary_rhs): Adjust gimple dump format + for FMA_EXPR. + 2017-02-18 Jakub Jelinek * final.c (last_columnnum, override_columnnum): New variables. diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 2a198ef47db..0626973d47a 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2017-02-19 Prathamesh Kulkarni + + * gimple-parser.c (c_parser_gimple_postfix_expression): Handle + FMA_EXPR. + 2017-02-16 Jakub Jelinek PR c++/79512 diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index d95987796e0..31d0a08d303 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -856,6 +856,28 @@ c_parser_gimple_postfix_expression (c_parser *parser) expr.value = fold_convert (type, val); return expr; } + else if (strcmp (IDENTIFIER_POINTER (id), "__FMA") == 0) + { + c_parser_consume_token (parser); + auto_vec args; + + if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) + { + c_parser_gimple_expr_list (parser, &args); + c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, + "expected %<)%>"); + } + if (args.length () != 3) + { + error_at (loc, "invalid number of operands to __FMA"); + expr.value = error_mark_node; + return expr; + } + expr.value = build3_loc (loc, FMA_EXPR, TREE_TYPE (args[0]), + args[0], args[1], args[2]); + return expr; + } + /* SSA name. */ unsigned version, ver_offset; if (! lookup_name (id) diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index 0033e97e80f..a7a5d00dc2e 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -453,11 +453,24 @@ dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags) break; case FMA_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); + if (flags & TDF_GIMPLE) + { + pp_string (buffer, "__FMA ("); + dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); + pp_comma (buffer); + dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); + pp_comma (buffer); + dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); + pp_right_paren (buffer); + } + else + { + 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); + } break; case DOT_PROD_EXPR: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d67721a1ab3..97f392a1ac6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-02-19 Prathamesh Kulkarni + + * gcc.dg/gimplefe-26.c: New test. + 2017-02-18 John David Anglin * g++.dg/tls/thread_local-order2.C: xfail on hppa*-*-hpux*. diff --git a/gcc/testsuite/gcc.dg/gimplefe-26.c b/gcc/testsuite/gcc.dg/gimplefe-26.c new file mode 100644 index 00000000000..55a4624b801 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-26.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-ssa-gimple" } */ + +#define foo(type, num) \ +type __GIMPLE () foo_##num (type a, type b, type c) \ +{ \ + type t0; \ + t0_1 = __FMA (a, b, c); \ + return t0_1; \ +} + +foo(float, 1) +foo(double, 2) +foo(long double, 3) + +/* { dg-final { scan-tree-dump-times "__FMA" 3 "ssa" } } */ -- 2.30.2