Add AMD SSE5 support; Add iterator over function arguments; Add stdarg_p, prototype_p...
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse5-fma-vector.c
blob59dc76515684f3af6d4e0678617ffbf770f35e93
1 /* Test that the compiler properly optimizes floating point multiply and add
2 instructions vector into fmaddps on SSE5 systems. */
4 /* { dg-do compile { target x86_64-*-*} } */
5 /* { dg-options "-O2 -msse5 -mfused-madd -ftree-vectorize" } */
7 extern void exit (int);
9 typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
10 typedef double __m128d __attribute__ ((__vector_size__ (16), __may_alias__));
12 #define SIZE 10240
14 union {
15 __m128 f_align;
16 __m128d d_align;
17 float f[SIZE];
18 double d[SIZE];
19 } a, b, c, d;
21 void
22 flt_mul_add (void)
24 int i;
26 for (i = 0; i < SIZE; i++)
27 a.f[i] = (b.f[i] * c.f[i]) + d.f[i];
30 void
31 dbl_mul_add (void)
33 int i;
35 for (i = 0; i < SIZE; i++)
36 a.d[i] = (b.d[i] * c.d[i]) + d.d[i];
39 void
40 flt_mul_sub (void)
42 int i;
44 for (i = 0; i < SIZE; i++)
45 a.f[i] = (b.f[i] * c.f[i]) - d.f[i];
48 void
49 dbl_mul_sub (void)
51 int i;
53 for (i = 0; i < SIZE; i++)
54 a.d[i] = (b.d[i] * c.d[i]) - d.d[i];
57 void
58 flt_neg_mul_add (void)
60 int i;
62 for (i = 0; i < SIZE; i++)
63 a.f[i] = (-(b.f[i] * c.f[i])) + d.f[i];
66 void
67 dbl_neg_mul_add (void)
69 int i;
71 for (i = 0; i < SIZE; i++)
72 a.d[i] = (-(b.d[i] * c.d[i])) + d.d[i];
75 int main ()
77 flt_mul_add ();
78 flt_mul_sub ();
79 flt_neg_mul_add ();
81 dbl_mul_add ();
82 dbl_mul_sub ();
83 dbl_neg_mul_add ();
84 exit (0);
87 /* { dg-final { scan-assembler "fmaddps" } } */
88 /* { dg-final { scan-assembler "fmaddpd" } } */
89 /* { dg-final { scan-assembler "fmsubps" } } */
90 /* { dg-final { scan-assembler "fmsubpd" } } */
91 /* { dg-final { scan-assembler "fnmaddps" } } */
92 /* { dg-final { scan-assembler "fnmaddpd" } } */