1 /* Test cases for ST Microelectronics Loongson-2E/2F SIMD intrinsics.
2 Copyright (C) 2008 Free Software Foundation, Inc.
3 Contributed by CodeSourcery.
5 This file is part of GCC.
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)
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.
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/>. */
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" } */
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
;
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
46 static void test_packsswh (void)
50 s
.a
[0] = INT16x4_MAX
- 2;
51 s
.a
[1] = INT16x4_MAX
- 1;
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
);
61 static void test_packsshb (void)
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;
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
);
84 static void test_packushb (void)
86 uint16x4_encap_t s
, t
;
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;
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
);
107 static void test_paddw_u (void)
109 uint32x2_encap_t s
, t
;
115 r
.v
= paddw_u (s
.v
, t
.v
);
116 assert (r
.a
[0] == 4);
117 assert (r
.a
[1] == 6);
120 static void test_paddw_s (void)
122 int32x2_encap_t s
, t
;
128 r
.v
= paddw_s (s
.v
, t
.v
);
129 assert (r
.a
[0] == 1);
130 assert (r
.a
[1] == 3);
133 static void test_paddh_u (void)
135 uint16x4_encap_t s
, t
;
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);
152 static void test_paddh_s (void)
154 int16x4_encap_t s
, t
;
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);
171 static void test_paddb_u (void)
173 uint8x8_encap_t s
, t
;
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);
202 static void test_paddb_s (void)
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);
233 static void test_paddd_u (void)
239 assert (r
== 912468);
242 static void test_paddd_s (void)
248 assert (r
== -665556);
251 static void test_paddsh (void)
253 int16x4_encap_t s
, t
;
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
);
270 static void test_paddsb (void)
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
);
301 static void test_paddush (void)
303 uint16x4_encap_t s
, t
;
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
);
320 static void test_paddusb (void)
322 uint8x8_encap_t s
, t
;
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
);
351 static void test_pandn_ud (void)
353 uint64_t d1
= 0x0000ffff0000ffffull
;
354 uint64_t d2
= 0x0000ffff0000ffffull
;
356 r
= pandn_ud (d1
, d2
);
360 static void test_pandn_sd (void)
362 int64_t d1
= (int64_t) 0x0000000000000000ull
;
363 int64_t d2
= (int64_t) 0xfffffffffffffffeull
;
365 r
= pandn_sd (d1
, d2
);
369 static void test_pandn_uw (void)
371 uint32x2_encap_t s
, t
;
377 r
.v
= pandn_uw (s
.v
, t
.v
);
378 assert (r
.a
[0] == 0x00000000);
379 assert (r
.a
[1] == 0xffffffff);
382 static void test_pandn_sw (void)
384 int32x2_encap_t s
, t
;
390 r
.v
= pandn_sw (s
.v
, t
.v
);
391 assert (r
.a
[0] == 0);
392 assert (r
.a
[1] == -2);
395 static void test_pandn_uh (void)
397 uint16x4_encap_t s
, t
;
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);
414 static void test_pandn_sh (void)
416 int16x4_encap_t s
, t
;
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);
433 static void test_pandn_ub (void)
435 uint8x8_encap_t s
, t
;
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);
464 static void test_pandn_sb (void)
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);
495 static void test_pavgh (void)
497 uint16x4_encap_t s
, t
;
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);
514 static void test_pavgb (void)
516 uint8x8_encap_t s
, t
;
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);
545 static void test_pcmpeqw_u (void)
547 uint32x2_encap_t s
, t
;
553 r
.v
= pcmpeqw_u (s
.v
, t
.v
);
554 assert (r
.a
[0] == 0x00000000);
555 assert (r
.a
[1] == 0xffffffff);
558 static void test_pcmpeqh_u (void)
560 uint16x4_encap_t s
, t
;
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);
577 static void test_pcmpeqb_u (void)
579 uint8x8_encap_t s
, t
;
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);
608 static void test_pcmpeqw_s (void)
610 int32x2_encap_t s
, t
;
616 r
.v
= pcmpeqw_s (s
.v
, t
.v
);
617 assert (r
.a
[0] == 0);
618 assert (r
.a
[1] == -1);
621 static void test_pcmpeqh_s (void)
623 int16x4_encap_t s
, t
;
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);
640 static void test_pcmpeqb_s (void)
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);
671 static void test_pcmpgtw_u (void)
673 uint32x2_encap_t s
, t
;
679 r
.v
= pcmpgtw_u (s
.v
, t
.v
);
680 assert (r
.a
[0] == 0x00000000);
681 assert (r
.a
[1] == 0xffffffff);
684 static void test_pcmpgth_u (void)
686 uint16x4_encap_t s
, t
;
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);
703 static void test_pcmpgtb_u (void)
705 uint8x8_encap_t s
, t
;
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);
734 static void test_pcmpgtw_s (void)
736 int32x2_encap_t s
, t
;
742 r
.v
= pcmpgtw_s (s
.v
, t
.v
);
743 assert (r
.a
[0] == -1);
744 assert (r
.a
[1] == 0);
747 static void test_pcmpgth_s (void)
749 int16x4_encap_t s
, t
;
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);
766 static void test_pcmpgtb_s (void)
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);
797 static void test_pextrh_u (void)
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);
812 static void test_pextrh_s (void)
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);
827 static void test_pinsrh_0123_u (void)
829 uint16x4_encap_t s
, t
;
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);
849 static void test_pinsrh_0123_s (void)
851 int16x4_encap_t s
, t
;
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);
871 static void test_pmaddhw (void)
873 int16x4_encap_t s
, t
;
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));
888 static void test_pmaxsh (void)
890 int16x4_encap_t s
, t
;
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);
907 static void test_pmaxub (void)
909 uint8x8_encap_t s
, t
;
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);
938 static void test_pminsh (void)
940 int16x4_encap_t s
, t
;
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);
957 static void test_pminub (void)
959 uint8x8_encap_t s
, t
;
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);
988 static void test_pmovmskb_u (void)
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);
1011 static void test_pmovmskb_s (void)
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);
1034 static void test_pmulhuh (void)
1036 uint16x4_encap_t s
, t
;
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);
1053 static void test_pmulhh (void)
1055 int16x4_encap_t s
, t
;
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);
1072 static void test_pmullh (void)
1074 int16x4_encap_t s
, t
;
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);
1091 static void test_pmuluw (void)
1093 uint32x2_encap_t s
, t
;
1095 s
.a
[0] = 0xdeadbeef;
1097 t
.a
[0] = 0x0f00baaa;
1099 r
= pmuluw (s
.v
, t
.v
);
1100 assert (r
== 0xd0cd08e1d1a70b6ull
);
1103 static void test_pasubub (void)
1105 uint8x8_encap_t s
, t
;
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);
1134 static void test_biadd (void)
1147 assert (r
.a
[0] == 360);
1148 assert (r
.a
[1] == 0);
1149 assert (r
.a
[2] == 0);
1150 assert (r
.a
[3] == 0);
1153 static void test_psadbh (void)
1155 uint8x8_encap_t s
, t
;
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);
1180 static void test_pshufh_u (void)
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);
1199 static void test_pshufh_s (void)
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);
1218 static void test_psllh_u (void)
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);
1233 static void test_psllw_u (void)
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);
1244 static void test_psllh_s (void)
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);
1259 static void test_psllw_s (void)
1265 r
.v
= psllw_s (s
.v
, 2);
1266 assert (r
.a
[0] == -4);
1267 assert (r
.a
[1] == -4);
1270 static void test_psrah_u (void)
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);
1285 static void test_psraw_u (void)
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);
1296 static void test_psrah_s (void)
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);
1311 static void test_psraw_s (void)
1317 r
.v
= psraw_s (s
.v
, 1);
1318 assert (r
.a
[0] == -1);
1319 assert (r
.a
[1] == -1);
1322 static void test_psrlh_u (void)
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);
1337 static void test_psrlw_u (void)
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);
1348 static void test_psrlh_s (void)
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
);
1363 static void test_psrlw_s (void)
1369 r
.v
= psrlw_s (s
.v
, 1);
1370 assert (r
.a
[0] == INT32x2_MAX
);
1371 assert (r
.a
[1] == INT32x2_MAX
);
1374 static void test_psubw_u (void)
1376 uint32x2_encap_t s
, t
;
1382 r
.v
= psubw_u (s
.v
, t
.v
);
1383 assert (r
.a
[0] == 1);
1384 assert (r
.a
[1] == 3);
1387 static void test_psubw_s (void)
1389 int32x2_encap_t s
, t
;
1395 r
.v
= psubw_s (s
.v
, t
.v
);
1396 assert (r
.a
[0] == -5);
1397 assert (r
.a
[1] == 3);
1400 static void test_psubh_u (void)
1402 uint16x4_encap_t s
, t
;
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);
1419 static void test_psubh_s (void)
1421 int16x4_encap_t s
, t
;
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);
1438 static void test_psubb_u (void)
1440 uint8x8_encap_t s
, t
;
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);
1469 static void test_psubb_s (void)
1471 int8x8_encap_t s
, t
;
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);
1500 static void test_psubd_u (void)
1502 uint64_t d
= 789012;
1503 uint64_t e
= 123456;
1506 assert (r
== 665556);
1509 static void test_psubd_s (void)
1512 int64_t e
= -789012;
1515 assert (r
== 912468);
1518 static void test_psubsh (void)
1520 int16x4_encap_t s
, t
;
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
);
1537 static void test_psubsb (void)
1539 int8x8_encap_t s
, t
;
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
);
1568 static void test_psubush (void)
1570 uint16x4_encap_t s
, t
;
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);
1587 static void test_psubusb (void)
1589 uint8x8_encap_t s
, t
;
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);
1618 static void test_punpckhbh_s (void)
1620 int8x8_encap_t s
, t
;
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);
1649 static void test_punpckhbh_u (void)
1651 uint8x8_encap_t s
, t
;
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);
1680 static void test_punpckhhw_s (void)
1682 int16x4_encap_t s
, t
;
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);
1699 static void test_punpckhhw_u (void)
1701 uint16x4_encap_t s
, t
;
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);
1718 static void test_punpckhwd_s (void)
1720 int32x2_encap_t s
, t
;
1726 r
.v
= punpckhwd_s (s
.v
, t
.v
);
1727 assert (r
.a
[0] == 3);
1728 assert (r
.a
[1] == -4);
1731 static void test_punpckhwd_u (void)
1733 uint32x2_encap_t s
, t
;
1739 r
.v
= punpckhwd_u (s
.v
, t
.v
);
1740 assert (r
.a
[0] == 3);
1741 assert (r
.a
[1] == 4);
1744 static void test_punpcklbh_s (void)
1746 int8x8_encap_t s
, t
;
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);
1775 static void test_punpcklbh_u (void)
1777 uint8x8_encap_t s
, t
;
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);
1806 static void test_punpcklhw_s (void)
1808 int16x4_encap_t s
, t
;
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);
1825 static void test_punpcklhw_u (void)
1827 uint16x4_encap_t s
, t
;
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);
1844 static void test_punpcklwd_s (void)
1846 int32x2_encap_t s
, t
;
1852 r
.v
= punpcklwd_s (s
.v
, t
.v
);
1853 assert (r
.a
[0] == 1);
1854 assert (r
.a
[1] == -2);
1857 static void test_punpcklwd_u (void)
1859 uint32x2_encap_t s
, t
;
1865 r
.v
= punpcklwd_u (s
.v
, t
.v
);
1866 assert (r
.a
[0] == 1);
1867 assert (r
.a
[1] == 2);
1911 test_pinsrh_0123_u ();
1912 test_pinsrh_0123_s ();
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 ();