Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse5-fma-vector.c
blobec6388f5a7a8afda9bc824c87789e8f840af0140
1 /* Test that the compiler properly optimizes floating point multiply and add
2 instructions vector into fmaddps on SSE5 systems. */
4 /* { dg-do compile } */
5 /* { dg-require-effective-target lp64 } */
6 /* { dg-options "-O2 -msse5 -mfused-madd -ftree-vectorize" } */
8 extern void exit (int);
10 typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
11 typedef double __m128d __attribute__ ((__vector_size__ (16), __may_alias__));
13 #define SIZE 10240
15 union {
16 __m128 f_align;
17 __m128d d_align;
18 float f[SIZE];
19 double d[SIZE];
20 } a, b, c, d;
22 void
23 flt_mul_add (void)
25 int i;
27 for (i = 0; i < SIZE; i++)
28 a.f[i] = (b.f[i] * c.f[i]) + d.f[i];
31 void
32 dbl_mul_add (void)
34 int i;
36 for (i = 0; i < SIZE; i++)
37 a.d[i] = (b.d[i] * c.d[i]) + d.d[i];
40 void
41 flt_mul_sub (void)
43 int i;
45 for (i = 0; i < SIZE; i++)
46 a.f[i] = (b.f[i] * c.f[i]) - d.f[i];
49 void
50 dbl_mul_sub (void)
52 int i;
54 for (i = 0; i < SIZE; i++)
55 a.d[i] = (b.d[i] * c.d[i]) - d.d[i];
58 void
59 flt_neg_mul_add (void)
61 int i;
63 for (i = 0; i < SIZE; i++)
64 a.f[i] = (-(b.f[i] * c.f[i])) + d.f[i];
67 void
68 dbl_neg_mul_add (void)
70 int i;
72 for (i = 0; i < SIZE; i++)
73 a.d[i] = (-(b.d[i] * c.d[i])) + d.d[i];
76 int main ()
78 flt_mul_add ();
79 flt_mul_sub ();
80 flt_neg_mul_add ();
82 dbl_mul_add ();
83 dbl_mul_sub ();
84 dbl_neg_mul_add ();
85 exit (0);
88 /* { dg-final { scan-assembler "fmaddps" } } */
89 /* { dg-final { scan-assembler "fmaddpd" } } */
90 /* { dg-final { scan-assembler "fmsubps" } } */
91 /* { dg-final { scan-assembler "fmsubpd" } } */
92 /* { dg-final { scan-assembler "fnmaddps" } } */
93 /* { dg-final { scan-assembler "fnmaddpd" } } */