1 /* Test that the compiler properly generates floating point multiply
2 and add instructions FMA4 systems. */
4 /* { dg-do compile { target { ! ia32 } } } */
5 /* { dg-options "-O2 -mfma4 -mno-fma" } */
8 # error "__FP_FAST_FMAF should be defined"
11 # error "__FP_FAST_FMA should be defined"
15 flt_mul_add (float a
, float b
, float c
)
17 return __builtin_fmaf (a
, b
, c
);
21 dbl_mul_add (double a
, double b
, double c
)
23 return __builtin_fma (a
, b
, c
);
27 flt_mul_sub (float a
, float b
, float c
)
29 return __builtin_fmaf (a
, b
, -c
);
33 dbl_mul_sub (double a
, double b
, double c
)
35 return __builtin_fma (a
, b
, -c
);
39 flt_neg_mul_add_1 (float a
, float b
, float c
)
41 return __builtin_fmaf (-a
, b
, c
);
45 dbl_neg_mul_add_1 (double a
, double b
, double c
)
47 return __builtin_fma (-a
, b
, c
);
51 flt_neg_mul_add_2 (float a
, float b
, float c
)
53 return __builtin_fmaf (a
, -b
, c
);
57 dbl_neg_mul_add_2 (double a
, double b
, double c
)
59 return __builtin_fma (a
, -b
, c
);
63 flt_neg_mul_sub (float a
, float b
, float c
)
65 return __builtin_fmaf (-a
, b
, -c
);
69 dbl_neg_mul_sub (double a
, double b
, double c
)
71 return __builtin_fma (-a
, b
, -c
);
74 /* { dg-final { scan-assembler-times "vfmaddss" 1 } } */
75 /* { dg-final { scan-assembler-times "vfmaddsd" 1 } } */
76 /* { dg-final { scan-assembler-times "vfmsubss" 1 } } */
77 /* { dg-final { scan-assembler-times "vfmsubsd" 1 } } */
78 /* { dg-final { scan-assembler-times "vfnmaddss" 2 } } */
79 /* { dg-final { scan-assembler-times "vfnmaddsd" 2 } } */
80 /* { dg-final { scan-assembler-times "vfnmsubss" 1 } } */
81 /* { dg-final { scan-assembler-times "vfnmsubsd" 1 } } */