* gcc.target/i386/*.c: Remove extra braces from target selectors.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / funcspec-2.c
blobd607fbc79c91de278511c0115a303639a30f7e20
1 /* Test whether using target specific options, we can generate FMA4 code. */
2 /* { dg-do compile { target { ! ia32 } } } */
3 /* { dg-skip-if "" { *-*-* } { "-march=*" } { "-march=k8" } } */
4 /* { dg-options "-O2 -march=k8" } */
6 extern void exit (int);
8 #define FMA4_ATTR __attribute__((__target__("fma4")))
9 extern float flt_mul_add (float a, float b, float c) FMA4_ATTR;
10 extern float flt_mul_sub (float a, float b, float c) FMA4_ATTR;
11 extern float flt_neg_mul_add (float a, float b, float c) FMA4_ATTR;
12 extern float flt_neg_mul_sub (float a, float b, float c) FMA4_ATTR;
14 extern double dbl_mul_add (double a, double b, double c) FMA4_ATTR;
15 extern double dbl_mul_sub (double a, double b, double c) FMA4_ATTR;
16 extern double dbl_neg_mul_add (double a, double b, double c) FMA4_ATTR;
17 extern double dbl_neg_mul_sub (double a, double b, double c) FMA4_ATTR;
19 float
20 flt_mul_add (float a, float b, float c)
22 return (a * b) + c;
25 double
26 dbl_mul_add (double a, double b, double c)
28 return (a * b) + c;
31 float
32 flt_mul_sub (float a, float b, float c)
34 return (a * b) - c;
37 double
38 dbl_mul_sub (double a, double b, double c)
40 return (a * b) - c;
43 float
44 flt_neg_mul_add (float a, float b, float c)
46 return (-(a * b)) + c;
49 double
50 dbl_neg_mul_add (double a, double b, double c)
52 return (-(a * b)) + c;
55 float
56 flt_neg_mul_sub (float a, float b, float c)
58 return (-(a * b)) - c;
61 double
62 dbl_neg_mul_sub (double a, double b, double c)
64 return (-(a * b)) - c;
67 float f[10] = { 2, 3, 4 };
68 double d[10] = { 2, 3, 4 };
70 int main ()
72 f[3] = flt_mul_add (f[0], f[1], f[2]);
73 f[4] = flt_mul_sub (f[0], f[1], f[2]);
74 f[5] = flt_neg_mul_add (f[0], f[1], f[2]);
75 f[6] = flt_neg_mul_sub (f[0], f[1], f[2]);
77 d[3] = dbl_mul_add (d[0], d[1], d[2]);
78 d[4] = dbl_mul_sub (d[0], d[1], d[2]);
79 d[5] = dbl_neg_mul_add (d[0], d[1], d[2]);
80 d[6] = dbl_neg_mul_sub (d[0], d[1], d[2]);
81 exit (0);
84 /* { dg-final { scan-assembler "vfmaddss" } } */
85 /* { dg-final { scan-assembler "vfmaddsd" } } */
86 /* { dg-final { scan-assembler "vfmsubss" } } */
87 /* { dg-final { scan-assembler "vfmsubsd" } } */
88 /* { dg-final { scan-assembler "vfnmaddss" } } */
89 /* { dg-final { scan-assembler "vfnmaddsd" } } */
90 /* { dg-final { scan-assembler "vfnmsubss" } } */
91 /* { dg-final { scan-assembler "vfnmsubsd" } } */
92 /* { dg-final { scan-assembler "call\t(.*)flt_mul_add" } } */
93 /* { dg-final { scan-assembler "call\t(.*)flt_mul_sub" } } */
94 /* { dg-final { scan-assembler "call\t(.*)flt_neg_mul_add" } } */
95 /* { dg-final { scan-assembler "call\t(.*)flt_neg_mul_sub" } } */
96 /* { dg-final { scan-assembler "call\t(.*)dbl_mul_add" } } */
97 /* { dg-final { scan-assembler "call\t(.*)dbl_mul_sub" } } */
98 /* { dg-final { scan-assembler "call\t(.*)dbl_neg_mul_add" } } */
99 /* { dg-final { scan-assembler "call\t(.*)dbl_neg_mul_sub" } } */