Debian Codegraph @

gcc/testsuite/gcc.target/powerpc/xxgenpc-runnable.c

raw
1 /* { dg-do run { target { power10_hw } } } */
2 /* { dg-do link { target { ! power10_hw } } } */
3 /* { dg-options "-mdejagnu-cpu=power10 -O2" } */
4 /* { dg-require-effective-target power10_ok } */
5
6 #include <altivec.h>
7
8 #ifdef DEBUG
9 #include <stdio.h>
10 #endif
11
12 #define IMM0 0
13 #define IMM1 1
14 #define IMM2 2
15 #define IMM3 3
16
17 void abort (void);
18
19 int main ()
20 {
21 int i;
22 vector unsigned char vec_byte_arg;
23 vector unsigned char vec_byte_result, vec_byte_expected0, vec_byte_expected1;
24 vector unsigned char vec_byte_expected2, vec_byte_expected3;
25
26 vector unsigned short vec_hword_arg;
27 vector unsigned short vec_hword_result, vec_hword_expected0;
28 vector unsigned short vec_hword_expected1, vec_hword_expected2;
29 vector unsigned short vec_hword_expected3;
30
31 vector unsigned int vec_word_arg;
32 vector unsigned int vec_word_result, vec_word_expected0, vec_word_expected1;
33 vector unsigned int vec_word_expected2, vec_word_expected3;
34
35 vec_byte_arg = (vector unsigned char ){ 0xFF, 0xF0, 0x7F, 0xFF,
36 0xFF, 0xFF, 0xFF, 0xFF,
37 0x00, 0x00, 0x01, 0x23,
38 0x45, 0x67, 0x00, 0x00 };
39
40 vec_byte_result = (vector unsigned char ){ 0xFF, 0xFF, 0xFF, 0xFF,
41 0xFF, 0xFF, 0xFF, 0xFF,
42 0xFF, 0xFF, 0xFF, 0xFF,
43 0xFF, 0xFF, 0xFF, 0xFF };
44
45 vec_byte_expected0 = (vector unsigned char){ 0x1F, 0x1E, 0x1D, 0x1C,
46 0x1B, 0x1A, 0x19, 0x18,
47 0x06, 0x05, 0x15, 0x04,
48 0x03, 0x02, 0x01, 0x00 };
49
50 vec_byte_expected1 = (vector unsigned char){ 0x00, 0x00, 0x00, 0x00,
51 0x00, 0x00, 0x00, 0x00,
52 0x00, 0x07, 0x06, 0x04,
53 0x03, 0x02, 0x01, 0x00 };
54
55 vec_byte_expected2 = (vector unsigned char){ 0x10, 0x11, 0x12, 0x13,
56 0x14, 0x15, 0x16, 0x17,
57 0x00, 0x01, 0x1a, 0x02,
58 0x03, 0x04, 0x05, 0x06 };
59
60 vec_byte_expected3 = (vector unsigned char){ 0x08, 0x09, 0x0B, 0x0C,
61 0x0D, 0x0E, 0x0F, 0x00,
62 0x00, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x00, 0x00 };
64
65 vec_hword_arg = (vector unsigned short) { 0x0004, 0xF003, 0x0002, 0x0001,
66 0xF004, 0x1003, 0xF002, 0x0001 };
67 vec_hword_expected0 = (vector unsigned short int){ 0x405, 0x1c1d, 0x203,
68 0x1819, 0x1617, 0x1,
69 0x1213, 0x1011 };
70 vec_hword_expected1 = (vector unsigned short int){ 0x0, 0x0, 0x0, 0x0,
71 0x0, 0xe0f, 0xa0b, 0x405 };
72 vec_hword_expected2 = (vector unsigned short int){ 0x100, 0x1312, 0x302,
73 0x1716, 0x1918, 0x504,
74 0x1d1c, 0x1f1e };
75 vec_hword_expected3 = (vector unsigned short int){ 0x100, 0x504, 0xb0a, 0x0,
76 0x0, 0x0, 0x0, 0x0 };
77
78 vec_word_arg = (vector unsigned int){ 0xFEDCBA90, 0xF101, 0xF0000202, 0xF303 };
79 vec_word_expected0 = (vector unsigned int){ 0x4050607, 0x18191a1b,
80 0x10203, 0x10111213 };
81 vec_word_expected1 = (vector unsigned int){ 0x0, 0x0, 0xc0d0e0f, 0x4050607 };
82 vec_word_expected2 = (vector unsigned int){ 0x3020100, 0x17161514,
83 0x7060504, 0x1f1e1d1c };
84 vec_word_expected3 = (vector unsigned int){ 0x3020100, 0xb0a0908, 0x0, 0x0 };
85
86 vec_byte_result = vec_genpcvm (vec_byte_arg, IMM0);
87
88 for (i = 0; i < 16; i++) {
89 if (vec_byte_expected0[i] != vec_byte_result[i])
90 #if DEBUG
91 printf("ERROR: vec_genpcvm(IMM = 0), vec_byte_expected[%d] = 0x%x does not match vec_byte_result[%d] = 0x%x\n",
92 i, vec_byte_expected0[i], i, vec_byte_result[i]);
93 #else
94 abort();
95 #endif
96 }
97
98 vec_byte_result = vec_genpcvm (vec_byte_arg, IMM1);
99
100 for (i = 0; i < 16; i++) {
101 if (vec_byte_expected1[i] != vec_byte_result[i])
102 #if DEBUG
103 printf("ERROR: vec_genpcvm(IMM = 1), vec_byte_expected[%d] = 0x%x does not match vec_byte_result[%d] = 0x%x\n",
104 i, vec_byte_expected1[i], i, vec_byte_result[i]);
105 #else
106 abort();
107 #endif
108 }
109
110 vec_byte_result = vec_genpcvm (vec_byte_arg, IMM2);
111
112 for (i = 0; i < 16; i++) {
113 if (vec_byte_expected2[i] != vec_byte_result[i])
114 #if DEBUG
115 printf("ERROR: vec_genpcvmbm(IMM = 2), vec_byte_expected[%d] = 0x%x does not match vec_byte_result[%d] = 0x%x\n",
116 i, vec_byte_expected2[i], i, vec_byte_result[i]);
117 #else
118 abort();
119 #endif
120 }
121
122 vec_byte_result = vec_genpcvm (vec_byte_arg, IMM3);
123
124 for (i = 0; i < 16; i++) {
125 if (vec_byte_expected3[i] != vec_byte_result[i])
126 #if DEBUG
127 printf("ERROR: vec_genpcvm(IMM = 3), vec_byte_expected[%d] = 0x%x does not match vec_byte_result[%d] = 0x%x\n",
128 i, vec_byte_expected3[i], i, vec_byte_result[i]);
129 #else
130 abort();
131 #endif
132 }
133
134 vec_hword_result = vec_genpcvm (vec_hword_arg, IMM0);
135
136 for (i = 0; i < 8; i++) {
137 if (vec_hword_expected0[i] != vec_hword_result[i])
138 #if DEBUG
139 printf("ERROR: vec_genpcvmhm(IMM = 0), vec_hword_expected[%d] = 0x%x does not match vec_hword_result[%d] = 0x%x\n",
140 i, vec_hword_expected0[i], i, vec_hword_result[i]);
141 #else
142 abort();
143 #endif
144 }
145
146 vec_hword_result = vec_genpcvm (vec_hword_arg, IMM1);
147
148 for (i = 0; i < 8; i++) {
149 if (vec_hword_expected1[i] != vec_hword_result[i])
150 #if DEBUG
151 printf("ERROR: vec_genpcvm(IMM = 1), vec_hword_expected[%d] = 0x%x does not match vec_hword_result[%d] = 0x%x\n",
152 i, vec_hword_expected1[i], i, vec_hword_result[i]);
153 #else
154 abort();
155 #endif
156 }
157
158 vec_hword_result = vec_genpcvm (vec_hword_arg, IMM2);
159
160 for (i = 0; i < 8; i++) {
161 if (vec_hword_expected2[i] != vec_hword_result[i])
162 #if DEBUG
163 printf("ERROR: vec_genpcvm(IMM = 2), vec_hword_expected[%d] = 0x%x does not match vec_hword_result[%d] = 0x%x\n",
164 i, vec_hword_expected2[i], i, vec_hword_result[i]);
165 #else
166 abort();
167 #endif
168 }
169
170 vec_hword_result = vec_genpcvm (vec_hword_arg, IMM3);
171
172 for (i = 0; i < 8; i++) {
173 if (vec_hword_expected3[i] != vec_hword_result[i])
174 #if DEBUG
175 printf("ERROR: vec_genpcvm(IMM = 3), vec_hword_expected[%d] = 0x%x does not match vec_hword_result[%d] = 0x%x\n",
176 i, vec_hword_expected3[i], i, vec_hword_result[i]);
177 #else
178 abort();
179 #endif
180 }
181
182
183 vec_word_result = vec_genpcvm (vec_word_arg, IMM0);
184
185 for (i = 0; i < 4; i++) {
186 if (vec_word_expected0[i] != vec_word_result[i])
187 #if DEBUG
188 printf("ERROR: vec_genpcvm(IMM = 0), vec_word_expected[%d] = 0x%x does not match vec_word_result[%d] = 0x%x\n",
189 i, vec_word_expected0[i], i, vec_word_result[i]);
190 #else
191 abort();
192 #endif
193 }
194
195 vec_word_result = vec_genpcvm (vec_word_arg, IMM1);
196
197 for (i = 0; i < 4; i++) {
198 if (vec_word_expected1[i] != vec_word_result[i])
199 #if DEBUG
200 printf("ERROR: vec_genpcvm(IMM = 1), vec_word_expected[%d] = 0%x does not match vec_word_result[%d] = 0x%x\n",
201 i, vec_word_expected1[i], i, vec_word_result[i]);
202 #else
203 abort();
204 #endif
205 }
206
207 vec_word_result = vec_genpcvm (vec_word_arg, IMM2);
208
209 for (i = 0; i < 4; i++) {
210 if (vec_word_expected2[i] != vec_word_result[i])
211 #if DEBUG
212 printf("ERROR: vec_genpcvm(IMM = 2), vec_word_expected[%d] = 0x%x does not match vec_word_result[%d] = 0x%x\n",
213 i, vec_word_expected2[i], i, vec_word_result[i]);
214 #else
215 abort();
216 #endif
217 }
218
219 vec_word_result = vec_genpcvm (vec_word_arg, IMM3);
220
221 for (i = 0; i < 4; i++) {
222 if (vec_word_expected3[i] != vec_word_result[i])
223 #if DEBUG
224 printf("ERROR: vec_genpcvm(IMM = 3), vec_word_expected[%d] = 0x%x does not match vec_word_result[%d] = 0x%x\n",
225 i, vec_word_expected3[i], i, vec_word_result[i]);
226 #else
227 abort();
228 #endif
229 }
230
231 return 0;
232 }