Add AMD SSE5 support; Add iterator over function arguments; Add stdarg_p, prototype_p...
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse5-maccXX.c
blob9603d53ea68c71e73413c9b18469e7a9b0b55a4e
1 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
2 /* { dg-require-effective-target sse5 } */
3 /* { dg-options "-O2 -msse5" } */
5 #include "sse5-check.h"
7 #include <bmmintrin.h>
8 #include <string.h>
10 #define NUM 20
12 union
14 __m128 x[NUM];
15 float f[NUM * 4];
16 __m128d y[NUM];
17 double d[NUM * 2];
18 } dst, res, src1, src2, src3;
21 /* Note that in macc*,msub*,mnmacc* and mnsub* instructions, the intermdediate
22 product is not rounded, only the addition is rounded. */
24 static void
25 init_maccps ()
27 int i;
28 for (i = 0; i < NUM * 4; i++)
30 src1.f[i] = i;
31 src2.f[i] = i + 10;
32 src3.f[i] = i + 20;
36 static void
37 init_maccpd ()
39 int i;
40 for (i = 0; i < NUM * 4; i++)
42 src1.d[i] = i;
43 src2.d[i] = i + 10;
44 src3.d[i] = i + 20;
48 static int
49 check_maccps ()
51 int i, j, check_fails = 0;
52 for (i = 0; i < NUM * 4; i = i + 4)
53 for (j = 0; j < 4; j++)
55 res.f[i + j] = (src1.f[i + j] * src2.f[i + j]) + src3.f[i + j];
56 if (dst.f[i + j] != res.f[i + j])
57 check_fails++;
59 return check_fails++;
62 static int
63 check_maccpd ()
65 int i, j, check_fails = 0;
66 for (i = 0; i < NUM * 2; i = i + 2)
67 for (j = 0; j < 2; j++)
69 res.d[i + j] = (src1.d[i + j] * src2.d[i + j]) + src3.d[i + j];
70 if (dst.d[i + j] != res.d[i + j])
71 check_fails++;
73 return check_fails++;
77 static int
78 check_maccss ()
80 int i, j, check_fails = 0;
81 for (i = 0; i < NUM * 4; i= i + 4)
83 res.f[i] = (src1.f[i] * src2.f[i]) + src3.f[i];
84 if (dst.f[i] != res.f[i])
85 check_fails++;
87 return check_fails++;
90 static int
91 check_maccsd ()
93 int i, j, check_fails = 0;
94 for (i = 0; i < NUM * 2; i = i + 2)
96 res.d[i] = (src1.d[i] * src2.d[i]) + src3.d[i];
97 if (dst.d[i] != res.d[i])
98 check_fails++;
100 return check_fails++;
103 static void
104 sse5_test (void)
106 int i;
108 /* Check maccps */
109 init_maccps ();
111 for (i = 0; i < NUM; i++)
112 dst.x[i] = _mm_macc_ps (src1.x[i], src2.x[i], src3.x[i]);
114 if (check_maccps ())
115 abort ();
117 /* check maccss */
118 for (i = 0; i < NUM; i++)
119 dst.x[i] = _mm_macc_ss (src1.x[i], src2.x[i], src3.x[i]);
121 if (check_maccss ())
122 abort ();
124 /* Check maccpd */
125 init_maccpd ();
127 for (i = 0; i < NUM; i++)
128 dst.y[i] = _mm_macc_pd (src1.y[i], src2.y[i], src3.y[i]);
130 if (check_maccpd ())
131 abort ();
133 /* Check maccps */
134 for (i = 0; i < NUM; i++)
135 dst.y[i] = _mm_macc_sd (src1.y[i], src2.y[i], src3.y[i]);
137 if (check_maccsd ())
138 abort ();