1 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
2 /* { dg-options "-O2 -msse" } */
7 #include "i386-cpuid.h"
10 #define NOINLINE __attribute__ ((noinline))
18 unsigned short int s
[4];
23 void sse_tests (void) NOINLINE
;
24 void dump64_16 (char *, char *, vecInWord
);
25 int check (const char *, const char *[]);
28 char comparison
[8000];
29 static int errors
= 0;
34 const char *reference_sse
[] = {
35 "_mm_shuffle_pi16 0123 4567 89ab cdef \n",
41 unsigned long cpu_facilities
;
43 cpu_facilities
= i386_cpuid ();
45 if ((cpu_facilities
& (bit_MMX
| bit_SSE
| bit_CMOV
))
46 != (bit_MMX
| bit_SSE
| bit_CMOV
))
47 /* If host has no vector support, pass. */
50 e64
.t
= 0x0123456789abcdefULL
;
54 if (cpu_facilities
& bit_SSE
)
57 check (buf
, reference_sse
);
59 printf ("sse testing:\n");
61 printf ("\ncomparison:\n");
76 c64
.v
= _mm_shuffle_pi16 (m64_64
, 0x1b);
77 dump64_16 (buf
, "_mm_shuffle_pi16", c64
);
81 dump64_16 (char *buf
, char *name
, vecInWord x
)
84 char *p
= buf
+ strlen (buf
);
86 sprintf (p
, "%s ", name
);
91 sprintf (p
, "%4.4x ", x
.s
[i
]);
98 check (const char *input
, const char *reference
[])
100 int broken
, i
, j
, len
;
105 p_comparison
= &comparison
[0];
108 for (i
= 0; *reference
[i
] != '\0'; i
++)
111 len
= strlen (reference
[i
]);
112 for (j
= 0; j
< len
; j
++)
114 /* Ignore the terminating NUL characters at the end of every string in 'reference[]'. */
115 if (!broken
&& *p_input
!= reference
[i
][j
])
117 *p_comparison
= '\0';
118 strcat (p_comparison
, " >>> ");
119 p_comparison
+= strlen (p_comparison
);
123 *p_comparison
= *p_input
;
129 *p_comparison
= '\0';
130 strcat (p_comparison
, "expected:\n");
131 strcat (p_comparison
, reference
[i
]);
132 p_comparison
+= strlen (p_comparison
);
135 *p_comparison
= '\0';
136 strcat (p_comparison
, new_errors
? "failure\n\n" : "O.K.\n\n") ;
137 errors
+= new_errors
;