1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
/* { dg-do run } */
/* { dg-require-effective-target power10_hw } */
/* { dg-options "-mdejagnu-cpu=power10" } */
#include <altivec.h>
#define DEBUG 0
#ifdef DEBUG
#include <stdio.h>
#endif
extern void abort (void);
int
main (int argc, char *argv [])
{
int i;
vector signed char vresult_char;
vector signed char expected_vresult_char;
vector signed char src_va_char;
vector signed char src_vb_char;
vector unsigned char vresult_uchar;
vector unsigned char expected_vresult_uchar;
vector unsigned char src_va_uchar;
vector unsigned char src_vb_uchar;
vector short int vresult_sh;
vector short int expected_vresult_sh;
vector short int src_va_sh;
vector short int src_vb_sh;
vector short unsigned int vresult_ush;
vector short unsigned int expected_vresult_ush;
vector short unsigned int src_va_ush;
vector short unsigned int src_vb_ush;
vector int vresult_int;
vector int expected_vresult_int;
vector int src_va_int;
vector int src_vb_int;
int src_a_int;
vector unsigned int vresult_uint;
vector unsigned int expected_vresult_uint;
vector unsigned int src_va_uint;
vector unsigned int src_vb_uint;
unsigned int src_a_uint;
vector long long int vresult_llint;
vector long long int expected_vresult_llint;
vector long long int src_va_llint;
vector long long int src_vb_llint;
long long int src_a_llint;
vector unsigned long long int vresult_ullint;
vector unsigned long long int expected_vresult_ullint;
vector unsigned long long int src_va_ullint;
vector unsigned long long int src_vb_ullint;
unsigned int long long src_a_ullint;
/* Vector shift double left */
src_va_char = (vector signed char) { 0, 2, 4, 6, 8, 10, 12, 14,
16, 18, 20, 22, 24, 26, 28, 30 };
src_vb_char = (vector signed char) { 10, 20, 30, 40, 50, 60, 70, 80, 90,
100, 110, 120, 130, 140, 150, 160 };
vresult_char = (vector signed char) { 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
expected_vresult_char = (vector signed char) { 80, 0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14 };
vresult_char = vec_sldb (src_va_char, src_vb_char, 7);
if (!vec_all_eq (vresult_char, expected_vresult_char)) {
#if DEBUG
printf("ERROR, vec_sldb (src_va_char_, src_vb_char, 7)\n");
for(i = 0; i < 16; i++)
printf(" vresult_char[%d] = %d, expected_vresult_char[%d] = %d\n",
i, vresult_char[i], i, expected_vresult_char[i]);
#else
abort();
#endif
}
src_va_uchar = (vector unsigned char) { 0, 2, 4, 6, 8, 10, 12, 14,
16, 18, 20, 22, 24, 26, 28, 30 };
src_vb_uchar = (vector unsigned char) { 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
vresult_uchar = (vector unsigned char) { 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
expected_vresult_uchar = (vector unsigned char) { 0, 0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14 };
vresult_uchar = vec_sldb (src_va_uchar, src_vb_uchar, 7);
if (!vec_all_eq (vresult_uchar, expected_vresult_uchar)) {
#if DEBUG
printf("ERROR, vec_sldb (src_va_uchar_, src_vb_uchar, 7)\n");
for(i = 0; i < 16; i++)
printf(" vresult_uchar[%d] = %d, expected_vresult_uchar[%d] = %d\n",
i, vresult_uchar[i], i, expected_vresult_uchar[i]);
#else
abort();
#endif
}
src_va_sh = (vector short int) { 0, 2, 4, 6, 8, 10, 12, 14 };
src_vb_sh = (vector short int) { 0, 0, 0, 0, 0, 0, 0, 0 };
vresult_sh = (vector short int) { 0, 0, 0, 0, 0, 0, 0, 0 };
expected_vresult_sh = (vector short int) { 0, 2*128, 4*128, 6*128,
8*128, 10*128, 12*128, 14*128 };
vresult_sh = vec_sldb (src_va_sh, src_vb_sh, 7);
if (!vec_all_eq (vresult_sh, expected_vresult_sh)) {
#if DEBUG
printf("ERROR, vec_sldb (src_va_sh_, src_vb_sh, 7)\n");
for(i = 0; i < 8; i++)
printf(" vresult_sh[%d] = %d, expected_vresult_sh[%d] = %d\n",
i, vresult_sh[i], i, expected_vresult_sh[i]);
#else
abort();
#endif
}
src_va_ush = (vector short unsigned int) { 0, 2, 4, 6, 8, 10, 12, 14 };
src_vb_ush = (vector short unsigned int) { 10, 20, 30, 40, 50, 60, 70, 80 };
vresult_ush = (vector short unsigned int) { 0, 0, 0, 0, 0, 0, 0, 0 };
expected_vresult_ush = (vector short unsigned int) { 0, 2*128, 4*128, 6*128,
8*128, 10*128, 12*128,
14*128 };
vresult_ush = vec_sldb (src_va_ush, src_vb_ush, 7);
if (!vec_all_eq (vresult_ush, expected_vresult_ush)) {
#if DEBUG
printf("ERROR, vec_sldb (src_va_ush_, src_vb_ush, 7)\n");
for(i = 0; i < 8; i++)
printf(" vresult_ush[%d] = %d, expected_vresult_ush[%d] = %d\n",
i, vresult_ush[i], i, expected_vresult_ush[i]);
#else
abort();
#endif
}
src_va_int = (vector signed int) { 0, 2, 3, 1 };
src_vb_int = (vector signed int) { 0, 0, 0, 0 };
vresult_int = (vector signed int) { 0, 0, 0, 0 };
expected_vresult_int = (vector signed int) { 0, 2*128, 3*128, 1*128 };
vresult_int = vec_sldb (src_va_int, src_vb_int, 7);
if (!vec_all_eq (vresult_int, expected_vresult_int)) {
#if DEBUG
printf("ERROR, vec_sldb (src_va_int_, src_vb_int, 7)\n");
for(i = 0; i < 4; i++)
printf(" vresult_int[%d] = %d, expected_vresult_int[%d] = %d\n",
i, vresult_int[i], i, expected_vresult_int[i]);
#else
abort();
#endif
}
src_va_uint = (vector unsigned int) { 0, 2, 4, 6 };
src_vb_uint = (vector unsigned int) { 10, 20, 30, 40 };
vresult_uint = (vector unsigned int) { 0, 0, 0, 0 };
expected_vresult_uint = (vector unsigned int) { 0, 2*128, 4*128, 6*128 };
vresult_uint = vec_sldb (src_va_uint, src_vb_uint, 7);
if (!vec_all_eq (vresult_uint, expected_vresult_uint)) {
#if DEBUG
printf("ERROR, vec_sldb (src_va_uint_, src_vb_uint, 7)\n");
for(i = 0; i < 4; i++)
printf(" vresult_uint[%d] = %d, expected_vresult_uint[%d] = %d\n",
i, vresult_uint[i], i, expected_vresult_uint[i]);
#else
abort();
#endif
}
src_va_llint = (vector signed long long int) { 5, 6 };
src_vb_llint = (vector signed long long int) { 0, 0 };
vresult_llint = (vector signed long long int) { 0, 0 };
expected_vresult_llint = (vector signed long long int) { 5*128, 6*128 };
vresult_llint = vec_sldb (src_va_llint, src_vb_llint, 7);
if (!vec_all_eq (vresult_llint, expected_vresult_llint)) {
#if DEBUG
printf("ERROR, vec_sldb (src_va_llint_, src_vb_llint, 7)\n");
for(i = 0; i < 2; i++)
printf(" vresult_llint[%d] = %d, expected_vresult_llint[%d] = %d\n",
i, vresult_llint[i], i, expected_vresult_llint[i]);
#else
abort();
#endif
}
src_va_ullint = (vector unsigned long long int) { 54, 26 };
src_vb_ullint = (vector unsigned long long int) { 10, 20 };
vresult_ullint = (vector unsigned long long int) { 0, 0 };
expected_vresult_ullint = (vector unsigned long long int) { 54*128,
26*128 };
vresult_ullint = vec_sldb (src_va_ullint, src_vb_ullint, 7);
if (!vec_all_eq (vresult_ullint, expected_vresult_ullint)) {
#if DEBUG
printf("ERROR, vec_sldb (src_va_ullint_, src_vb_ullint, 7)\n");
for(i = 0; i < 2; i++)
printf(" vresult_ullint[%d] = %d, expected_vresult_ullint[%d] = %d\n",
i, vresult_ullint[i], i, expected_vresult_ullint[i]);
#else
abort();
#endif
}
/* Vector shift double right */
src_va_char = (vector signed char) { 0, 2, 4, 6, 8, 10, 12, 14,
16, 18, 20, 22, 24, 26, 28, 30 };
src_vb_char = (vector signed char) { 10, 12, 14, 16, 18, 20, 22, 24, 26,
28, 30, 32, 34, 36, 38, 40 };
vresult_char = (vector signed char) { 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
expected_vresult_char = (vector signed char) { 24, 28, 32, 36, 40, 44, 48,
52, 56, 60, 64, 68, 72, 76,
80, 0 };
vresult_char = vec_srdb (src_va_char, src_vb_char, 7);
if (!vec_all_eq (vresult_char, expected_vresult_char)) {
#if DEBUG
printf("ERROR, vec_srdb (src_va_char_, src_vb_char, 7)\n");
for(i = 0; i < 16; i++)
printf(" vresult_char[%d] = %d, expected_vresult_char[%d] = %d\n",
i, vresult_char[i], i, expected_vresult_char[i]);
#else
abort();
#endif
}
src_va_uchar = (vector unsigned char) { 100, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
src_vb_uchar = (vector unsigned char) { 0, 2, 4, 6, 8, 10, 12, 14,
16, 18, 20, 22, 24, 26, 28, 30 };
vresult_uchar = (vector unsigned char) { 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
expected_vresult_uchar = (vector unsigned char) { 4, 8, 12, 16, 20, 24, 28,
32, 36, 40, 44, 48, 52,
56, 60, 200 };
vresult_uchar = vec_srdb (src_va_uchar, src_vb_uchar, 7);
if (!vec_all_eq (vresult_uchar, expected_vresult_uchar)) {
#if DEBUG
printf("ERROR, vec_srdb (src_va_uchar_, src_vb_uchar, 7)\n");
for(i = 0; i < 16; i++)
printf(" vresult_uchar[%d] = %d, expected_vresult_uchar[%d] = %d\n",
i, vresult_uchar[i], i, expected_vresult_uchar[i]);
#else
abort();
#endif
}
src_va_sh = (vector short int) { 0, 0, 0, 0, 0, 0, 0, 0 };
src_vb_sh = (vector short int) { 0, 2*128, 4*128, 6*128,
8*128, 10*128, 12*128, 14*128 };
vresult_sh = (vector short int) { 0, 0, 0, 0, 0, 0, 0, 0 };
expected_vresult_sh = (vector short int) { 0, 2, 4, 6, 8, 10, 12, 14 };
vresult_sh = vec_srdb (src_va_sh, src_vb_sh, 7);
if (!vec_all_eq (vresult_sh, expected_vresult_sh)) {
#if DEBUG
printf("ERROR, vec_srdb (src_va_sh_, src_vb_sh, 7)\n");
for(i = 0; i < 8; i++)
printf(" vresult_sh[%d] = %d, expected_vresult_sh[%d] = %d\n",
i, vresult_sh[i], i, expected_vresult_sh[i]);
#else
abort();
#endif
}
src_va_ush = (vector short unsigned int) { 0, 20, 30, 40, 50, 60, 70, 80 };
src_vb_ush = (vector short unsigned int) { 0, 2*128, 4*128, 6*128,
8*128, 10*128, 12*128, 14*128 };
vresult_ush = (vector short unsigned int) { 0, 0, 0, 0, 0, 0, 0, 0 };
expected_vresult_ush = (vector short unsigned int) { 0, 2, 4, 6, 8, 10,
12, 14 };
vresult_ush = vec_srdb (src_va_ush, src_vb_ush, 7);
if (!vec_all_eq (vresult_ush, expected_vresult_ush)) {
#if DEBUG
printf("ERROR, vec_srdb (src_va_ush_, src_vb_ush, 7)\n");
for(i = 0; i < 8; i++)
printf(" vresult_ush[%d] = %d, expected_vresult_ush[%d] = %d\n",
i, vresult_ush[i], i, expected_vresult_ush[i]);
#else
abort();
#endif
}
src_va_int = (vector signed int) { 0, 0, 0, 0 };
src_vb_int = (vector signed int) { 0, 2*128, 3*128, 1*128 };
vresult_int = (vector signed int) { 0, 0, 0, 0 };
expected_vresult_int = (vector signed int) { 0, 2, 3, 1 };
vresult_int = vec_srdb (src_va_int, src_vb_int, 7);
if (!vec_all_eq (vresult_int, expected_vresult_int)) {
#if DEBUG
printf("ERROR, vec_srdb (src_va_int_, src_vb_int, 7)\n");
for(i = 0; i < 4; i++)
printf(" vresult_int[%d] = %d, expected_vresult_int[%d] = %d\n",
i, vresult_int[i], i, expected_vresult_int[i]);
#else
abort();
#endif
}
src_va_uint = (vector unsigned int) { 0, 20, 30, 40 };
src_vb_uint = (vector unsigned int) { 128, 2*128, 4*128, 6*128 };
vresult_uint = (vector unsigned int) { 0, 0, 0, 0 };
expected_vresult_uint = (vector unsigned int) { 1, 2, 4, 6 };
vresult_uint = vec_srdb (src_va_uint, src_vb_uint, 7);
if (!vec_all_eq (vresult_uint, expected_vresult_uint)) {
#if DEBUG
printf("ERROR, vec_srdb (src_va_uint_, src_vb_uint, 7)\n");
for(i = 0; i < 4; i++)
printf(" vresult_uint[%d] = %d, expected_vresult_uint[%d] = %d\n",
i, vresult_uint[i], i, expected_vresult_uint[i]);
#else
abort();
#endif
}
src_va_llint = (vector signed long long int) { 0, 0 };
src_vb_llint = (vector signed long long int) { 5*128, 6*128 };
vresult_llint = (vector signed long long int) { 0, 0 };
expected_vresult_llint = (vector signed long long int) { 5, 6 };
vresult_llint = vec_srdb (src_va_llint, src_vb_llint, 7);
if (!vec_all_eq (vresult_llint, expected_vresult_llint)) {
#if DEBUG
printf("ERROR, vec_srdb (src_va_llint_, src_vb_llint, 7)\n");
for(i = 0; i < 2; i++)
printf(" vresult_llint[%d] = %d, expected_vresult_llint[%d] = %d\n",
i, vresult_llint[i], i, expected_vresult_llint[i]);
#else
abort();
#endif
}
src_va_ullint = (vector unsigned long long int) { 0, 0 };
src_vb_ullint = (vector unsigned long long int) { 54*128, 26*128 };
vresult_ullint = (vector unsigned long long int) { 0, 0 };
expected_vresult_ullint = (vector unsigned long long int) { 54, 26 };
vresult_ullint = vec_srdb (src_va_ullint, src_vb_ullint, 7);
if (!vec_all_eq (vresult_ullint, expected_vresult_ullint)) {
#if DEBUG
printf("ERROR, vec_srdb (src_va_ullint_, src_vb_ullint, 7)\n");
for(i = 0; i < 2; i++)
printf(" vresult_ullint[%d] = %d, expected_vresult_ullint[%d] = %d\n",
i, vresult_ullint[i], i, expected_vresult_ullint[i]);
#else
abort();
#endif
}
return 0;
}
/* { dg-final { scan-assembler-times {\msldbi\M} 6 } } */
/* { dg-final { scan-assembler-times {\msrdbi\M} 6 } } */
|