Index: testsuite/gcc.target/ia64/builtin-fma-1.c
===================================================================
--- testsuite/gcc.target/ia64/builtin-fma-1.c	(revision 0)
+++ testsuite/gcc.target/ia64/builtin-fma-1.c	(revision 0)
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+/* Don't confuse the fma insn with the fma in the filename.  */
+/* { dg-final { scan-assembler-times "fma\\." 2 } } */
+/* { dg-final { scan-assembler-times "fms" 4 } } */
+/* { dg-final { scan-assembler-times "fnma." 0 } } */
+
+#ifndef __FP_FAST_FMAF
+# error "__FP_FAST_FMAF should be defined"
+#endif
+#ifndef __FP_FAST_FMA
+# error "__FP_FAST_FMA should be defined"
+#endif
+
+float f0(float x, float y, float z) { return __builtin_fmaf(x,y,z); }
+float f1(float x, float y, float z) { return __builtin_fmaf(x,y,-z); }
+float f2(float x, float y, float z) { return -__builtin_fmaf(x,y,-z); }
+
+double d0(double x, double y, double z) { return __builtin_fma(x,y,z); }
+double d1(double x, double y, double z) { return __builtin_fma(x,y,-z); }
+double d2(double x, double y, double z) { return -__builtin_fma(x,y,-z); }
Index: testsuite/gcc.target/ia64/builtin-fma-2.c
===================================================================
--- testsuite/gcc.target/ia64/builtin-fma-2.c	(revision 0)
+++ testsuite/gcc.target/ia64/builtin-fma-2.c	(revision 0)
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-signed-zeros" } */
+/* Don't confuse the fma insn with the fma in the filename.  */
+/* { dg-final { scan-assembler-times "fma\\." 2 } } */
+/* { dg-final { scan-assembler-times "fms" 2 } } */
+/* { dg-final { scan-assembler-times "fnma" 2 } } */
+
+float f0(float x, float y, float z) { return __builtin_fmaf(x,y,z); }
+float f1(float x, float y, float z) { return __builtin_fmaf(x,y,-z); }
+float f2(float x, float y, float z) { return -__builtin_fmaf(x,y,-z); }
+
+double d0(double x, double y, double z) { return __builtin_fma(x,y,z); }
+double d1(double x, double y, double z) { return __builtin_fma(x,y,-z); }
+double d2(double x, double y, double z) { return -__builtin_fma(x,y,-z); }
Index: testsuite/gcc.target/ia64/builtin-fma-3.c
===================================================================
--- testsuite/gcc.target/ia64/builtin-fma-3.c	(revision 0)
+++ testsuite/gcc.target/ia64/builtin-fma-3.c	(revision 0)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-skip-if "128-bit long double" { *-*-hpux* } { "*" } { "" } } */
+/* { dg-options "-O" } */
+/* Don't confuse the fma insn with the fma in the filename.  */
+/* { dg-final { scan-assembler-times "fma\[ 	\]" 1 } } */
+/* { dg-final { scan-assembler-times "fms" 2 } } */
+/* { dg-final { scan-assembler-times "fnma" 0 } } */
+
+#ifndef __FP_FAST_FMAL
+# error "__FP_FAST_FMAL should be defined"
+#endif
+
+typedef long double LD;
+
+LD f0(LD x, LD y, LD z) { return __builtin_fmal(x,y,z); }
+LD f1(LD x, LD y, LD z) { return __builtin_fmal(x,y,-z); }
+LD f2(LD x, LD y, LD z) { return -__builtin_fmal(x,y,-z); }
Index: testsuite/gcc.target/ia64/builtin-fma-4.c
===================================================================
--- testsuite/gcc.target/ia64/builtin-fma-4.c	(revision 0)
+++ testsuite/gcc.target/ia64/builtin-fma-4.c	(revision 0)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-skip-if "128-bit long double" { *-*-hpux* } { "*" } { "" } } */
+/* { dg-options "-O -fno-signed-zeros" } */
+/* Don't confuse the fma insn with the fma in the filename.  */
+/* { dg-final { scan-assembler-times "fma\[ 	\]" 1 } } */
+/* { dg-final { scan-assembler-times "fms" 1 } } */
+/* { dg-final { scan-assembler-times "fnma" 1 } } */
+
+#ifndef __FP_FAST_FMAL
+# error "__FP_FAST_FMAL should be defined"
+#endif
+
+typedef long double LD;
+
+LD f0(LD x, LD y, LD z) { return __builtin_fmal(x,y,z); }
+LD f1(LD x, LD y, LD z) { return __builtin_fmal(x,y,-z); }
+LD f2(LD x, LD y, LD z) { return -__builtin_fmal(x,y,-z); }
Index: config/ia64/ia64.md
===================================================================
--- config/ia64/ia64.md	(revision 165650)
+++ config/ia64/ia64.md	(working copy)
@@ -2791,6 +2791,41 @@
   "TARGET_FUSED_MADD"
   "fnma.s %0 = %F1, %F2, %F3"
   [(set_attr "itanium_class" "fmac")])
+
+;; Official C99 versions of the fmaf family of operations.
+(define_insn "fmasf4"
+  [(set (match_operand:SF 0 "fr_register_operand" "=f")
+	(fma:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
+		(match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")
+		(match_operand:SF 3 "fr_reg_or_signed_fp01_operand" "fZ")))]
+  ""
+  "fma.s %0 = %F1, %F2, %F3"
+  [(set_attr "itanium_class" "fmac")])
+
+(define_insn "*fmssf4"
+  [(set (match_operand:SF 0 "fr_register_operand" "=f")
+	(fma:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
+		(match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")
+		(neg:SF
+		  (match_operand:SF 3 "fr_reg_or_signed_fp01_operand" "fZ"))))]
+  ""
+  "fms.s %0 = %F1, %F2, %F3"
+  [(set_attr "itanium_class" "fmac")])
+
+;; This insn is officially "-(a * b) + c" which is "-((a * b) - c)",
+;; except for the sign of a zero result.  E.g.
+;;	-(1 * 0) + 0 => -(0) + 0 => -0 + 0 => +0
+;;	-((1 * 0) - 0) => -(0 - 0) => -(0) => -0
+(define_insn "*nfmssf4"
+  [(set (match_operand:SF 0 "fr_register_operand" "=f")
+	(neg:SF
+	 (fma:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
+		 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")
+		 (neg:SF
+		  (match_operand:SF 3 "fr_reg_or_signed_fp01_operand" "fZ")))))]
+  "!flag_signed_zeros"
+  "fnma.s %0 = %F1, %F2, %F3"
+  [(set_attr "itanium_class" "fmac")])
 
 ;; ::::::::::::::::::::
 ;; ::
@@ -2977,6 +3012,38 @@
   "TARGET_FUSED_MADD"
   "fnma.s %0 = %F1, %F2, %F3"
   [(set_attr "itanium_class" "fmac")])
+
+;; Official C99 versions of the fma family of operations.
+(define_insn "fmadf4"
+  [(set (match_operand:DF 0 "fr_register_operand" "=f")
+	(fma:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
+		(match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")
+		(match_operand:DF 3 "fr_reg_or_signed_fp01_operand" "fZ")))]
+  ""
+  "fma.d %0 = %F1, %F2, %F3"
+  [(set_attr "itanium_class" "fmac")])
+
+(define_insn "*fmsdf4"
+  [(set (match_operand:DF 0 "fr_register_operand" "=f")
+	(fma:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
+		(match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")
+		(neg:DF
+		  (match_operand:DF 3 "fr_reg_or_signed_fp01_operand" "fZ"))))]
+  ""
+  "fms.d %0 = %F1, %F2, %F3"
+  [(set_attr "itanium_class" "fmac")])
+
+;; See comment for nfmssf4.
+(define_insn "*nfmsdf4"
+  [(set (match_operand:DF 0 "fr_register_operand" "=f")
+	(neg:DF
+	 (fma:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
+		 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")
+		 (neg:DF
+		  (match_operand:DF 3 "fr_reg_or_signed_fp01_operand" "fZ")))))]
+  "!flag_signed_zeros"
+  "fnma.d %0 = %F1, %F2, %F3"
+  [(set_attr "itanium_class" "fmac")])
 
 ;; ::::::::::::::::::::
 ;; ::
@@ -3234,6 +3301,38 @@
   "TARGET_FUSED_MADD"
   "fnma.d %0 = %F1, %F2, %F3"
   [(set_attr "itanium_class" "fmac")])
+
+;; Official C99 versions of the fmal family of operations.
+(define_insn "fmaxf4"
+  [(set (match_operand:XF 0 "fr_register_operand" "=f")
+	(fma:XF (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
+		(match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")
+		(match_operand:XF 3 "fr_reg_or_signed_fp01_operand" "fZ")))]
+  ""
+  "fma %0 = %F1, %F2, %F3"
+  [(set_attr "itanium_class" "fmac")])
+
+(define_insn "*fmsxf4"
+  [(set (match_operand:XF 0 "fr_register_operand" "=f")
+	(fma:XF (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
+		(match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")
+		(neg:XF
+		  (match_operand:XF 3 "fr_reg_or_signed_fp01_operand" "fZ"))))]
+  ""
+  "fms %0 = %F1, %F2, %F3"
+  [(set_attr "itanium_class" "fmac")])
+
+;; See comment for nfmssf4.
+(define_insn "*nfmsxf4"
+  [(set (match_operand:XF 0 "fr_register_operand" "=f")
+	(neg:XF
+	 (fma:XF (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
+		 (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")
+		 (neg:XF
+		  (match_operand:XF 3 "fr_reg_or_signed_fp01_operand" "fZ")))))]
+  "!flag_signed_zeros"
+  "fnma %0 = %F1, %F2, %F3"
+  [(set_attr "itanium_class" "fmac")])
 
 ;; ::::::::::::::::::::
 ;; ::
