Add AMD SSE5 support; Add iterator over function arguments; Add stdarg_p, prototype_p...
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse5-msubXX.c
blob151e8c6e51f04500b09dfb30f23b3d7f5f31a5f5
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;
20 /* Note that in macc*,msub*,mnmacc* and mnsub* instructions, the intermdediate
21 product is not rounded, only the addition is rounded. */
23 static void
24 init_msubps ()
26 int i;
27 for (i = 0; i < NUM * 4; i++)
29 src1.f[i] = i;
30 src2.f[i] = i + 10;
31 src3.f[i] = i + 20;
35 static void
36 init_msubpd ()
38 int i;
39 for (i = 0; i < NUM * 4; i++)
41 src1.d[i] = i;
42 src2.d[i] = i + 10;
43 src3.d[i] = i + 20;
47 static int
48 check_msubps ()
50 int i, j, check_fails = 0;
51 for (i = 0; i < NUM * 4; i = i + 4)
52 for (j = 0; j < 4; j++)
54 res.f[i + j] = (src1.f[i + j] * src2.f[i + j]) - src3.f[i + j];
55 if (dst.f[i + j] != res.f[i + j])
56 check_fails++;
58 return check_fails++;
61 static int
62 check_msubpd ()
64 int i, j, check_fails = 0;
65 for (i = 0; i < NUM * 2; i = i + 2)
66 for (j = 0; j < 2; j++)
68 res.d[i + j] = (src1.d[i + j] * src2.d[i + j]) - src3.d[i + j];
69 if (dst.d[i + j] != res.d[i + j])
70 check_fails++;
72 return check_fails++;
76 static int
77 check_msubss ()
79 int i, j, check_fails = 0;
80 for (i = 0; i < NUM * 4; i = i + 4)
82 res.f[i] = (src1.f[i] * src2.f[i]) - src3.f[i];
83 if (dst.f[i] != res.f[i])
84 check_fails++;
86 return check_fails++;
89 static int
90 check_msubsd ()
92 int i, j, check_fails = 0;
93 for (i = 0; i < NUM * 2; i = i + 2)
95 res.d[i] = (src1.d[i] * src2.d[i]) - src3.d[i];
96 if (dst.d[i] != res.d[i])
97 check_fails++;
99 return check_fails++;
102 static void
103 sse5_test (void)
105 int i;
107 /* Check msubps */
108 init_msubps ();
110 for (i = 0; i < NUM; i++)
111 dst.x[i] = _mm_msub_ps (src1.x[i], src2.x[i], src3.x[i]);
113 if (check_msubps ())
114 abort ();
116 /* check msubss */
117 for (i = 0; i < NUM; i++)
118 dst.x[i] = _mm_msub_ss (src1.x[i], src2.x[i], src3.x[i]);
120 if (check_msubss ())
121 abort ();
123 /* Check msubpd */
124 init_msubpd ();
126 for (i = 0; i < NUM; i++)
127 dst.y[i] = _mm_msub_pd (src1.y[i], src2.y[i], src3.y[i]);
129 if (check_msubpd ())
130 abort ();
132 /* Check msubps */
133 for (i = 0; i < NUM; i++)
134 dst.y[i] = _mm_msub_sd (src1.y[i], src2.y[i], src3.y[i]);
136 if (check_msubsd ())
137 abort ();