2018-05-17 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / fma4-builtin.c
blob2d0a886b10b34201d0da1ce69708dc3dcb03b928
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" } */
7 #ifndef __FP_FAST_FMAF
8 # error "__FP_FAST_FMAF should be defined"
9 #endif
10 #ifndef __FP_FAST_FMA
11 # error "__FP_FAST_FMA should be defined"
12 #endif
14 float
15 flt_mul_add (float a, float b, float c)
17 return __builtin_fmaf (a, b, c);
20 double
21 dbl_mul_add (double a, double b, double c)
23 return __builtin_fma (a, b, c);
26 float
27 flt_mul_sub (float a, float b, float c)
29 return __builtin_fmaf (a, b, -c);
32 double
33 dbl_mul_sub (double a, double b, double c)
35 return __builtin_fma (a, b, -c);
38 float
39 flt_neg_mul_add_1 (float a, float b, float c)
41 return __builtin_fmaf (-a, b, c);
44 double
45 dbl_neg_mul_add_1 (double a, double b, double c)
47 return __builtin_fma (-a, b, c);
50 float
51 flt_neg_mul_add_2 (float a, float b, float c)
53 return __builtin_fmaf (a, -b, c);
56 double
57 dbl_neg_mul_add_2 (double a, double b, double c)
59 return __builtin_fma (a, -b, c);
62 float
63 flt_neg_mul_sub (float a, float b, float c)
65 return __builtin_fmaf (-a, b, -c);
68 double
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 } } */