gimple-pretty-print.c (dump_ternary_rhs): Adjust gimple dump format for FMA_EXPR.
authorPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Sun, 19 Feb 2017 09:06:30 +0000 (09:06 +0000)
committerPrathamesh Kulkarni <prathamesh3492@gcc.gnu.org>
Sun, 19 Feb 2017 09:06:30 +0000 (09:06 +0000)
2017-02-19  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

* 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
gcc/c/ChangeLog
gcc/c/gimple-parser.c
gcc/gimple-pretty-print.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/gimplefe-26.c [new file with mode: 0644]

index 86a4938edd1ad88beb51cc973ae2a7ae311db732..4b7bc561707c8f9c4d8383f53134b39ad8009c7c 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-19  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
+
+       * gimple-pretty-print.c (dump_ternary_rhs): Adjust gimple dump format
+       for FMA_EXPR.
+
 2017-02-18  Jakub Jelinek  <jakub@redhat.com>
 
        * final.c (last_columnnum, override_columnnum): New variables.
index 2a198ef47db344b8418b3c650ca2c3aa40ea8862..0626973d47a2d2c7a2b8dae4e0f9693c3a9885b1 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-19  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
+
+       * gimple-parser.c (c_parser_gimple_postfix_expression): Handle
+       FMA_EXPR.
+
 2017-02-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/79512
index d95987796e0ef55a5470a7615d60e364b73a7e1b..31d0a08d3035c1eba0d21fabf691d1deabb520b4 100644 (file)
@@ -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<tree> 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)
index 0033e97e80fac933933279872e692d8041721b21..a7a5d00dc2e63cbdfb7a26d3c69f385df9b243e2 100644 (file)
@@ -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:
index d67721a1ab31a5fc676267f671b4eb27a6fea191..97f392a1ac66d890e4c582371e247a02bcbb2a32 100644 (file)
@@ -1,3 +1,7 @@
+2017-02-19  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
+
+       * gcc.dg/gimplefe-26.c: New test.
+
 2017-02-18  John David Anglin  <danglin@gcc.gnu.org>
 
        * 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 (file)
index 0000000..55a4624
--- /dev/null
@@ -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" } } */