]>
Commit | Line | Data |
---|---|---|
ac3b8691 | 1 | /* { dg-do run } */ |
869170df | 2 | /* { dg-options "-O2 -msse" } */ |
8d67c58f UB |
3 | |
4 | #include "sse-check.h" | |
5 | ||
3977a4a1 | 6 | #include <xmmintrin.h> |
3977a4a1 | 7 | #include <string.h> |
3977a4a1 JJ |
8 | |
9 | #define SHIFT (4) | |
10 | ||
11 | typedef union { | |
12 | __m64 v; | |
13 | unsigned char c[8]; | |
14 | unsigned short int s[4]; | |
15 | unsigned long long t; | |
16 | unsigned int u[2]; | |
17 | }vecInWord; | |
18 | ||
b3172cab | 19 | void sse_tests (void) __attribute__((noinline)); |
3977a4a1 JJ |
20 | void dump64_16 (char *, char *, vecInWord); |
21 | int check (const char *, const char *[]); | |
22 | ||
23 | char buf[8000]; | |
24 | char comparison[8000]; | |
25 | static int errors = 0; | |
26 | ||
27 | vecInWord c64, e64; | |
28 | __m64 m64_64; | |
29 | ||
30 | const char *reference_sse[] = { | |
31 | "_mm_shuffle_pi16 0123 4567 89ab cdef \n", | |
32 | "" | |
33 | }; | |
34 | ||
8d67c58f UB |
35 | static void |
36 | sse_test (void) | |
3977a4a1 | 37 | { |
3977a4a1 JJ |
38 | e64.t = 0x0123456789abcdefULL; |
39 | ||
40 | m64_64 = e64.v; | |
41 | ||
8d67c58f UB |
42 | sse_tests(); |
43 | check (buf, reference_sse); | |
3977a4a1 | 44 | #ifdef DEBUG |
8d67c58f UB |
45 | printf ("sse testing:\n"); |
46 | printf (buf); | |
47 | printf ("\ncomparison:\n"); | |
48 | printf (comparison); | |
3977a4a1 | 49 | #endif |
8d67c58f | 50 | buf[0] = '\0'; |
3977a4a1 JJ |
51 | |
52 | if (errors != 0) | |
53 | abort (); | |
3977a4a1 JJ |
54 | } |
55 | ||
b3172cab | 56 | void __attribute__((noinline)) |
3977a4a1 JJ |
57 | sse_tests (void) |
58 | { | |
59 | /* pshufw */ | |
60 | c64.v = _mm_shuffle_pi16 (m64_64, 0x1b); | |
61 | dump64_16 (buf, "_mm_shuffle_pi16", c64); | |
62 | } | |
63 | ||
64 | void | |
65 | dump64_16 (char *buf, char *name, vecInWord x) | |
66 | { | |
67 | int i; | |
68 | char *p = buf + strlen (buf); | |
69 | ||
70 | sprintf (p, "%s ", name); | |
71 | p += strlen (p); | |
72 | ||
73 | for (i=0; i<4; i++) | |
74 | { | |
75 | sprintf (p, "%4.4x ", x.s[i]); | |
76 | p += strlen (p); | |
77 | } | |
78 | strcat (p, "\n"); | |
79 | } | |
80 | ||
81 | int | |
82 | check (const char *input, const char *reference[]) | |
83 | { | |
84 | int broken, i, j, len; | |
85 | const char *p_input; | |
86 | char *p_comparison; | |
87 | int new_errors = 0; | |
88 | ||
89 | p_comparison = &comparison[0]; | |
90 | p_input = input; | |
91 | ||
92 | for (i = 0; *reference[i] != '\0'; i++) | |
93 | { | |
94 | broken = 0; | |
95 | len = strlen (reference[i]); | |
96 | for (j = 0; j < len; j++) | |
97 | { | |
98 | /* Ignore the terminating NUL characters at the end of every string in 'reference[]'. */ | |
99 | if (!broken && *p_input != reference[i][j]) | |
100 | { | |
101 | *p_comparison = '\0'; | |
102 | strcat (p_comparison, " >>> "); | |
103 | p_comparison += strlen (p_comparison); | |
104 | new_errors++; | |
105 | broken = 1; | |
106 | } | |
107 | *p_comparison = *p_input; | |
108 | p_comparison++; | |
109 | p_input++; | |
110 | } | |
111 | if (broken) | |
112 | { | |
113 | *p_comparison = '\0'; | |
114 | strcat (p_comparison, "expected:\n"); | |
115 | strcat (p_comparison, reference[i]); | |
116 | p_comparison += strlen (p_comparison); | |
117 | } | |
118 | } | |
119 | *p_comparison = '\0'; | |
120 | strcat (p_comparison, new_errors ? "failure\n\n" : "O.K.\n\n") ; | |
121 | errors += new_errors; | |
122 | return 0; | |
123 | } |