OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.target/] [mips/] [loongson-simd.c] - Blame information for rev 321

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 321 jeremybenn
/* Test cases for ST Microelectronics Loongson-2E/2F SIMD intrinsics.
2
   Copyright (C) 2008 Free Software Foundation, Inc.
3
   Contributed by CodeSourcery.
4
 
5
This file is part of GCC.
6
 
7
GCC is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 3, or (at your option)
10
any later version.
11
 
12
GCC is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with GCC; see the file COPYING3.  If not see
19
<http://www.gnu.org/licenses/>.  */
20
 
21
/* { dg-do run } */
22
/* loongson.h does not handle or check for MIPS16ness.  There doesn't
23
   seem any good reason for it to, given that the Loongson processors
24
   do not support MIPS16.  */
25
/* { dg-options "isa=loongson -mhard-float -mno-mips16 -flax-vector-conversions" } */
26
 
27
#include "loongson.h"
28
#include <stdio.h>
29
#include <stdint.h>
30
#include <assert.h>
31
#include <limits.h>
32
 
33
typedef union { int32x2_t v; int32_t a[2]; } int32x2_encap_t;
34
typedef union { int16x4_t v; int16_t a[4]; } int16x4_encap_t;
35
typedef union { int8x8_t v; int8_t a[8]; } int8x8_encap_t;
36
typedef union { uint32x2_t v; uint32_t a[2]; } uint32x2_encap_t;
37
typedef union { uint16x4_t v; uint16_t a[4]; } uint16x4_encap_t;
38
typedef union { uint8x8_t v; uint8_t a[8]; } uint8x8_encap_t;
39
 
40
#define UINT16x4_MAX USHRT_MAX
41
#define UINT8x8_MAX UCHAR_MAX
42
#define INT8x8_MAX SCHAR_MAX
43
#define INT16x4_MAX SHRT_MAX
44
#define INT32x2_MAX INT_MAX
45
 
46
static void test_packsswh (void)
47
{
48
  int32x2_encap_t s, t;
49
  int16x4_encap_t r;
50
  s.a[0] = INT16x4_MAX - 2;
51
  s.a[1] = INT16x4_MAX - 1;
52
  t.a[0] = INT16x4_MAX;
53
  t.a[1] = INT16x4_MAX + 1;
54
  r.v = packsswh (s.v, t.v);
55
  assert (r.a[0] == INT16x4_MAX - 2);
56
  assert (r.a[1] == INT16x4_MAX - 1);
57
  assert (r.a[2] == INT16x4_MAX);
58
  assert (r.a[3] == INT16x4_MAX);
59
}
60
 
61
static void test_packsshb (void)
62
{
63
  int16x4_encap_t s, t;
64
  int8x8_encap_t r;
65
  s.a[0] = INT8x8_MAX - 6;
66
  s.a[1] = INT8x8_MAX - 5;
67
  s.a[2] = INT8x8_MAX - 4;
68
  s.a[3] = INT8x8_MAX - 3;
69
  t.a[0] = INT8x8_MAX - 2;
70
  t.a[1] = INT8x8_MAX - 1;
71
  t.a[2] = INT8x8_MAX;
72
  t.a[3] = INT8x8_MAX + 1;
73
  r.v = packsshb (s.v, t.v);
74
  assert (r.a[0] == INT8x8_MAX - 6);
75
  assert (r.a[1] == INT8x8_MAX - 5);
76
  assert (r.a[2] == INT8x8_MAX - 4);
77
  assert (r.a[3] == INT8x8_MAX - 3);
78
  assert (r.a[4] == INT8x8_MAX - 2);
79
  assert (r.a[5] == INT8x8_MAX - 1);
80
  assert (r.a[6] == INT8x8_MAX);
81
  assert (r.a[7] == INT8x8_MAX);
82
}
83
 
84
static void test_packushb (void)
85
{
86
  uint16x4_encap_t s, t;
87
  uint8x8_encap_t r;
88
  s.a[0] = UINT8x8_MAX - 6;
89
  s.a[1] = UINT8x8_MAX - 5;
90
  s.a[2] = UINT8x8_MAX - 4;
91
  s.a[3] = UINT8x8_MAX - 3;
92
  t.a[0] = UINT8x8_MAX - 2;
93
  t.a[1] = UINT8x8_MAX - 1;
94
  t.a[2] = UINT8x8_MAX;
95
  t.a[3] = UINT8x8_MAX + 1;
96
  r.v = packushb (s.v, t.v);
97
  assert (r.a[0] == UINT8x8_MAX - 6);
98
  assert (r.a[1] == UINT8x8_MAX - 5);
99
  assert (r.a[2] == UINT8x8_MAX - 4);
100
  assert (r.a[3] == UINT8x8_MAX - 3);
101
  assert (r.a[4] == UINT8x8_MAX - 2);
102
  assert (r.a[5] == UINT8x8_MAX - 1);
103
  assert (r.a[6] == UINT8x8_MAX);
104
  assert (r.a[7] == UINT8x8_MAX);
105
}
106
 
107
static void test_paddw_u (void)
108
{
109
  uint32x2_encap_t s, t;
110
  uint32x2_encap_t r;
111
  s.a[0] = 1;
112
  s.a[1] = 2;
113
  t.a[0] = 3;
114
  t.a[1] = 4;
115
  r.v = paddw_u (s.v, t.v);
116
  assert (r.a[0] == 4);
117
  assert (r.a[1] == 6);
118
}
119
 
120
static void test_paddw_s (void)
121
{
122
  int32x2_encap_t s, t;
123
  int32x2_encap_t r;
124
  s.a[0] = -2;
125
  s.a[1] = -1;
126
  t.a[0] = 3;
127
  t.a[1] = 4;
128
  r.v = paddw_s (s.v, t.v);
129
  assert (r.a[0] == 1);
130
  assert (r.a[1] == 3);
131
}
132
 
133
static void test_paddh_u (void)
134
{
135
  uint16x4_encap_t s, t;
136
  uint16x4_encap_t r;
137
  s.a[0] = 1;
138
  s.a[1] = 2;
139
  s.a[2] = 3;
140
  s.a[3] = 4;
141
  t.a[0] = 5;
142
  t.a[1] = 6;
143
  t.a[2] = 7;
144
  t.a[3] = 8;
145
  r.v = paddh_u (s.v, t.v);
146
  assert (r.a[0] == 6);
147
  assert (r.a[1] == 8);
148
  assert (r.a[2] == 10);
149
  assert (r.a[3] == 12);
150
}
151
 
152
static void test_paddh_s (void)
153
{
154
  int16x4_encap_t s, t;
155
  int16x4_encap_t r;
156
  s.a[0] = -10;
157
  s.a[1] = -20;
158
  s.a[2] = -30;
159
  s.a[3] = -40;
160
  t.a[0] = 1;
161
  t.a[1] = 2;
162
  t.a[2] = 3;
163
  t.a[3] = 4;
164
  r.v = paddh_s (s.v, t.v);
165
  assert (r.a[0] == -9);
166
  assert (r.a[1] == -18);
167
  assert (r.a[2] == -27);
168
  assert (r.a[3] == -36);
169
}
170
 
171
static void test_paddb_u (void)
172
{
173
  uint8x8_encap_t s, t;
174
  uint8x8_encap_t r;
175
  s.a[0] = 1;
176
  s.a[1] = 2;
177
  s.a[2] = 3;
178
  s.a[3] = 4;
179
  s.a[4] = 5;
180
  s.a[5] = 6;
181
  s.a[6] = 7;
182
  s.a[7] = 8;
183
  t.a[0] = 9;
184
  t.a[1] = 10;
185
  t.a[2] = 11;
186
  t.a[3] = 12;
187
  t.a[4] = 13;
188
  t.a[5] = 14;
189
  t.a[6] = 15;
190
  t.a[7] = 16;
191
  r.v = paddb_u (s.v, t.v);
192
  assert (r.a[0] == 10);
193
  assert (r.a[1] == 12);
194
  assert (r.a[2] == 14);
195
  assert (r.a[3] == 16);
196
  assert (r.a[4] == 18);
197
  assert (r.a[5] == 20);
198
  assert (r.a[6] == 22);
199
  assert (r.a[7] == 24);
200
}
201
 
202
static void test_paddb_s (void)
203
{
204
  int8x8_encap_t s, t;
205
  int8x8_encap_t r;
206
  s.a[0] = -10;
207
  s.a[1] = -20;
208
  s.a[2] = -30;
209
  s.a[3] = -40;
210
  s.a[4] = -50;
211
  s.a[5] = -60;
212
  s.a[6] = -70;
213
  s.a[7] = -80;
214
  t.a[0] = 1;
215
  t.a[1] = 2;
216
  t.a[2] = 3;
217
  t.a[3] = 4;
218
  t.a[4] = 5;
219
  t.a[5] = 6;
220
  t.a[6] = 7;
221
  t.a[7] = 8;
222
  r.v = paddb_s (s.v, t.v);
223
  assert (r.a[0] == -9);
224
  assert (r.a[1] == -18);
225
  assert (r.a[2] == -27);
226
  assert (r.a[3] == -36);
227
  assert (r.a[4] == -45);
228
  assert (r.a[5] == -54);
229
  assert (r.a[6] == -63);
230
  assert (r.a[7] == -72);
231
}
232
 
233
static void test_paddd_u (void)
234
{
235
  uint64_t d = 123456;
236
  uint64_t e = 789012;
237
  uint64_t r;
238
  r = paddd_u (d, e);
239
  assert (r == 912468);
240
}
241
 
242
static void test_paddd_s (void)
243
{
244
  int64_t d = 123456;
245
  int64_t e = -789012;
246
  int64_t r;
247
  r = paddd_s (d, e);
248
  assert (r == -665556);
249
}
250
 
251
static void test_paddsh (void)
252
{
253
  int16x4_encap_t s, t;
254
  int16x4_encap_t r;
255
  s.a[0] = -1;
256
  s.a[1] = 0;
257
  s.a[2] = 1;
258
  s.a[3] = 2;
259
  t.a[0] = INT16x4_MAX;
260
  t.a[1] = INT16x4_MAX;
261
  t.a[2] = INT16x4_MAX;
262
  t.a[3] = INT16x4_MAX;
263
  r.v = paddsh (s.v, t.v);
264
  assert (r.a[0] == INT16x4_MAX - 1);
265
  assert (r.a[1] == INT16x4_MAX);
266
  assert (r.a[2] == INT16x4_MAX);
267
  assert (r.a[3] == INT16x4_MAX);
268
}
269
 
270
static void test_paddsb (void)
271
{
272
  int8x8_encap_t s, t;
273
  int8x8_encap_t r;
274
  s.a[0] = -6;
275
  s.a[1] = -5;
276
  s.a[2] = -4;
277
  s.a[3] = -3;
278
  s.a[4] = -2;
279
  s.a[5] = -1;
280
  s.a[6] = 0;
281
  s.a[7] = 1;
282
  t.a[0] = INT8x8_MAX;
283
  t.a[1] = INT8x8_MAX;
284
  t.a[2] = INT8x8_MAX;
285
  t.a[3] = INT8x8_MAX;
286
  t.a[4] = INT8x8_MAX;
287
  t.a[5] = INT8x8_MAX;
288
  t.a[6] = INT8x8_MAX;
289
  t.a[7] = INT8x8_MAX;
290
  r.v = paddsb (s.v, t.v);
291
  assert (r.a[0] == INT8x8_MAX - 6);
292
  assert (r.a[1] == INT8x8_MAX - 5);
293
  assert (r.a[2] == INT8x8_MAX - 4);
294
  assert (r.a[3] == INT8x8_MAX - 3);
295
  assert (r.a[4] == INT8x8_MAX - 2);
296
  assert (r.a[5] == INT8x8_MAX - 1);
297
  assert (r.a[6] == INT8x8_MAX);
298
  assert (r.a[7] == INT8x8_MAX);
299
}
300
 
301
static void test_paddush (void)
302
{
303
  uint16x4_encap_t s, t;
304
  uint16x4_encap_t r;
305
  s.a[0] = 0;
306
  s.a[1] = 1;
307
  s.a[2] = 0;
308
  s.a[3] = 1;
309
  t.a[0] = UINT16x4_MAX;
310
  t.a[1] = UINT16x4_MAX;
311
  t.a[2] = UINT16x4_MAX;
312
  t.a[3] = UINT16x4_MAX;
313
  r.v = paddush (s.v, t.v);
314
  assert (r.a[0] == UINT16x4_MAX);
315
  assert (r.a[1] == UINT16x4_MAX);
316
  assert (r.a[2] == UINT16x4_MAX);
317
  assert (r.a[3] == UINT16x4_MAX);
318
}
319
 
320
static void test_paddusb (void)
321
{
322
  uint8x8_encap_t s, t;
323
  uint8x8_encap_t r;
324
  s.a[0] = 0;
325
  s.a[1] = 1;
326
  s.a[2] = 0;
327
  s.a[3] = 1;
328
  s.a[4] = 0;
329
  s.a[5] = 1;
330
  s.a[6] = 0;
331
  s.a[7] = 1;
332
  t.a[0] = UINT8x8_MAX;
333
  t.a[1] = UINT8x8_MAX;
334
  t.a[2] = UINT8x8_MAX;
335
  t.a[3] = UINT8x8_MAX;
336
  t.a[4] = UINT8x8_MAX;
337
  t.a[5] = UINT8x8_MAX;
338
  t.a[6] = UINT8x8_MAX;
339
  t.a[7] = UINT8x8_MAX;
340
  r.v = paddusb (s.v, t.v);
341
  assert (r.a[0] == UINT8x8_MAX);
342
  assert (r.a[1] == UINT8x8_MAX);
343
  assert (r.a[2] == UINT8x8_MAX);
344
  assert (r.a[3] == UINT8x8_MAX);
345
  assert (r.a[4] == UINT8x8_MAX);
346
  assert (r.a[5] == UINT8x8_MAX);
347
  assert (r.a[6] == UINT8x8_MAX);
348
  assert (r.a[7] == UINT8x8_MAX);
349
}
350
 
351
static void test_pandn_ud (void)
352
{
353
  uint64_t d1 = 0x0000ffff0000ffffull;
354
  uint64_t d2 = 0x0000ffff0000ffffull;
355
  uint64_t r;
356
  r = pandn_ud (d1, d2);
357
  assert (r == 0);
358
}
359
 
360
static void test_pandn_sd (void)
361
{
362
  int64_t d1 = (int64_t) 0x0000000000000000ull;
363
  int64_t d2 = (int64_t) 0xfffffffffffffffeull;
364
  int64_t r;
365
  r = pandn_sd (d1, d2);
366
  assert (r == -2);
367
}
368
 
369
static void test_pandn_uw (void)
370
{
371
  uint32x2_encap_t s, t;
372
  uint32x2_encap_t r;
373
  s.a[0] = 0xffffffff;
374
  s.a[1] = 0x00000000;
375
  t.a[0] = 0x00000000;
376
  t.a[1] = 0xffffffff;
377
  r.v = pandn_uw (s.v, t.v);
378
  assert (r.a[0] == 0x00000000);
379
  assert (r.a[1] == 0xffffffff);
380
}
381
 
382
static void test_pandn_sw (void)
383
{
384
  int32x2_encap_t s, t;
385
  int32x2_encap_t r;
386
  s.a[0] = 0xffffffff;
387
  s.a[1] = 0x00000000;
388
  t.a[0] = 0xffffffff;
389
  t.a[1] = 0xfffffffe;
390
  r.v = pandn_sw (s.v, t.v);
391
  assert (r.a[0] == 0);
392
  assert (r.a[1] == -2);
393
}
394
 
395
static void test_pandn_uh (void)
396
{
397
  uint16x4_encap_t s, t;
398
  uint16x4_encap_t r;
399
  s.a[0] = 0xffff;
400
  s.a[1] = 0x0000;
401
  s.a[2] = 0xffff;
402
  s.a[3] = 0x0000;
403
  t.a[0] = 0x0000;
404
  t.a[1] = 0xffff;
405
  t.a[2] = 0x0000;
406
  t.a[3] = 0xffff;
407
  r.v = pandn_uh (s.v, t.v);
408
  assert (r.a[0] == 0x0000);
409
  assert (r.a[1] == 0xffff);
410
  assert (r.a[2] == 0x0000);
411
  assert (r.a[3] == 0xffff);
412
}
413
 
414
static void test_pandn_sh (void)
415
{
416
  int16x4_encap_t s, t;
417
  int16x4_encap_t r;
418
  s.a[0] = 0xffff;
419
  s.a[1] = 0x0000;
420
  s.a[2] = 0xffff;
421
  s.a[3] = 0x0000;
422
  t.a[0] = 0xffff;
423
  t.a[1] = 0xfffe;
424
  t.a[2] = 0xffff;
425
  t.a[3] = 0xfffe;
426
  r.v = pandn_sh (s.v, t.v);
427
  assert (r.a[0] == 0);
428
  assert (r.a[1] == -2);
429
  assert (r.a[2] == 0);
430
  assert (r.a[3] == -2);
431
}
432
 
433
static void test_pandn_ub (void)
434
{
435
  uint8x8_encap_t s, t;
436
  uint8x8_encap_t r;
437
  s.a[0] = 0xff;
438
  s.a[1] = 0x00;
439
  s.a[2] = 0xff;
440
  s.a[3] = 0x00;
441
  s.a[4] = 0xff;
442
  s.a[5] = 0x00;
443
  s.a[6] = 0xff;
444
  s.a[7] = 0x00;
445
  t.a[0] = 0x00;
446
  t.a[1] = 0xff;
447
  t.a[2] = 0x00;
448
  t.a[3] = 0xff;
449
  t.a[4] = 0x00;
450
  t.a[5] = 0xff;
451
  t.a[6] = 0x00;
452
  t.a[7] = 0xff;
453
  r.v = pandn_ub (s.v, t.v);
454
  assert (r.a[0] == 0x00);
455
  assert (r.a[1] == 0xff);
456
  assert (r.a[2] == 0x00);
457
  assert (r.a[3] == 0xff);
458
  assert (r.a[4] == 0x00);
459
  assert (r.a[5] == 0xff);
460
  assert (r.a[6] == 0x00);
461
  assert (r.a[7] == 0xff);
462
}
463
 
464
static void test_pandn_sb (void)
465
{
466
  int8x8_encap_t s, t;
467
  int8x8_encap_t r;
468
  s.a[0] = 0xff;
469
  s.a[1] = 0x00;
470
  s.a[2] = 0xff;
471
  s.a[3] = 0x00;
472
  s.a[4] = 0xff;
473
  s.a[5] = 0x00;
474
  s.a[6] = 0xff;
475
  s.a[7] = 0x00;
476
  t.a[0] = 0xff;
477
  t.a[1] = 0xfe;
478
  t.a[2] = 0xff;
479
  t.a[3] = 0xfe;
480
  t.a[4] = 0xff;
481
  t.a[5] = 0xfe;
482
  t.a[6] = 0xff;
483
  t.a[7] = 0xfe;
484
  r.v = pandn_sb (s.v, t.v);
485
  assert (r.a[0] == 0);
486
  assert (r.a[1] == -2);
487
  assert (r.a[2] == 0);
488
  assert (r.a[3] == -2);
489
  assert (r.a[4] == 0);
490
  assert (r.a[5] == -2);
491
  assert (r.a[6] == 0);
492
  assert (r.a[7] == -2);
493
}
494
 
495
static void test_pavgh (void)
496
{
497
  uint16x4_encap_t s, t;
498
  uint16x4_encap_t r;
499
  s.a[0] = 1;
500
  s.a[1] = 2;
501
  s.a[2] = 3;
502
  s.a[3] = 4;
503
  t.a[0] = 5;
504
  t.a[1] = 6;
505
  t.a[2] = 7;
506
  t.a[3] = 8;
507
  r.v = pavgh (s.v, t.v);
508
  assert (r.a[0] == 3);
509
  assert (r.a[1] == 4);
510
  assert (r.a[2] == 5);
511
  assert (r.a[3] == 6);
512
}
513
 
514
static void test_pavgb (void)
515
{
516
  uint8x8_encap_t s, t;
517
  uint8x8_encap_t r;
518
  s.a[0] = 1;
519
  s.a[1] = 2;
520
  s.a[2] = 3;
521
  s.a[3] = 4;
522
  s.a[4] = 1;
523
  s.a[5] = 2;
524
  s.a[6] = 3;
525
  s.a[7] = 4;
526
  t.a[0] = 5;
527
  t.a[1] = 6;
528
  t.a[2] = 7;
529
  t.a[3] = 8;
530
  t.a[4] = 5;
531
  t.a[5] = 6;
532
  t.a[6] = 7;
533
  t.a[7] = 8;
534
  r.v = pavgb (s.v, t.v);
535
  assert (r.a[0] == 3);
536
  assert (r.a[1] == 4);
537
  assert (r.a[2] == 5);
538
  assert (r.a[3] == 6);
539
  assert (r.a[4] == 3);
540
  assert (r.a[5] == 4);
541
  assert (r.a[6] == 5);
542
  assert (r.a[7] == 6);
543
}
544
 
545
static void test_pcmpeqw_u (void)
546
{
547
  uint32x2_encap_t s, t;
548
  uint32x2_encap_t r;
549
  s.a[0] = 42;
550
  s.a[1] = 43;
551
  t.a[0] = 43;
552
  t.a[1] = 43;
553
  r.v = pcmpeqw_u (s.v, t.v);
554
  assert (r.a[0] == 0x00000000);
555
  assert (r.a[1] == 0xffffffff);
556
}
557
 
558
static void test_pcmpeqh_u (void)
559
{
560
  uint16x4_encap_t s, t;
561
  uint16x4_encap_t r;
562
  s.a[0] = 42;
563
  s.a[1] = 43;
564
  s.a[2] = 42;
565
  s.a[3] = 43;
566
  t.a[0] = 43;
567
  t.a[1] = 43;
568
  t.a[2] = 43;
569
  t.a[3] = 43;
570
  r.v = pcmpeqh_u (s.v, t.v);
571
  assert (r.a[0] == 0x0000);
572
  assert (r.a[1] == 0xffff);
573
  assert (r.a[2] == 0x0000);
574
  assert (r.a[3] == 0xffff);
575
}
576
 
577
static void test_pcmpeqb_u (void)
578
{
579
  uint8x8_encap_t s, t;
580
  uint8x8_encap_t r;
581
  s.a[0] = 42;
582
  s.a[1] = 43;
583
  s.a[2] = 42;
584
  s.a[3] = 43;
585
  s.a[4] = 42;
586
  s.a[5] = 43;
587
  s.a[6] = 42;
588
  s.a[7] = 43;
589
  t.a[0] = 43;
590
  t.a[1] = 43;
591
  t.a[2] = 43;
592
  t.a[3] = 43;
593
  t.a[4] = 43;
594
  t.a[5] = 43;
595
  t.a[6] = 43;
596
  t.a[7] = 43;
597
  r.v = pcmpeqb_u (s.v, t.v);
598
  assert (r.a[0] == 0x00);
599
  assert (r.a[1] == 0xff);
600
  assert (r.a[2] == 0x00);
601
  assert (r.a[3] == 0xff);
602
  assert (r.a[4] == 0x00);
603
  assert (r.a[5] == 0xff);
604
  assert (r.a[6] == 0x00);
605
  assert (r.a[7] == 0xff);
606
}
607
 
608
static void test_pcmpeqw_s (void)
609
{
610
  int32x2_encap_t s, t;
611
  int32x2_encap_t r;
612
  s.a[0] = -42;
613
  s.a[1] = -42;
614
  t.a[0] = 42;
615
  t.a[1] = -42;
616
  r.v = pcmpeqw_s (s.v, t.v);
617
  assert (r.a[0] == 0);
618
  assert (r.a[1] == -1);
619
}
620
 
621
static void test_pcmpeqh_s (void)
622
{
623
  int16x4_encap_t s, t;
624
  int16x4_encap_t r;
625
  s.a[0] = -42;
626
  s.a[1] = -42;
627
  s.a[2] = -42;
628
  s.a[3] = -42;
629
  t.a[0] = 42;
630
  t.a[1] = -42;
631
  t.a[2] = 42;
632
  t.a[3] = -42;
633
  r.v = pcmpeqh_s (s.v, t.v);
634
  assert (r.a[0] == 0);
635
  assert (r.a[1] == -1);
636
  assert (r.a[2] == 0);
637
  assert (r.a[3] == -1);
638
}
639
 
640
static void test_pcmpeqb_s (void)
641
{
642
  int8x8_encap_t s, t;
643
  int8x8_encap_t r;
644
  s.a[0] = -42;
645
  s.a[1] = -42;
646
  s.a[2] = -42;
647
  s.a[3] = -42;
648
  s.a[4] = -42;
649
  s.a[5] = -42;
650
  s.a[6] = -42;
651
  s.a[7] = -42;
652
  t.a[0] = 42;
653
  t.a[1] = -42;
654
  t.a[2] = 42;
655
  t.a[3] = -42;
656
  t.a[4] = 42;
657
  t.a[5] = -42;
658
  t.a[6] = 42;
659
  t.a[7] = -42;
660
  r.v = pcmpeqb_s (s.v, t.v);
661
  assert (r.a[0] == 0);
662
  assert (r.a[1] == -1);
663
  assert (r.a[2] == 0);
664
  assert (r.a[3] == -1);
665
  assert (r.a[4] == 0);
666
  assert (r.a[5] == -1);
667
  assert (r.a[6] == 0);
668
  assert (r.a[7] == -1);
669
}
670
 
671
static void test_pcmpgtw_u (void)
672
{
673
  uint32x2_encap_t s, t;
674
  uint32x2_encap_t r;
675
  s.a[0] = 42;
676
  s.a[1] = 43;
677
  t.a[0] = 43;
678
  t.a[1] = 42;
679
  r.v = pcmpgtw_u (s.v, t.v);
680
  assert (r.a[0] == 0x00000000);
681
  assert (r.a[1] == 0xffffffff);
682
}
683
 
684
static void test_pcmpgth_u (void)
685
{
686
  uint16x4_encap_t s, t;
687
  uint16x4_encap_t r;
688
  s.a[0] = 40;
689
  s.a[1] = 41;
690
  s.a[2] = 42;
691
  s.a[3] = 43;
692
  t.a[0] = 40;
693
  t.a[1] = 41;
694
  t.a[2] = 43;
695
  t.a[3] = 42;
696
  r.v = pcmpgth_u (s.v, t.v);
697
  assert (r.a[0] == 0x0000);
698
  assert (r.a[1] == 0x0000);
699
  assert (r.a[2] == 0x0000);
700
  assert (r.a[3] == 0xffff);
701
}
702
 
703
static void test_pcmpgtb_u (void)
704
{
705
  uint8x8_encap_t s, t;
706
  uint8x8_encap_t r;
707
  s.a[0] = 40;
708
  s.a[1] = 41;
709
  s.a[2] = 42;
710
  s.a[3] = 43;
711
  s.a[4] = 44;
712
  s.a[5] = 45;
713
  s.a[6] = 46;
714
  s.a[7] = 47;
715
  t.a[0] = 48;
716
  t.a[1] = 47;
717
  t.a[2] = 46;
718
  t.a[3] = 45;
719
  t.a[4] = 44;
720
  t.a[5] = 43;
721
  t.a[6] = 42;
722
  t.a[7] = 41;
723
  r.v = pcmpgtb_u (s.v, t.v);
724
  assert (r.a[0] == 0x00);
725
  assert (r.a[1] == 0x00);
726
  assert (r.a[2] == 0x00);
727
  assert (r.a[3] == 0x00);
728
  assert (r.a[4] == 0x00);
729
  assert (r.a[5] == 0xff);
730
  assert (r.a[6] == 0xff);
731
  assert (r.a[7] == 0xff);
732
}
733
 
734
static void test_pcmpgtw_s (void)
735
{
736
  int32x2_encap_t s, t;
737
  int32x2_encap_t r;
738
  s.a[0] = 42;
739
  s.a[1] = -42;
740
  t.a[0] = -42;
741
  t.a[1] = -42;
742
  r.v = pcmpgtw_s (s.v, t.v);
743
  assert (r.a[0] == -1);
744
  assert (r.a[1] == 0);
745
}
746
 
747
static void test_pcmpgth_s (void)
748
{
749
  int16x4_encap_t s, t;
750
  int16x4_encap_t r;
751
  s.a[0] = -42;
752
  s.a[1] = -42;
753
  s.a[2] = -42;
754
  s.a[3] = -42;
755
  t.a[0] = 42;
756
  t.a[1] = 43;
757
  t.a[2] = 44;
758
  t.a[3] = -43;
759
  r.v = pcmpgth_s (s.v, t.v);
760
  assert (r.a[0] == 0);
761
  assert (r.a[1] == 0);
762
  assert (r.a[2] == 0);
763
  assert (r.a[3] == -1);
764
}
765
 
766
static void test_pcmpgtb_s (void)
767
{
768
  int8x8_encap_t s, t;
769
  int8x8_encap_t r;
770
  s.a[0] = -42;
771
  s.a[1] = -42;
772
  s.a[2] = -42;
773
  s.a[3] = -42;
774
  s.a[4] = 42;
775
  s.a[5] = 42;
776
  s.a[6] = 42;
777
  s.a[7] = 42;
778
  t.a[0] = -45;
779
  t.a[1] = -44;
780
  t.a[2] = -43;
781
  t.a[3] = -42;
782
  t.a[4] = 42;
783
  t.a[5] = 43;
784
  t.a[6] = 41;
785
  t.a[7] = 40;
786
  r.v = pcmpgtb_s (s.v, t.v);
787
  assert (r.a[0] == -1);
788
  assert (r.a[1] == -1);
789
  assert (r.a[2] == -1);
790
  assert (r.a[3] == 0);
791
  assert (r.a[4] == 0);
792
  assert (r.a[5] == 0);
793
  assert (r.a[6] == -1);
794
  assert (r.a[7] == -1);
795
}
796
 
797
static void test_pextrh_u (void)
798
{
799
  uint16x4_encap_t s;
800
  uint16x4_encap_t r;
801
  s.a[0] = 40;
802
  s.a[1] = 41;
803
  s.a[2] = 42;
804
  s.a[3] = 43;
805
  r.v = pextrh_u (s.v, 1);
806
  assert (r.a[0] == 41);
807
  assert (r.a[1] == 0);
808
  assert (r.a[2] == 0);
809
  assert (r.a[3] == 0);
810
}
811
 
812
static void test_pextrh_s (void)
813
{
814
  int16x4_encap_t s;
815
  int16x4_encap_t r;
816
  s.a[0] = -40;
817
  s.a[1] = -41;
818
  s.a[2] = -42;
819
  s.a[3] = -43;
820
  r.v = pextrh_s (s.v, 2);
821
  assert (r.a[0] == -42);
822
  assert (r.a[1] == 0);
823
  assert (r.a[2] == 0);
824
  assert (r.a[3] == 0);
825
}
826
 
827
static void test_pinsrh_0123_u (void)
828
{
829
  uint16x4_encap_t s, t;
830
  uint16x4_encap_t r;
831
  s.a[0] = 42;
832
  s.a[1] = 0;
833
  s.a[2] = 0;
834
  s.a[3] = 0;
835
  t.a[0] = 0;
836
  t.a[1] = 0;
837
  t.a[2] = 0;
838
  t.a[3] = 0;
839
  r.v = pinsrh_0_u (t.v, s.v);
840
  r.v = pinsrh_1_u (r.v, s.v);
841
  r.v = pinsrh_2_u (r.v, s.v);
842
  r.v = pinsrh_3_u (r.v, s.v);
843
  assert (r.a[0] == 42);
844
  assert (r.a[1] == 42);
845
  assert (r.a[2] == 42);
846
  assert (r.a[3] == 42);
847
}
848
 
849
static void test_pinsrh_0123_s (void)
850
{
851
  int16x4_encap_t s, t;
852
  int16x4_encap_t r;
853
  s.a[0] = -42;
854
  s.a[1] = 0;
855
  s.a[2] = 0;
856
  s.a[3] = 0;
857
  t.a[0] = 0;
858
  t.a[1] = 0;
859
  t.a[2] = 0;
860
  t.a[3] = 0;
861
  r.v = pinsrh_0_s (t.v, s.v);
862
  r.v = pinsrh_1_s (r.v, s.v);
863
  r.v = pinsrh_2_s (r.v, s.v);
864
  r.v = pinsrh_3_s (r.v, s.v);
865
  assert (r.a[0] == -42);
866
  assert (r.a[1] == -42);
867
  assert (r.a[2] == -42);
868
  assert (r.a[3] == -42);
869
}
870
 
871
static void test_pmaddhw (void)
872
{
873
  int16x4_encap_t s, t;
874
  int32x2_encap_t r;
875
  s.a[0] = -5;
876
  s.a[1] = -4;
877
  s.a[2] = -3;
878
  s.a[3] = -2;
879
  t.a[0] = 10;
880
  t.a[1] = 11;
881
  t.a[2] = 12;
882
  t.a[3] = 13;
883
  r.v = pmaddhw (s.v, t.v);
884
  assert (r.a[0] == (-5*10 + -4*11));
885
  assert (r.a[1] == (-3*12 + -2*13));
886
}
887
 
888
static void test_pmaxsh (void)
889
{
890
  int16x4_encap_t s, t;
891
  int16x4_encap_t r;
892
  s.a[0] = -20;
893
  s.a[1] = 40;
894
  s.a[2] = -10;
895
  s.a[3] = 50;
896
  t.a[0] = 20;
897
  t.a[1] = -40;
898
  t.a[2] = 10;
899
  t.a[3] = -50;
900
  r.v = pmaxsh (s.v, t.v);
901
  assert (r.a[0] == 20);
902
  assert (r.a[1] == 40);
903
  assert (r.a[2] == 10);
904
  assert (r.a[3] == 50);
905
}
906
 
907
static void test_pmaxub (void)
908
{
909
  uint8x8_encap_t s, t;
910
  uint8x8_encap_t r;
911
  s.a[0] = 10;
912
  s.a[1] = 20;
913
  s.a[2] = 30;
914
  s.a[3] = 40;
915
  s.a[4] = 50;
916
  s.a[5] = 60;
917
  s.a[6] = 70;
918
  s.a[7] = 80;
919
  t.a[0] = 80;
920
  t.a[1] = 70;
921
  t.a[2] = 60;
922
  t.a[3] = 50;
923
  t.a[4] = 40;
924
  t.a[5] = 30;
925
  t.a[6] = 20;
926
  t.a[7] = 10;
927
  r.v = pmaxub (s.v, t.v);
928
  assert (r.a[0] == 80);
929
  assert (r.a[1] == 70);
930
  assert (r.a[2] == 60);
931
  assert (r.a[3] == 50);
932
  assert (r.a[4] == 50);
933
  assert (r.a[5] == 60);
934
  assert (r.a[6] == 70);
935
  assert (r.a[7] == 80);
936
}
937
 
938
static void test_pminsh (void)
939
{
940
  int16x4_encap_t s, t;
941
  int16x4_encap_t r;
942
  s.a[0] = -20;
943
  s.a[1] = 40;
944
  s.a[2] = -10;
945
  s.a[3] = 50;
946
  t.a[0] = 20;
947
  t.a[1] = -40;
948
  t.a[2] = 10;
949
  t.a[3] = -50;
950
  r.v = pminsh (s.v, t.v);
951
  assert (r.a[0] == -20);
952
  assert (r.a[1] == -40);
953
  assert (r.a[2] == -10);
954
  assert (r.a[3] == -50);
955
}
956
 
957
static void test_pminub (void)
958
{
959
  uint8x8_encap_t s, t;
960
  uint8x8_encap_t r;
961
  s.a[0] = 10;
962
  s.a[1] = 20;
963
  s.a[2] = 30;
964
  s.a[3] = 40;
965
  s.a[4] = 50;
966
  s.a[5] = 60;
967
  s.a[6] = 70;
968
  s.a[7] = 80;
969
  t.a[0] = 80;
970
  t.a[1] = 70;
971
  t.a[2] = 60;
972
  t.a[3] = 50;
973
  t.a[4] = 40;
974
  t.a[5] = 30;
975
  t.a[6] = 20;
976
  t.a[7] = 10;
977
  r.v = pminub (s.v, t.v);
978
  assert (r.a[0] == 10);
979
  assert (r.a[1] == 20);
980
  assert (r.a[2] == 30);
981
  assert (r.a[3] == 40);
982
  assert (r.a[4] == 40);
983
  assert (r.a[5] == 30);
984
  assert (r.a[6] == 20);
985
  assert (r.a[7] == 10);
986
}
987
 
988
static void test_pmovmskb_u (void)
989
{
990
  uint8x8_encap_t s;
991
  uint8x8_encap_t r;
992
  s.a[0] = 0xf0;
993
  s.a[1] = 0x40;
994
  s.a[2] = 0xf0;
995
  s.a[3] = 0x40;
996
  s.a[4] = 0xf0;
997
  s.a[5] = 0x40;
998
  s.a[6] = 0xf0;
999
  s.a[7] = 0x40;
1000
  r.v = pmovmskb_u (s.v);
1001
  assert (r.a[0] == 0x55);
1002
  assert (r.a[1] == 0);
1003
  assert (r.a[2] == 0);
1004
  assert (r.a[3] == 0);
1005
  assert (r.a[4] == 0);
1006
  assert (r.a[5] == 0);
1007
  assert (r.a[6] == 0);
1008
  assert (r.a[7] == 0);
1009
}
1010
 
1011
static void test_pmovmskb_s (void)
1012
{
1013
  int8x8_encap_t s;
1014
  int8x8_encap_t r;
1015
  s.a[0] = -1;
1016
  s.a[1] = 1;
1017
  s.a[2] = -1;
1018
  s.a[3] = 1;
1019
  s.a[4] = -1;
1020
  s.a[5] = 1;
1021
  s.a[6] = -1;
1022
  s.a[7] = 1;
1023
  r.v = pmovmskb_s (s.v);
1024
  assert (r.a[0] == 0x55);
1025
  assert (r.a[1] == 0);
1026
  assert (r.a[2] == 0);
1027
  assert (r.a[3] == 0);
1028
  assert (r.a[4] == 0);
1029
  assert (r.a[5] == 0);
1030
  assert (r.a[6] == 0);
1031
  assert (r.a[7] == 0);
1032
}
1033
 
1034
static void test_pmulhuh (void)
1035
{
1036
  uint16x4_encap_t s, t;
1037
  uint16x4_encap_t r;
1038
  s.a[0] = 0xff00;
1039
  s.a[1] = 0xff00;
1040
  s.a[2] = 0xff00;
1041
  s.a[3] = 0xff00;
1042
  t.a[0] = 16;
1043
  t.a[1] = 16;
1044
  t.a[2] = 16;
1045
  t.a[3] = 16;
1046
  r.v = pmulhuh (s.v, t.v);
1047
  assert (r.a[0] == 0x000f);
1048
  assert (r.a[1] == 0x000f);
1049
  assert (r.a[2] == 0x000f);
1050
  assert (r.a[3] == 0x000f);
1051
}
1052
 
1053
static void test_pmulhh (void)
1054
{
1055
  int16x4_encap_t s, t;
1056
  int16x4_encap_t r;
1057
  s.a[0] = 0x0ff0;
1058
  s.a[1] = 0x0ff0;
1059
  s.a[2] = 0x0ff0;
1060
  s.a[3] = 0x0ff0;
1061
  t.a[0] = -16*16;
1062
  t.a[1] = -16*16;
1063
  t.a[2] = -16*16;
1064
  t.a[3] = -16*16;
1065
  r.v = pmulhh (s.v, t.v);
1066
  assert (r.a[0] == -16);
1067
  assert (r.a[1] == -16);
1068
  assert (r.a[2] == -16);
1069
  assert (r.a[3] == -16);
1070
}
1071
 
1072
static void test_pmullh (void)
1073
{
1074
  int16x4_encap_t s, t;
1075
  int16x4_encap_t r;
1076
  s.a[0] = 0x0ff0;
1077
  s.a[1] = 0x0ff0;
1078
  s.a[2] = 0x0ff0;
1079
  s.a[3] = 0x0ff0;
1080
  t.a[0] = -16*16;
1081
  t.a[1] = -16*16;
1082
  t.a[2] = -16*16;
1083
  t.a[3] = -16*16;
1084
  r.v = pmullh (s.v, t.v);
1085
  assert (r.a[0] == 4096);
1086
  assert (r.a[1] == 4096);
1087
  assert (r.a[2] == 4096);
1088
  assert (r.a[3] == 4096);
1089
}
1090
 
1091
static void test_pmuluw (void)
1092
{
1093
  uint32x2_encap_t s, t;
1094
  uint64_t r;
1095
  s.a[0] = 0xdeadbeef;
1096
  s.a[1] = 0;
1097
  t.a[0] = 0x0f00baaa;
1098
  t.a[1] = 0;
1099
  r = pmuluw (s.v, t.v);
1100
  assert (r == 0xd0cd08e1d1a70b6ull);
1101
}
1102
 
1103
static void test_pasubub (void)
1104
{
1105
  uint8x8_encap_t s, t;
1106
  uint8x8_encap_t r;
1107
  s.a[0] = 10;
1108
  s.a[1] = 20;
1109
  s.a[2] = 30;
1110
  s.a[3] = 40;
1111
  s.a[4] = 50;
1112
  s.a[5] = 60;
1113
  s.a[6] = 70;
1114
  s.a[7] = 80;
1115
  t.a[0] = 80;
1116
  t.a[1] = 70;
1117
  t.a[2] = 60;
1118
  t.a[3] = 50;
1119
  t.a[4] = 40;
1120
  t.a[5] = 30;
1121
  t.a[6] = 20;
1122
  t.a[7] = 10;
1123
  r.v = pasubub (s.v, t.v);
1124
  assert (r.a[0] == 70);
1125
  assert (r.a[1] == 50);
1126
  assert (r.a[2] == 30);
1127
  assert (r.a[3] == 10);
1128
  assert (r.a[4] == 10);
1129
  assert (r.a[5] == 30);
1130
  assert (r.a[6] == 50);
1131
  assert (r.a[7] == 70);
1132
}
1133
 
1134
static void test_biadd (void)
1135
{
1136
  uint8x8_encap_t s;
1137
  uint16x4_encap_t r;
1138
  s.a[0] = 10;
1139
  s.a[1] = 20;
1140
  s.a[2] = 30;
1141
  s.a[3] = 40;
1142
  s.a[4] = 50;
1143
  s.a[5] = 60;
1144
  s.a[6] = 70;
1145
  s.a[7] = 80;
1146
  r.v = biadd (s.v);
1147
  assert (r.a[0] == 360);
1148
  assert (r.a[1] == 0);
1149
  assert (r.a[2] == 0);
1150
  assert (r.a[3] == 0);
1151
}
1152
 
1153
static void test_psadbh (void)
1154
{
1155
  uint8x8_encap_t s, t;
1156
  uint16x4_encap_t r;
1157
  s.a[0] = 10;
1158
  s.a[1] = 20;
1159
  s.a[2] = 30;
1160
  s.a[3] = 40;
1161
  s.a[4] = 50;
1162
  s.a[5] = 60;
1163
  s.a[6] = 70;
1164
  s.a[7] = 80;
1165
  t.a[0] = 80;
1166
  t.a[1] = 70;
1167
  t.a[2] = 60;
1168
  t.a[3] = 50;
1169
  t.a[4] = 40;
1170
  t.a[5] = 30;
1171
  t.a[6] = 20;
1172
  t.a[7] = 10;
1173
  r.v = psadbh (s.v, t.v);
1174
  assert (r.a[0] == 0x0140);
1175
  assert (r.a[1] == 0);
1176
  assert (r.a[2] == 0);
1177
  assert (r.a[3] == 0);
1178
}
1179
 
1180
static void test_pshufh_u (void)
1181
{
1182
  uint16x4_encap_t s;
1183
  uint16x4_encap_t r;
1184
  s.a[0] = 1;
1185
  s.a[1] = 2;
1186
  s.a[2] = 3;
1187
  s.a[3] = 4;
1188
  r.a[0] = 0;
1189
  r.a[1] = 0;
1190
  r.a[2] = 0;
1191
  r.a[3] = 0;
1192
  r.v = pshufh_u (r.v, s.v, 0xe5);
1193
  assert (r.a[0] == 2);
1194
  assert (r.a[1] == 2);
1195
  assert (r.a[2] == 3);
1196
  assert (r.a[3] == 4);
1197
}
1198
 
1199
static void test_pshufh_s (void)
1200
{
1201
  int16x4_encap_t s;
1202
  int16x4_encap_t r;
1203
  s.a[0] = -1;
1204
  s.a[1] = 2;
1205
  s.a[2] = -3;
1206
  s.a[3] = 4;
1207
  r.a[0] = 0;
1208
  r.a[1] = 0;
1209
  r.a[2] = 0;
1210
  r.a[3] = 0;
1211
  r.v = pshufh_s (r.v, s.v, 0xe5);
1212
  assert (r.a[0] == 2);
1213
  assert (r.a[1] == 2);
1214
  assert (r.a[2] == -3);
1215
  assert (r.a[3] == 4);
1216
}
1217
 
1218
static void test_psllh_u (void)
1219
{
1220
  uint16x4_encap_t s;
1221
  uint16x4_encap_t r;
1222
  s.a[0] = 0xffff;
1223
  s.a[1] = 0xffff;
1224
  s.a[2] = 0xffff;
1225
  s.a[3] = 0xffff;
1226
  r.v = psllh_u (s.v, 1);
1227
  assert (r.a[0] == 0xfffe);
1228
  assert (r.a[1] == 0xfffe);
1229
  assert (r.a[2] == 0xfffe);
1230
  assert (r.a[3] == 0xfffe);
1231
}
1232
 
1233
static void test_psllw_u (void)
1234
{
1235
  uint32x2_encap_t s;
1236
  uint32x2_encap_t r;
1237
  s.a[0] = 0xffffffff;
1238
  s.a[1] = 0xffffffff;
1239
  r.v = psllw_u (s.v, 2);
1240
  assert (r.a[0] == 0xfffffffc);
1241
  assert (r.a[1] == 0xfffffffc);
1242
}
1243
 
1244
static void test_psllh_s (void)
1245
{
1246
  int16x4_encap_t s;
1247
  int16x4_encap_t r;
1248
  s.a[0] = -1;
1249
  s.a[1] = -1;
1250
  s.a[2] = -1;
1251
  s.a[3] = -1;
1252
  r.v = psllh_s (s.v, 1);
1253
  assert (r.a[0] == -2);
1254
  assert (r.a[1] == -2);
1255
  assert (r.a[2] == -2);
1256
  assert (r.a[3] == -2);
1257
}
1258
 
1259
static void test_psllw_s (void)
1260
{
1261
  int32x2_encap_t s;
1262
  int32x2_encap_t r;
1263
  s.a[0] = -1;
1264
  s.a[1] = -1;
1265
  r.v = psllw_s (s.v, 2);
1266
  assert (r.a[0] == -4);
1267
  assert (r.a[1] == -4);
1268
}
1269
 
1270
static void test_psrah_u (void)
1271
{
1272
  uint16x4_encap_t s;
1273
  uint16x4_encap_t r;
1274
  s.a[0] = 0xffef;
1275
  s.a[1] = 0xffef;
1276
  s.a[2] = 0xffef;
1277
  s.a[3] = 0xffef;
1278
  r.v = psrah_u (s.v, 1);
1279
  assert (r.a[0] == 0xfff7);
1280
  assert (r.a[1] == 0xfff7);
1281
  assert (r.a[2] == 0xfff7);
1282
  assert (r.a[3] == 0xfff7);
1283
}
1284
 
1285
static void test_psraw_u (void)
1286
{
1287
  uint32x2_encap_t s;
1288
  uint32x2_encap_t r;
1289
  s.a[0] = 0xffffffef;
1290
  s.a[1] = 0xffffffef;
1291
  r.v = psraw_u (s.v, 1);
1292
  assert (r.a[0] == 0xfffffff7);
1293
  assert (r.a[1] == 0xfffffff7);
1294
}
1295
 
1296
static void test_psrah_s (void)
1297
{
1298
  int16x4_encap_t s;
1299
  int16x4_encap_t r;
1300
  s.a[0] = -2;
1301
  s.a[1] = -2;
1302
  s.a[2] = -2;
1303
  s.a[3] = -2;
1304
  r.v = psrah_s (s.v, 1);
1305
  assert (r.a[0] == -1);
1306
  assert (r.a[1] == -1);
1307
  assert (r.a[2] == -1);
1308
  assert (r.a[3] == -1);
1309
}
1310
 
1311
static void test_psraw_s (void)
1312
{
1313
  int32x2_encap_t s;
1314
  int32x2_encap_t r;
1315
  s.a[0] = -2;
1316
  s.a[1] = -2;
1317
  r.v = psraw_s (s.v, 1);
1318
  assert (r.a[0] == -1);
1319
  assert (r.a[1] == -1);
1320
}
1321
 
1322
static void test_psrlh_u (void)
1323
{
1324
  uint16x4_encap_t s;
1325
  uint16x4_encap_t r;
1326
  s.a[0] = 0xffef;
1327
  s.a[1] = 0xffef;
1328
  s.a[2] = 0xffef;
1329
  s.a[3] = 0xffef;
1330
  r.v = psrlh_u (s.v, 1);
1331
  assert (r.a[0] == 0x7ff7);
1332
  assert (r.a[1] == 0x7ff7);
1333
  assert (r.a[2] == 0x7ff7);
1334
  assert (r.a[3] == 0x7ff7);
1335
}
1336
 
1337
static void test_psrlw_u (void)
1338
{
1339
  uint32x2_encap_t s;
1340
  uint32x2_encap_t r;
1341
  s.a[0] = 0xffffffef;
1342
  s.a[1] = 0xffffffef;
1343
  r.v = psrlw_u (s.v, 1);
1344
  assert (r.a[0] == 0x7ffffff7);
1345
  assert (r.a[1] == 0x7ffffff7);
1346
}
1347
 
1348
static void test_psrlh_s (void)
1349
{
1350
  int16x4_encap_t s;
1351
  int16x4_encap_t r;
1352
  s.a[0] = -1;
1353
  s.a[1] = -1;
1354
  s.a[2] = -1;
1355
  s.a[3] = -1;
1356
  r.v = psrlh_s (s.v, 1);
1357
  assert (r.a[0] == INT16x4_MAX);
1358
  assert (r.a[1] == INT16x4_MAX);
1359
  assert (r.a[2] == INT16x4_MAX);
1360
  assert (r.a[3] == INT16x4_MAX);
1361
}
1362
 
1363
static void test_psrlw_s (void)
1364
{
1365
  int32x2_encap_t s;
1366
  int32x2_encap_t r;
1367
  s.a[0] = -1;
1368
  s.a[1] = -1;
1369
  r.v = psrlw_s (s.v, 1);
1370
  assert (r.a[0] == INT32x2_MAX);
1371
  assert (r.a[1] == INT32x2_MAX);
1372
}
1373
 
1374
static void test_psubw_u (void)
1375
{
1376
  uint32x2_encap_t s, t;
1377
  uint32x2_encap_t r;
1378
  s.a[0] = 3;
1379
  s.a[1] = 4;
1380
  t.a[0] = 2;
1381
  t.a[1] = 1;
1382
  r.v = psubw_u (s.v, t.v);
1383
  assert (r.a[0] == 1);
1384
  assert (r.a[1] == 3);
1385
}
1386
 
1387
static void test_psubw_s (void)
1388
{
1389
  int32x2_encap_t s, t;
1390
  int32x2_encap_t r;
1391
  s.a[0] = -2;
1392
  s.a[1] = -1;
1393
  t.a[0] = 3;
1394
  t.a[1] = -4;
1395
  r.v = psubw_s (s.v, t.v);
1396
  assert (r.a[0] == -5);
1397
  assert (r.a[1] == 3);
1398
}
1399
 
1400
static void test_psubh_u (void)
1401
{
1402
  uint16x4_encap_t s, t;
1403
  uint16x4_encap_t r;
1404
  s.a[0] = 5;
1405
  s.a[1] = 6;
1406
  s.a[2] = 7;
1407
  s.a[3] = 8;
1408
  t.a[0] = 1;
1409
  t.a[1] = 2;
1410
  t.a[2] = 3;
1411
  t.a[3] = 4;
1412
  r.v = psubh_u (s.v, t.v);
1413
  assert (r.a[0] == 4);
1414
  assert (r.a[1] == 4);
1415
  assert (r.a[2] == 4);
1416
  assert (r.a[3] == 4);
1417
}
1418
 
1419
static void test_psubh_s (void)
1420
{
1421
  int16x4_encap_t s, t;
1422
  int16x4_encap_t r;
1423
  s.a[0] = -10;
1424
  s.a[1] = -20;
1425
  s.a[2] = -30;
1426
  s.a[3] = -40;
1427
  t.a[0] = 1;
1428
  t.a[1] = 2;
1429
  t.a[2] = 3;
1430
  t.a[3] = 4;
1431
  r.v = psubh_s (s.v, t.v);
1432
  assert (r.a[0] == -11);
1433
  assert (r.a[1] == -22);
1434
  assert (r.a[2] == -33);
1435
  assert (r.a[3] == -44);
1436
}
1437
 
1438
static void test_psubb_u (void)
1439
{
1440
  uint8x8_encap_t s, t;
1441
  uint8x8_encap_t r;
1442
  s.a[0] = 10;
1443
  s.a[1] = 11;
1444
  s.a[2] = 12;
1445
  s.a[3] = 13;
1446
  s.a[4] = 14;
1447
  s.a[5] = 15;
1448
  s.a[6] = 16;
1449
  s.a[7] = 17;
1450
  t.a[0] = 1;
1451
  t.a[1] = 2;
1452
  t.a[2] = 3;
1453
  t.a[3] = 4;
1454
  t.a[4] = 5;
1455
  t.a[5] = 6;
1456
  t.a[6] = 7;
1457
  t.a[7] = 8;
1458
  r.v = psubb_u (s.v, t.v);
1459
  assert (r.a[0] == 9);
1460
  assert (r.a[1] == 9);
1461
  assert (r.a[2] == 9);
1462
  assert (r.a[3] == 9);
1463
  assert (r.a[4] == 9);
1464
  assert (r.a[5] == 9);
1465
  assert (r.a[6] == 9);
1466
  assert (r.a[7] == 9);
1467
}
1468
 
1469
static void test_psubb_s (void)
1470
{
1471
  int8x8_encap_t s, t;
1472
  int8x8_encap_t r;
1473
  s.a[0] = -10;
1474
  s.a[1] = -20;
1475
  s.a[2] = -30;
1476
  s.a[3] = -40;
1477
  s.a[4] = -50;
1478
  s.a[5] = -60;
1479
  s.a[6] = -70;
1480
  s.a[7] = -80;
1481
  t.a[0] = 1;
1482
  t.a[1] = 2;
1483
  t.a[2] = 3;
1484
  t.a[3] = 4;
1485
  t.a[4] = 5;
1486
  t.a[5] = 6;
1487
  t.a[6] = 7;
1488
  t.a[7] = 8;
1489
  r.v = psubb_s (s.v, t.v);
1490
  assert (r.a[0] == -11);
1491
  assert (r.a[1] == -22);
1492
  assert (r.a[2] == -33);
1493
  assert (r.a[3] == -44);
1494
  assert (r.a[4] == -55);
1495
  assert (r.a[5] == -66);
1496
  assert (r.a[6] == -77);
1497
  assert (r.a[7] == -88);
1498
}
1499
 
1500
static void test_psubd_u (void)
1501
{
1502
  uint64_t d = 789012;
1503
  uint64_t e = 123456;
1504
  uint64_t r;
1505
  r = psubd_u (d, e);
1506
  assert (r == 665556);
1507
}
1508
 
1509
static void test_psubd_s (void)
1510
{
1511
  int64_t d = 123456;
1512
  int64_t e = -789012;
1513
  int64_t r;
1514
  r = psubd_s (d, e);
1515
  assert (r == 912468);
1516
}
1517
 
1518
static void test_psubsh (void)
1519
{
1520
  int16x4_encap_t s, t;
1521
  int16x4_encap_t r;
1522
  s.a[0] = -1;
1523
  s.a[1] = 0;
1524
  s.a[2] = 1;
1525
  s.a[3] = 2;
1526
  t.a[0] = -INT16x4_MAX;
1527
  t.a[1] = -INT16x4_MAX;
1528
  t.a[2] = -INT16x4_MAX;
1529
  t.a[3] = -INT16x4_MAX;
1530
  r.v = psubsh (s.v, t.v);
1531
  assert (r.a[0] == INT16x4_MAX - 1);
1532
  assert (r.a[1] == INT16x4_MAX);
1533
  assert (r.a[2] == INT16x4_MAX);
1534
  assert (r.a[3] == INT16x4_MAX);
1535
}
1536
 
1537
static void test_psubsb (void)
1538
{
1539
  int8x8_encap_t s, t;
1540
  int8x8_encap_t r;
1541
  s.a[0] = -6;
1542
  s.a[1] = -5;
1543
  s.a[2] = -4;
1544
  s.a[3] = -3;
1545
  s.a[4] = -2;
1546
  s.a[5] = -1;
1547
  s.a[6] = 0;
1548
  s.a[7] = 1;
1549
  t.a[0] = -INT8x8_MAX;
1550
  t.a[1] = -INT8x8_MAX;
1551
  t.a[2] = -INT8x8_MAX;
1552
  t.a[3] = -INT8x8_MAX;
1553
  t.a[4] = -INT8x8_MAX;
1554
  t.a[5] = -INT8x8_MAX;
1555
  t.a[6] = -INT8x8_MAX;
1556
  t.a[7] = -INT8x8_MAX;
1557
  r.v = psubsb (s.v, t.v);
1558
  assert (r.a[0] == INT8x8_MAX - 6);
1559
  assert (r.a[1] == INT8x8_MAX - 5);
1560
  assert (r.a[2] == INT8x8_MAX - 4);
1561
  assert (r.a[3] == INT8x8_MAX - 3);
1562
  assert (r.a[4] == INT8x8_MAX - 2);
1563
  assert (r.a[5] == INT8x8_MAX - 1);
1564
  assert (r.a[6] == INT8x8_MAX);
1565
  assert (r.a[7] == INT8x8_MAX);
1566
}
1567
 
1568
static void test_psubush (void)
1569
{
1570
  uint16x4_encap_t s, t;
1571
  uint16x4_encap_t r;
1572
  s.a[0] = 0;
1573
  s.a[1] = 1;
1574
  s.a[2] = 2;
1575
  s.a[3] = 3;
1576
  t.a[0] = 1;
1577
  t.a[1] = 1;
1578
  t.a[2] = 3;
1579
  t.a[3] = 3;
1580
  r.v = psubush (s.v, t.v);
1581
  assert (r.a[0] == 0);
1582
  assert (r.a[1] == 0);
1583
  assert (r.a[2] == 0);
1584
  assert (r.a[3] == 0);
1585
}
1586
 
1587
static void test_psubusb (void)
1588
{
1589
  uint8x8_encap_t s, t;
1590
  uint8x8_encap_t r;
1591
  s.a[0] = 0;
1592
  s.a[1] = 1;
1593
  s.a[2] = 2;
1594
  s.a[3] = 3;
1595
  s.a[4] = 4;
1596
  s.a[5] = 5;
1597
  s.a[6] = 6;
1598
  s.a[7] = 7;
1599
  t.a[0] = 1;
1600
  t.a[1] = 1;
1601
  t.a[2] = 3;
1602
  t.a[3] = 3;
1603
  t.a[4] = 5;
1604
  t.a[5] = 5;
1605
  t.a[6] = 7;
1606
  t.a[7] = 7;
1607
  r.v = psubusb (s.v, t.v);
1608
  assert (r.a[0] == 0);
1609
  assert (r.a[1] == 0);
1610
  assert (r.a[2] == 0);
1611
  assert (r.a[3] == 0);
1612
  assert (r.a[4] == 0);
1613
  assert (r.a[5] == 0);
1614
  assert (r.a[6] == 0);
1615
  assert (r.a[7] == 0);
1616
}
1617
 
1618
static void test_punpckhbh_s (void)
1619
{
1620
  int8x8_encap_t s, t;
1621
  int8x8_encap_t r;
1622
  s.a[0] = -1;
1623
  s.a[1] = -3;
1624
  s.a[2] = -5;
1625
  s.a[3] = -7;
1626
  s.a[4] = -9;
1627
  s.a[5] = -11;
1628
  s.a[6] = -13;
1629
  s.a[7] = -15;
1630
  t.a[0] = 2;
1631
  t.a[1] = 4;
1632
  t.a[2] = 6;
1633
  t.a[3] = 8;
1634
  t.a[4] = 10;
1635
  t.a[5] = 12;
1636
  t.a[6] = 14;
1637
  t.a[7] = 16;
1638
  r.v = punpckhbh_s (s.v, t.v);
1639
  assert (r.a[0] == -9);
1640
  assert (r.a[1] == 10);
1641
  assert (r.a[2] == -11);
1642
  assert (r.a[3] == 12);
1643
  assert (r.a[4] == -13);
1644
  assert (r.a[5] == 14);
1645
  assert (r.a[6] == -15);
1646
  assert (r.a[7] == 16);
1647
}
1648
 
1649
static void test_punpckhbh_u (void)
1650
{
1651
  uint8x8_encap_t s, t;
1652
  uint8x8_encap_t r;
1653
  s.a[0] = 1;
1654
  s.a[1] = 3;
1655
  s.a[2] = 5;
1656
  s.a[3] = 7;
1657
  s.a[4] = 9;
1658
  s.a[5] = 11;
1659
  s.a[6] = 13;
1660
  s.a[7] = 15;
1661
  t.a[0] = 2;
1662
  t.a[1] = 4;
1663
  t.a[2] = 6;
1664
  t.a[3] = 8;
1665
  t.a[4] = 10;
1666
  t.a[5] = 12;
1667
  t.a[6] = 14;
1668
  t.a[7] = 16;
1669
  r.v = punpckhbh_u (s.v, t.v);
1670
  assert (r.a[0] == 9);
1671
  assert (r.a[1] == 10);
1672
  assert (r.a[2] == 11);
1673
  assert (r.a[3] == 12);
1674
  assert (r.a[4] == 13);
1675
  assert (r.a[5] == 14);
1676
  assert (r.a[6] == 15);
1677
  assert (r.a[7] == 16);
1678
}
1679
 
1680
static void test_punpckhhw_s (void)
1681
{
1682
  int16x4_encap_t s, t;
1683
  int16x4_encap_t r;
1684
  s.a[0] = -1;
1685
  s.a[1] = 3;
1686
  s.a[2] = -5;
1687
  s.a[3] = 7;
1688
  t.a[0] = -2;
1689
  t.a[1] = 4;
1690
  t.a[2] = -6;
1691
  t.a[3] = 8;
1692
  r.v = punpckhhw_s (s.v, t.v);
1693
  assert (r.a[0] == -5);
1694
  assert (r.a[1] == -6);
1695
  assert (r.a[2] == 7);
1696
  assert (r.a[3] == 8);
1697
}
1698
 
1699
static void test_punpckhhw_u (void)
1700
{
1701
  uint16x4_encap_t s, t;
1702
  uint16x4_encap_t r;
1703
  s.a[0] = 1;
1704
  s.a[1] = 3;
1705
  s.a[2] = 5;
1706
  s.a[3] = 7;
1707
  t.a[0] = 2;
1708
  t.a[1] = 4;
1709
  t.a[2] = 6;
1710
  t.a[3] = 8;
1711
  r.v = punpckhhw_u (s.v, t.v);
1712
  assert (r.a[0] == 5);
1713
  assert (r.a[1] == 6);
1714
  assert (r.a[2] == 7);
1715
  assert (r.a[3] == 8);
1716
}
1717
 
1718
static void test_punpckhwd_s (void)
1719
{
1720
  int32x2_encap_t s, t;
1721
  int32x2_encap_t r;
1722
  s.a[0] = 1;
1723
  s.a[1] = 3;
1724
  t.a[0] = 2;
1725
  t.a[1] = -4;
1726
  r.v = punpckhwd_s (s.v, t.v);
1727
  assert (r.a[0] == 3);
1728
  assert (r.a[1] == -4);
1729
}
1730
 
1731
static void test_punpckhwd_u (void)
1732
{
1733
  uint32x2_encap_t s, t;
1734
  uint32x2_encap_t r;
1735
  s.a[0] = 1;
1736
  s.a[1] = 3;
1737
  t.a[0] = 2;
1738
  t.a[1] = 4;
1739
  r.v = punpckhwd_u (s.v, t.v);
1740
  assert (r.a[0] == 3);
1741
  assert (r.a[1] == 4);
1742
}
1743
 
1744
static void test_punpcklbh_s (void)
1745
{
1746
  int8x8_encap_t s, t;
1747
  int8x8_encap_t r;
1748
  s.a[0] = -1;
1749
  s.a[1] = -3;
1750
  s.a[2] = -5;
1751
  s.a[3] = -7;
1752
  s.a[4] = -9;
1753
  s.a[5] = -11;
1754
  s.a[6] = -13;
1755
  s.a[7] = -15;
1756
  t.a[0] = 2;
1757
  t.a[1] = 4;
1758
  t.a[2] = 6;
1759
  t.a[3] = 8;
1760
  t.a[4] = 10;
1761
  t.a[5] = 12;
1762
  t.a[6] = 14;
1763
  t.a[7] = 16;
1764
  r.v = punpcklbh_s (s.v, t.v);
1765
  assert (r.a[0] == -1);
1766
  assert (r.a[1] == 2);
1767
  assert (r.a[2] == -3);
1768
  assert (r.a[3] == 4);
1769
  assert (r.a[4] == -5);
1770
  assert (r.a[5] == 6);
1771
  assert (r.a[6] == -7);
1772
  assert (r.a[7] == 8);
1773
}
1774
 
1775
static void test_punpcklbh_u (void)
1776
{
1777
  uint8x8_encap_t s, t;
1778
  uint8x8_encap_t r;
1779
  s.a[0] = 1;
1780
  s.a[1] = 3;
1781
  s.a[2] = 5;
1782
  s.a[3] = 7;
1783
  s.a[4] = 9;
1784
  s.a[5] = 11;
1785
  s.a[6] = 13;
1786
  s.a[7] = 15;
1787
  t.a[0] = 2;
1788
  t.a[1] = 4;
1789
  t.a[2] = 6;
1790
  t.a[3] = 8;
1791
  t.a[4] = 10;
1792
  t.a[5] = 12;
1793
  t.a[6] = 14;
1794
  t.a[7] = 16;
1795
  r.v = punpcklbh_u (s.v, t.v);
1796
  assert (r.a[0] == 1);
1797
  assert (r.a[1] == 2);
1798
  assert (r.a[2] == 3);
1799
  assert (r.a[3] == 4);
1800
  assert (r.a[4] == 5);
1801
  assert (r.a[5] == 6);
1802
  assert (r.a[6] == 7);
1803
  assert (r.a[7] == 8);
1804
}
1805
 
1806
static void test_punpcklhw_s (void)
1807
{
1808
  int16x4_encap_t s, t;
1809
  int16x4_encap_t r;
1810
  s.a[0] = -1;
1811
  s.a[1] = 3;
1812
  s.a[2] = -5;
1813
  s.a[3] = 7;
1814
  t.a[0] = -2;
1815
  t.a[1] = 4;
1816
  t.a[2] = -6;
1817
  t.a[3] = 8;
1818
  r.v = punpcklhw_s (s.v, t.v);
1819
  assert (r.a[0] == -1);
1820
  assert (r.a[1] == -2);
1821
  assert (r.a[2] == 3);
1822
  assert (r.a[3] == 4);
1823
}
1824
 
1825
static void test_punpcklhw_u (void)
1826
{
1827
  uint16x4_encap_t s, t;
1828
  uint16x4_encap_t r;
1829
  s.a[0] = 1;
1830
  s.a[1] = 3;
1831
  s.a[2] = 5;
1832
  s.a[3] = 7;
1833
  t.a[0] = 2;
1834
  t.a[1] = 4;
1835
  t.a[2] = 6;
1836
  t.a[3] = 8;
1837
  r.v = punpcklhw_u (s.v, t.v);
1838
  assert (r.a[0] == 1);
1839
  assert (r.a[1] == 2);
1840
  assert (r.a[2] == 3);
1841
  assert (r.a[3] == 4);
1842
}
1843
 
1844
static void test_punpcklwd_s (void)
1845
{
1846
  int32x2_encap_t s, t;
1847
  int32x2_encap_t r;
1848
  s.a[0] = 1;
1849
  s.a[1] = 3;
1850
  t.a[0] = -2;
1851
  t.a[1] = 4;
1852
  r.v = punpcklwd_s (s.v, t.v);
1853
  assert (r.a[0] == 1);
1854
  assert (r.a[1] == -2);
1855
}
1856
 
1857
static void test_punpcklwd_u (void)
1858
{
1859
  uint32x2_encap_t s, t;
1860
  uint32x2_encap_t r;
1861
  s.a[0] = 1;
1862
  s.a[1] = 3;
1863
  t.a[0] = 2;
1864
  t.a[1] = 4;
1865
  r.v = punpcklwd_u (s.v, t.v);
1866
  assert (r.a[0] == 1);
1867
  assert (r.a[1] == 2);
1868
}
1869
 
1870
int main (void)
1871
{
1872
  test_packsswh ();
1873
  test_packsshb ();
1874
  test_packushb ();
1875
  test_paddw_u ();
1876
  test_paddw_s ();
1877
  test_paddh_u ();
1878
  test_paddh_s ();
1879
  test_paddb_u ();
1880
  test_paddb_s ();
1881
  test_paddd_u ();
1882
  test_paddd_s ();
1883
  test_paddsh ();
1884
  test_paddsb ();
1885
  test_paddush ();
1886
  test_paddusb ();
1887
  test_pandn_ud ();
1888
  test_pandn_sd ();
1889
  test_pandn_uw ();
1890
  test_pandn_sw ();
1891
  test_pandn_uh ();
1892
  test_pandn_sh ();
1893
  test_pandn_ub ();
1894
  test_pandn_sb ();
1895
  test_pavgh ();
1896
  test_pavgb ();
1897
  test_pcmpeqw_u ();
1898
  test_pcmpeqh_u ();
1899
  test_pcmpeqb_u ();
1900
  test_pcmpeqw_s ();
1901
  test_pcmpeqh_s ();
1902
  test_pcmpeqb_s ();
1903
  test_pcmpgtw_u ();
1904
  test_pcmpgth_u ();
1905
  test_pcmpgtb_u ();
1906
  test_pcmpgtw_s ();
1907
  test_pcmpgth_s ();
1908
  test_pcmpgtb_s ();
1909
  test_pextrh_u ();
1910
  test_pextrh_s ();
1911
  test_pinsrh_0123_u ();
1912
  test_pinsrh_0123_s ();
1913
  test_pmaddhw ();
1914
  test_pmaxsh ();
1915
  test_pmaxub ();
1916
  test_pminsh ();
1917
  test_pminub ();
1918
  test_pmovmskb_u ();
1919
  test_pmovmskb_s ();
1920
  test_pmulhuh ();
1921
  test_pmulhh ();
1922
  test_pmullh ();
1923
  test_pmuluw ();
1924
  test_pasubub ();
1925
  test_biadd ();
1926
  test_psadbh ();
1927
  test_pshufh_u ();
1928
  test_pshufh_s ();
1929
  test_psllh_u ();
1930
  test_psllw_u ();
1931
  test_psllh_s ();
1932
  test_psllw_s ();
1933
  test_psrah_u ();
1934
  test_psraw_u ();
1935
  test_psrah_s ();
1936
  test_psraw_s ();
1937
  test_psrlh_u ();
1938
  test_psrlw_u ();
1939
  test_psrlh_s ();
1940
  test_psrlw_s ();
1941
  test_psubw_u ();
1942
  test_psubw_s ();
1943
  test_psubh_u ();
1944
  test_psubh_s ();
1945
  test_psubb_u ();
1946
  test_psubb_s ();
1947
  test_psubd_u ();
1948
  test_psubd_s ();
1949
  test_psubsh ();
1950
  test_psubsb ();
1951
  test_psubush ();
1952
  test_psubusb ();
1953
  test_punpckhbh_s ();
1954
  test_punpckhbh_u ();
1955
  test_punpckhhw_s ();
1956
  test_punpckhhw_u ();
1957
  test_punpckhwd_s ();
1958
  test_punpckhwd_u ();
1959
  test_punpcklbh_s ();
1960
  test_punpcklbh_u ();
1961
  test_punpcklhw_s ();
1962
  test_punpcklhw_u ();
1963
  test_punpcklwd_s ();
1964
  test_punpcklwd_u ();
1965
  return 0;
1966
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.