2 /* { dg-options "-O2 -mmmx" } */
14 unsigned short int s
[4];
19 void mmx_tests (void) __attribute__((noinline
));
20 void dump64_16 (char *, char *, vecInWord
);
21 void dump64_32 (char *, char *, vecInWord
);
22 void dump64_64 (char *, char *, vecInWord
);
23 int check (const char *, const char *[]);
26 char comparison
[8000];
27 static int errors
= 0;
29 vecInWord a64
, b64
, c64
, d64
, e64
;
30 __m64 m64_16
, s64
, m64_32
, m64_64
;
32 const char *reference_mmx
[] = {
33 "_mm_srai_pi16 0012 0012 0012 0012 \n",
34 "_mm_sra_pi16 0012 0012 0012 0012 \n",
35 "_mm_srai_pi32 00123456 00123456 \n",
36 "_mm_sra_pi32 00123456 00123456 \n",
37 "_mm_srli_pi16 0012 0012 0012 0012 \n",
38 "_mm_srl_pi16 0012 0012 0012 0012 \n",
39 "_mm_srli_pi32 00123456 00123456 \n",
40 "_mm_srl_pi32 00123456 00123456 \n",
41 "_mm_srli_si64 00123456789abcde\n",
42 "_mm_srl_si64 00123456789abcde\n",
43 "_mm_slli_pi16 1230 1230 1230 1230 \n",
44 "_mm_sll_pi16 1230 1230 1230 1230 \n",
45 "_mm_slli_pi32 12345670 12345670 \n",
46 "_mm_sll_pi32 12345670 12345670 \n",
47 "_mm_slli_si64 123456789abcdef0\n",
48 "_mm_sll_si64 123456789abcdef0\n",
56 d64
.u
[0] = 0x01234567;
57 d64
.u
[1] = 0x01234567;
61 e64
.t
= 0x0123456789abcdefULL
;
80 check (buf
, reference_mmx
);
82 printf ("mmx testing:\n");
84 printf ("\ncomparison:\n");
93 void __attribute__((noinline
))
97 c64
.v
= _mm_srai_pi16 (m64_16
, SHIFT
);
98 dump64_16 (buf
, "_mm_srai_pi16", c64
);
99 c64
.v
= _mm_sra_pi16 (m64_16
, s64
);
100 dump64_16 (buf
, "_mm_sra_pi16", c64
);
103 c64
.v
= _mm_srai_pi32 (m64_32
, SHIFT
);
104 dump64_32 (buf
, "_mm_srai_pi32", c64
);
105 c64
.v
= _mm_sra_pi32 (m64_32
, s64
);
106 dump64_32 (buf
, "_mm_sra_pi32", c64
);
109 c64
.v
= _mm_srli_pi16 (m64_16
, SHIFT
);
110 dump64_16 (buf
, "_mm_srli_pi16", c64
);
111 c64
.v
= _mm_srl_pi16 (m64_16
, s64
);
112 dump64_16 (buf
, "_mm_srl_pi16", c64
);
115 c64
.v
= _mm_srli_pi32 (m64_32
, SHIFT
);
116 dump64_32 (buf
, "_mm_srli_pi32", c64
);
117 c64
.v
= _mm_srl_pi32 (m64_32
, s64
);
118 dump64_32 (buf
, "_mm_srl_pi32", c64
);
121 c64
.v
= _mm_srli_si64 (m64_64
, SHIFT
);
122 dump64_64 (buf
, "_mm_srli_si64", c64
);
123 c64
.v
= _mm_srl_si64 (m64_64
, s64
);
124 dump64_64 (buf
, "_mm_srl_si64", c64
);
127 c64
.v
= _mm_slli_pi16 (m64_16
, SHIFT
);
128 dump64_16 (buf
, "_mm_slli_pi16", c64
);
129 c64
.v
= _mm_sll_pi16 (m64_16
, s64
);
130 dump64_16 (buf
, "_mm_sll_pi16", c64
);
133 c64
.v
= _mm_slli_pi32 (m64_32
, SHIFT
);
134 dump64_32 (buf
, "_mm_slli_pi32", c64
);
135 c64
.v
= _mm_sll_pi32 (m64_32
, s64
);
136 dump64_32 (buf
, "_mm_sll_pi32", c64
);
139 c64
.v
= _mm_slli_si64 (m64_64
, SHIFT
);
140 dump64_64 (buf
, "_mm_slli_si64", c64
);
141 c64
.v
= _mm_sll_si64 (m64_64
, s64
);
142 dump64_64 (buf
, "_mm_sll_si64", c64
);
146 dump64_16 (char *buf
, char *name
, vecInWord x
)
149 char *p
= buf
+ strlen (buf
);
151 sprintf (p
, "%s ", name
);
156 sprintf (p
, "%4.4x ", x
.s
[i
]);
163 dump64_32 (char *buf
, char *name
, vecInWord x
)
166 char *p
= buf
+ strlen (buf
);
168 sprintf (p
, "%s ", name
);
173 sprintf (p
, "%8.8x ", x
.u
[i
]);
180 dump64_64 (char *buf
, char *name
, vecInWord x
)
182 char *p
= buf
+ strlen (buf
);
184 sprintf (p
, "%s ", name
);
187 #if defined(_WIN32) && !defined(__CYGWIN__)
188 sprintf (p
, "%16.16I64x\n", x
.t
);
190 sprintf (p
, "%16.16llx\n", x
.t
);
195 check (const char *input
, const char *reference
[])
197 int broken
, i
, j
, len
;
202 p_comparison
= &comparison
[0];
205 for (i
= 0; *reference
[i
] != '\0'; i
++)
208 len
= strlen (reference
[i
]);
209 for (j
= 0; j
< len
; j
++)
211 /* Ignore the terminating NUL characters at the end of every string in 'reference[]'. */
212 if (!broken
&& *p_input
!= reference
[i
][j
])
214 *p_comparison
= '\0';
215 strcat (p_comparison
, " >>> ");
216 p_comparison
+= strlen (p_comparison
);
220 *p_comparison
= *p_input
;
226 *p_comparison
= '\0';
227 strcat (p_comparison
, "expected:\n");
228 strcat (p_comparison
, reference
[i
]);
229 p_comparison
+= strlen (p_comparison
);
232 *p_comparison
= '\0';
233 strcat (p_comparison
, new_errors
? "failure\n\n" : "O.K.\n\n") ;
234 errors
+= new_errors
;