-
Notifications
You must be signed in to change notification settings - Fork 57
/
simd_bit_shift.wast
1104 lines (1074 loc) · 56.3 KB
/
simd_bit_shift.wast
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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;; Test all the bit shift operators on major boundary values and all special values.
(module
(func (export "i8x16.shl") (param $0 v128) (param $1 i32) (result v128) (i8x16.shl (local.get $0) (local.get $1)))
(func (export "i8x16.shr_s") (param $0 v128) (param $1 i32) (result v128) (i8x16.shr_s (local.get $0) (local.get $1)))
(func (export "i8x16.shr_u") (param $0 v128) (param $1 i32) (result v128) (i8x16.shr_u (local.get $0) (local.get $1)))
(func (export "i16x8.shl") (param $0 v128) (param $1 i32) (result v128) (i16x8.shl (local.get $0) (local.get $1)))
(func (export "i16x8.shr_s") (param $0 v128) (param $1 i32) (result v128) (i16x8.shr_s (local.get $0) (local.get $1)))
(func (export "i16x8.shr_u") (param $0 v128) (param $1 i32) (result v128) (i16x8.shr_u (local.get $0) (local.get $1)))
(func (export "i32x4.shl") (param $0 v128) (param $1 i32) (result v128) (i32x4.shl (local.get $0) (local.get $1)))
(func (export "i32x4.shr_s") (param $0 v128) (param $1 i32) (result v128) (i32x4.shr_s (local.get $0) (local.get $1)))
(func (export "i32x4.shr_u") (param $0 v128) (param $1 i32) (result v128) (i32x4.shr_u (local.get $0) (local.get $1)))
(func (export "i64x2.shl") (param $0 v128) (param $1 i32) (result v128) (i64x2.shl (local.get $0) (local.get $1)))
(func (export "i64x2.shr_s") (param $0 v128) (param $1 i32) (result v128) (i64x2.shr_s (local.get $0) (local.get $1)))
(func (export "i64x2.shr_u") (param $0 v128) (param $1 i32) (result v128) (i64x2.shr_u (local.get $0) (local.get $1)))
;; shifting by a constant amount
;; i8x16
(func (export "i8x16.shl_1") (param $0 v128) (result v128) (i8x16.shl (local.get $0) (i32.const 1)))
(func (export "i8x16.shr_u_8") (param $0 v128) (result v128) (i8x16.shr_u (local.get $0) (i32.const 8)))
(func (export "i8x16.shr_s_9") (param $0 v128) (result v128) (i8x16.shr_s (local.get $0) (i32.const 9)))
;; i16x8
(func (export "i16x8.shl_1") (param $0 v128) (result v128) (i16x8.shl (local.get $0) (i32.const 1)))
(func (export "i16x8.shr_u_16") (param $0 v128) (result v128) (i16x8.shr_u (local.get $0) (i32.const 16)))
(func (export "i16x8.shr_s_17") (param $0 v128) (result v128) (i16x8.shr_s (local.get $0) (i32.const 17)))
;; i32x4
(func (export "i32x4.shl_1") (param $0 v128) (result v128) (i32x4.shl (local.get $0) (i32.const 1)))
(func (export "i32x4.shr_u_32") (param $0 v128) (result v128) (i32x4.shr_u (local.get $0) (i32.const 32)))
(func (export "i32x4.shr_s_33") (param $0 v128) (result v128) (i32x4.shr_s (local.get $0) (i32.const 33)))
;; i64x2
(func (export "i64x2.shl_1") (param $0 v128) (result v128) (i64x2.shl (local.get $0) (i32.const 1)))
(func (export "i64x2.shr_u_64") (param $0 v128) (result v128) (i64x2.shr_u (local.get $0) (i32.const 64)))
(func (export "i64x2.shr_s_65") (param $0 v128) (result v128) (i64x2.shr_s (local.get $0) (i32.const 65)))
)
;; i8x16 shl
;; amount less than lane width
(assert_return (invoke "i8x16.shl" (v128.const i8x16 -128 -64 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D)
(i32.const 1))
(v128.const i8x16 0 -128 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A))
(assert_return (invoke "i8x16.shl" (v128.const i8x16 0xAA 0xBB 0xCC 0xDD 0xEE 0xFF 0xA0 0xB0 0xC0 0xD0 0xE0 0xF0 0x0A 0x0B 0x0C 0x0D)
(i32.const 4))
(v128.const i8x16 0xA0 0xB0 0xC0 0xD0 0xE0 0xF0 0x00 0x00 0x00 0x00 0x00 0x00 0xA0 0xB0 0xC0 0xD0))
;; amount is multiple of lane width
(assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 8))
(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
(assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 32))
(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
(assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 128))
(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
(assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 256))
(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
;; amount greater than but not a multiple of lane width
(assert_return (invoke "i8x16.shl" (v128.const i8x16 -128 -64 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D)
(i32.const 9))
(v128.const i8x16 0 -128 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A))
(assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 9))
(v128.const i8x16 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A 0x1C 0x1E))
(assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 17))
(v128.const i8x16 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A 0x1C 0x1E))
(assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 33))
(v128.const i8x16 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A 0x1C 0x1E))
(assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 129))
(v128.const i8x16 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A 0x1C 0x1E))
(assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 257))
(v128.const i8x16 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A 0x1C 0x1E))
(assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 513))
(v128.const i8x16 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A 0x1C 0x1E))
(assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 514))
(v128.const i8x16 0 4 8 12 16 20 24 28 32 36 0x28 0x2C 0x30 0x34 0x38 0x3C))
;; i8x16 shr_u
;; amount less than lane width
(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 -128 -64 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D)
(i32.const 1))
(v128.const i8x16 64 96 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06))
(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 0xAA 0xBB 0xCC 0xDD 0xEE 0xFF 0xA0 0xB0 0xC0 0xD0 0xE0 0xF0 0x0A 0x0B 0x0C 0x0D)
(i32.const 4))
(v128.const i8x16 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x00 0x00 0x00 0x00))
;; amount is multiple of lane width
(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 8))
(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 32))
(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 128))
(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 256))
(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
;; amount greater than but not a multiple of lane width
(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 -128 -64 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D)
(i32.const 9))
(v128.const i8x16 64 96 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06))
(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 9))
(v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 17))
(v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 33))
(v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 129))
(v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 257))
(v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 513))
(v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 514))
(v128.const i8x16 0 0 0 0 1 1 1 1 2 2 0x02 0x02 0x03 0x03 0x03 0x03))
;; i8x16 shr_s
;; amount less than lane width
(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 -128 -64 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D)
(i32.const 1))
(v128.const i8x16 192 224 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06))
(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 0xAA 0xBB 0xCC 0xDD 0xEE 0xFF 0xA0 0xB0 0xC0 0xD0 0xE0 0xF0 0x0A 0x0B 0x0C 0x0D)
(i32.const 4))
(v128.const i8x16 0xFA 0xFB 0xFC 0xFD 0xFE 0xFF 0xFA 0xFB 0xFC 0xFD 0xFE 0xFF 0x00 0x00 0x00 0x00))
;; amount is multiple of lane width
(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 8))
(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 32))
(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 128))
(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 256))
(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
;; amount greater than but not a multiple of lane width
(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 -128 -64 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D)
(i32.const 9))
(v128.const i8x16 192 224 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06))
(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 9))
(v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 17))
(v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 33))
(v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 129))
(v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 257))
(v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 513))
(v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
(i32.const 514))
(v128.const i8x16 0 0 0 0 1 1 1 1 2 2 0x02 0x02 0x03 0x03 0x03 0x03))
;; shifting by a constant amount
(assert_return (invoke "i8x16.shl_1" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
(v128.const i8x16 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A 0x1C 0x1E))
(assert_return (invoke "i8x16.shr_u_8" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
(assert_return (invoke "i8x16.shr_s_9" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
(v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
;; i16x8 shl
;; amount less than lane width
(assert_return (invoke "i16x8.shl" (v128.const i16x8 -128 -64 0 1 2 3 4 5)
(i32.const 1))
(v128.const i16x8 65280 65408 0 2 4 6 8 10))
(assert_return (invoke "i16x8.shl" (v128.const i16x8 012_345 012_345 012_345 012_345 012_345 012_345 012_345 012_345)
(i32.const 2))
(v128.const i16x8 49380 49380 49380 49380 49380 49380 49380 49380))
(assert_return (invoke "i16x8.shl" (v128.const i16x8 0x0_1234 0x0_1234 0x0_1234 0x0_1234 0x0_1234 0x0_1234 0x0_1234 0x0_1234)
(i32.const 2))
(v128.const i16x8 0x48d0 0x48d0 0x48d0 0x48d0 0x48d0 0x48d0 0x48d0 0x48d0))
(assert_return (invoke "i16x8.shl" (v128.const i16x8 0xAABB 0xCCDD 0xEEFF 0xA0B0 0xC0D0 0xE0F0 0x0A0B 0x0C0D)
(i32.const 4))
(v128.const i16x8 0xABB0 0xCDD0 0xEFF0 0xB00 0xD00 0xF00 0xA0B0 0xC0D0))
(assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 8))
(v128.const i16x8 0 256 512 768 1024 1280 1536 1792))
;; amount is multiple of lane width
(assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 32))
(v128.const i16x8 0 1 2 3 4 5 6 7))
(assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 128))
(v128.const i16x8 0 1 2 3 4 5 6 7))
(assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 256))
(v128.const i16x8 0 1 2 3 4 5 6 7))
;; amount greater than but not a multiple of lane width
(assert_return (invoke "i16x8.shl" (v128.const i16x8 -128 -64 0 1 2 3 4 5)
(i32.const 17))
(v128.const i16x8 65280 65408 0 2 4 6 8 10))
(assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 17))
(v128.const i16x8 0 2 4 6 8 10 12 14))
(assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 33))
(v128.const i16x8 0 2 4 6 8 10 12 14))
(assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 129))
(v128.const i16x8 0 2 4 6 8 10 12 14))
(assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 257))
(v128.const i16x8 0 2 4 6 8 10 12 14))
(assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 513))
(v128.const i16x8 0 2 4 6 8 10 12 14))
(assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 514))
(v128.const i16x8 0 4 8 12 16 20 24 28))
;; i16x8 shr_u
;; amount less than lane width
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 -128 -64 0 1 2 3 4 5)
(i32.const 1))
(v128.const i16x8 32704 32736 0 0 1 1 2 2))
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 012_345 012_345 012_345 012_345 012_345 012_345 012_345 012_345)
(i32.const 2))
(v128.const i16x8 3086 3086 3086 3086 3086 3086 3086 3086))
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0x0_90AB 0x0_90AB 0x0_90AB 0x0_90AB 0x0_90AB 0x0_90AB 0x0_90AB 0x0_90AB)
(i32.const 2))
(v128.const i16x8 0x242a 0x242a 0x242a 0x242a 0x242a 0x242a 0x242a 0x242a))
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0xAABB 0xCCDD 0xEEFF 0xA0B0 0xC0D0 0xE0F0 0x0A0B 0x0C0D)
(i32.const 4))
(v128.const i16x8 0xAAB 0xCCD 0xEEF 0xA0B 0xC0D 0xE0F 0x0A0 0x0C0))
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 8))
(v128.const i16x8 0 0 0 0 0 0 0 0))
;; amount is multiple of lane width
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 32))
(v128.const i16x8 0 1 2 3 4 5 6 7))
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 128))
(v128.const i16x8 0 1 2 3 4 5 6 7))
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 256))
(v128.const i16x8 0 1 2 3 4 5 6 7))
;; amount greater than but not a multiple of lane width
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 -128 -64 0 1 2 3 4 5)
(i32.const 17))
(v128.const i16x8 32704 32736 0 0 1 1 2 2))
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 17))
(v128.const i16x8 0 0 1 1 2 2 3 3))
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 33))
(v128.const i16x8 0 0 1 1 2 2 3 3))
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 129))
(v128.const i16x8 0 0 1 1 2 2 3 3))
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 257))
(v128.const i16x8 0 0 1 1 2 2 3 3))
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 513))
(v128.const i16x8 0 0 1 1 2 2 3 3))
(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 514))
(v128.const i16x8 0 0 0 0 1 1 1 1))
;; i16x8 shr_s
;; amount less than lane width
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 -128 -64 0 1 2 3 4 5)
(i32.const 1))
(v128.const i16x8 65472 65504 0 0 1 1 2 2))
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 012_345 012_345 012_345 012_345 012_345 012_345 012_345 012_345)
(i32.const 2))
(v128.const i16x8 3086 3086 3086 3086 3086 3086 3086 3086))
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0x0_90AB 0x0_90AB 0x0_90AB 0x0_90AB 0x0_90AB 0x0_90AB 0x0_90AB 0x0_90AB)
(i32.const 2))
(v128.const i16x8 0xe42a 0xe42a 0xe42a 0xe42a 0xe42a 0xe42a 0xe42a 0xe42a))
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0xAABB 0xCCDD 0xEEFF 0xA0B0 0xC0D0 0xE0F0 0x0A0B 0x0C0D)
(i32.const 4))
(v128.const i16x8 0xFAAB 0xFCCD 0xFEEF 0xFA0B 0xFC0D 0xFE0F 0x00A0 0x00C0))
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 8))
(v128.const i16x8 0 0 0 0 0 0 0 0))
;; amount is multiple of lane width
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 32))
(v128.const i16x8 0 1 2 3 4 5 6 7))
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 128))
(v128.const i16x8 0 1 2 3 4 5 6 7))
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 256))
(v128.const i16x8 0 1 2 3 4 5 6 7))
;; amount greater than but not a multiple of lane width
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 -128 -64 0 1 2 3 4 5)
(i32.const 17))
(v128.const i16x8 65472 65504 0 0 1 1 2 2))
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 17))
(v128.const i16x8 0 0 1 1 2 2 3 3))
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 33))
(v128.const i16x8 0 0 1 1 2 2 3 3))
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 129))
(v128.const i16x8 0 0 1 1 2 2 3 3))
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 257))
(v128.const i16x8 0 0 1 1 2 2 3 3))
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 513))
(v128.const i16x8 0 0 1 1 2 2 3 3))
(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
(i32.const 514))
(v128.const i16x8 0 0 0 0 1 1 1 1))
;; shifting by a constant amount
(assert_return (invoke "i16x8.shl_1" (v128.const i16x8 0 1 2 3 4 5 6 7))
(v128.const i16x8 0 2 4 6 8 10 12 14))
(assert_return (invoke "i16x8.shr_u_16" (v128.const i16x8 0 1 2 3 4 5 6 7))
(v128.const i16x8 0 1 2 3 4 5 6 7))
(assert_return (invoke "i16x8.shr_s_17" (v128.const i16x8 0 1 2 3 4 5 6 7))
(v128.const i16x8 0 0 1 1 2 2 3 3))
;; i32x4 shl
;; amount less than lane width
(assert_return (invoke "i32x4.shl" (v128.const i32x4 -2147483648 -32768 0 0x0A0B0C0D)
(i32.const 1))
(v128.const i32x4 0 4294901760 0 0x1416181A))
(assert_return (invoke "i32x4.shl" (v128.const i32x4 01_234_567_890 01_234_567_890 01_234_567_890 01_234_567_890)
(i32.const 2))
(v128.const i32x4 643304264 643304264 643304264 643304264))
(assert_return (invoke "i32x4.shl" (v128.const i32x4 0x0_1234_5678 0x0_1234_5678 0x0_1234_5678 0x0_1234_5678)
(i32.const 2))
(v128.const i32x4 0x48d159e0 0x48d159e0 0x48d159e0 0x48d159e0))
(assert_return (invoke "i32x4.shl" (v128.const i32x4 0xAABBCCDD 0xEEFFA0B0 0xC0D0E0F0 0x0A0B0C0D)
(i32.const 4))
(v128.const i32x4 0xABBCCDD0 0xEFFA0B00 0x0D0E0F00 0xA0B0C0D0))
(assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 8))
(v128.const i32x4 0 256 0x00000E00 0x00000F00))
;; amount is multiple of lane width
(assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 32))
(v128.const i32x4 0 1 0x0E 0x0F))
(assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 128))
(v128.const i32x4 0 1 0x0E 0x0F))
(assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 256))
(v128.const i32x4 0 1 0x0E 0x0F))
;; amount greater than but not a multiple of lane width
(assert_return (invoke "i32x4.shl" (v128.const i32x4 -2147483648 -32768 0 0x0A0B0C0D)
(i32.const 33))
(v128.const i32x4 0 4294901760 0 0x1416181A))
(assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 33))
(v128.const i32x4 0 2 0x1C 0x1E))
(assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 65))
(v128.const i32x4 0 2 0x1C 0x1E))
(assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 129))
(v128.const i32x4 0 2 0x1C 0x1E))
(assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 257))
(v128.const i32x4 0 2 0x1C 0x1E))
(assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 513))
(v128.const i32x4 0 2 0x1C 0x1E))
(assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 514))
(v128.const i32x4 0 4 0x38 0x3C))
;; i32x4 shr_u
;; amount less than lane width
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 -2147483648 -32768 0x0000000C 0x0000000D)
(i32.const 1))
(v128.const i32x4 1073741824 2147467264 0x00000006 0x00000006))
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 01_234_567_890 01_234_567_890 01_234_567_890 01_234_567_890)
(i32.const 2))
(v128.const i32x4 308641972 308641972 308641972 308641972))
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0x0_90AB_cdef 0x0_90AB_cdef 0x0_90AB_cdef 0x0_90AB_cdef)
(i32.const 2))
(v128.const i32x4 0x242af37b 0x242af37b 0x242af37b 0x242af37b))
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0xAABBCCDD 0xEEFFA0B0 0xC0D0E0F0 0x0A0B0C0D)
(i32.const 4))
(v128.const i32x4 0x0AABBCCD 0x0EEFFA0B 0x0C0D0E0F 0x00A0B0C0))
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 8))
(v128.const i32x4 0 0 0x00000000 0x00000000))
;; amount is multiple of lane width
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 32))
(v128.const i32x4 0 1 0x0E 0x0F))
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 128))
(v128.const i32x4 0 1 0x0E 0x0F))
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 256))
(v128.const i32x4 0 1 0x0E 0x0F))
;; amount greater than but not a multiple of lane width
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 -2147483648 -32768 0x0000000C 0x0000000D)
(i32.const 33))
(v128.const i32x4 1073741824 2147467264 0x00000006 0x00000006))
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 33))
(v128.const i32x4 0 0 0x07 0x07))
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 65))
(v128.const i32x4 0 0 0x07 0x07))
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 129))
(v128.const i32x4 0 0 0x07 0x07))
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 257))
(v128.const i32x4 0 0 0x07 0x07))
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 513))
(v128.const i32x4 0 0 0x07 0x07))
(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 514))
(v128.const i32x4 0 0 0x03 0x03))
;; i32x4 shr_s
;; amount less than lane width
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 -2147483648 -32768 0x0C 0x0D)
(i32.const 1))
(v128.const i32x4 3221225472 4294950912 0x06 0x06))
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 01_234_567_890 01_234_567_890 01_234_567_890 01_234_567_890)
(i32.const 2))
(v128.const i32x4 308641972 308641972 308641972 308641972))
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0x0_90AB_cdef 0x0_90AB_cdef 0x0_90AB_cdef 0x0_90AB_cdef)
(i32.const 2))
(v128.const i32x4 0xe42af37b 0xe42af37b 0xe42af37b 0xe42af37b))
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0xAABBCCDD 0xEEFFA0B0 0xC0D0E0F0 0x0A0B0C0D)
(i32.const 4))
(v128.const i32x4 0xfaabbccd 0xFEEFFA0B 0xFC0D0E0F 0x00A0B0C0))
;; amount is multiple of lane width
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 8))
(v128.const i32x4 0 0 0x00000000 0x00000000))
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 32))
(v128.const i32x4 0 1 0x0E 0x0F))
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 128))
(v128.const i32x4 0 1 0x0E 0x0F))
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 256))
(v128.const i32x4 0 1 0x0E 0x0F))
;; amount greater than but not a multiple of lane width
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 -2147483648 -32768 0x0C 0x0D)
(i32.const 33))
(v128.const i32x4 3221225472 4294950912 0x06 0x06))
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 33))
(v128.const i32x4 0 0 0x07 0x07))
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 65))
(v128.const i32x4 0 0 0x07 0x07))
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 129))
(v128.const i32x4 0 0 0x07 0x07))
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 257))
(v128.const i32x4 0 0 0x07 0x07))
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 513))
(v128.const i32x4 0 0 0x07 0x07))
(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
(i32.const 514))
(v128.const i32x4 0 0 0x03 0x03))
;; shifting by a constant amount
(assert_return (invoke "i32x4.shl_1" (v128.const i32x4 0 1 0x0E 0x0F))
(v128.const i32x4 0 2 28 30))
(assert_return (invoke "i32x4.shr_u_32" (v128.const i32x4 0 1 0x0E 0x0F))
(v128.const i32x4 0 1 0x0E 0x0F))
(assert_return (invoke "i32x4.shr_s_33" (v128.const i32x4 0 1 0x0E 0x0F))
(v128.const i32x4 0 0 7 7))
;; i64x2 shl
;; amount less than lane width
(assert_return (invoke "i64x2.shl" (v128.const i64x2 -9223372036854775808 -2147483648)
(i32.const 1))
(v128.const i64x2 0 18446744069414584320))
(assert_return (invoke "i64x2.shl" (v128.const i64x2 01_234_567_890_123_456_789 01_234_567_890_123_456_789)
(i32.const 2))
(v128.const i64x2 4938271560493827156 4938271560493827156))
(assert_return (invoke "i64x2.shl" (v128.const i64x2 0x0_1234_5678_90AB_cdef 0x0_1234_5678_90AB_cdef)
(i32.const 2))
(v128.const i64x2 0x48d159e242af37bc 0x48d159e242af37bc))
(assert_return (invoke "i64x2.shl" (v128.const i64x2 0xAABBCCDDEEFFA0B0 0xC0D0E0F00A0B0C0D)
(i32.const 4))
(v128.const i64x2 0xABBCCDDEEFFA0B00 0xD0E0F00A0B0C0D0))
(assert_return (invoke "i64x2.shl" (v128.const i64x2 0xAABBCCDDEEFFA0B0 0xC0D0E0F00A0B0C0D)
(i32.const 8))
(v128.const i64x2 0xBBCCDDEEFFA0B000 0xD0E0F00A0B0C0D00))
(assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
(i32.const 16))
(v128.const i64x2 65536 0xF0000))
(assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
(i32.const 32))
(v128.const i64x2 4294967296 0xF00000000))
;; amount is multiple of lane width
(assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
(i32.const 128))
(v128.const i64x2 1 0x0F))
(assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
(i32.const 256))
(v128.const i64x2 1 0x0F))
;; amount greater than but not a multiple of lane width
(assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
(i32.const 65))
(v128.const i64x2 2 0x1E))
(assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
(i32.const 129))
(v128.const i64x2 2 0x1E))
(assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
(i32.const 257))
(v128.const i64x2 2 0x1E))
(assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
(i32.const 513))
(v128.const i64x2 2 0x1E))
(assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
(i32.const 514))
(v128.const i64x2 4 0x3C))
;; i64x2 shr_u
;; amount less than lane width
(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 -9223372036854775808 -2147483648)
(i32.const 1))
(v128.const i64x2 4611686018427387904 9223372035781033984))
(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 01_234_567_890_123_456_789 01_234_567_890_123_456_789)
(i32.const 2))
(v128.const i64x2 308641972530864197 308641972530864197))
(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 0x0_90AB_cdef_8765_4321 0x0_90AB_cdef_8765_4321)
(i32.const 2))
(v128.const i64x2 0x242af37be1d950c8 0x242af37be1d950c8))
(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 0xAABBCCDDEEFFA0B0 0xC0D0E0F00A0B0C0D)
(i32.const 4))
(v128.const i64x2 0xAABBCCDDEEFFA0B 0xC0D0E0F00A0B0C0))
(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 0xAABBCCDDEEFFA0B0 0xC0D0E0F00A0B0C0D)
(i32.const 8))
(v128.const i64x2 0xAABBCCDDEEFFA0 0xC0D0E0F00A0B0C))
(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
(i32.const 16))
(v128.const i64x2 0 0x00))
(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
(i32.const 32))
(v128.const i64x2 0 0x00))
;; amount is multiple of lane width
(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
(i32.const 128))
(v128.const i64x2 1 0x0F))
(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
(i32.const 256))
(v128.const i64x2 1 0x0F))
;; amount greater than but not a multiple of lane width
(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
(i32.const 65))
(v128.const i64x2 0 0x07))
(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
(i32.const 129))
(v128.const i64x2 0 0x07))
(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
(i32.const 257))
(v128.const i64x2 0 0x07))
(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
(i32.const 513))
(v128.const i64x2 0 0x07))
(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 0 0x0F)
(i32.const 514))
(v128.const i64x2 0 0x03))
;; i64x2 shr_s
;; amount less than lane width
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 -9223372036854775808 -2147483648)
(i32.const 1))
(v128.const i64x2 13835058055282163712 18446744072635809792))
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 01_234_567_890_123_456_789 01_234_567_890_123_456_789)
(i32.const 2))
(v128.const i64x2 308641972530864197 308641972530864197))
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 0x0_90AB_cdef_8765_4321 0x0_90AB_cdef_8765_4321)
(i32.const 2))
(v128.const i64x2 0xe42af37be1d950c8 0xe42af37be1d950c8))
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 0xAABBCCDDEEFFA0B0 0xC0D0E0F00A0B0C0D)
(i32.const 4))
(v128.const i64x2 0xFAABBCCDDEEFFA0B 0xFC0D0E0F00A0B0C0))
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 0xFFAABBCCDDEEFFA0 0xC0D0E0F00A0B0C0D)
(i32.const 8))
(v128.const i64x2 0xFFFFAABBCCDDEEFF 0xFFC0D0E0F00A0B0C))
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
(i32.const 16))
(v128.const i64x2 0 0x00))
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
(i32.const 32))
(v128.const i64x2 0 0x00))
;; amount is multiple of lane width
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
(i32.const 128))
(v128.const i64x2 1 0x0F))
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
(i32.const 256))
(v128.const i64x2 1 0x0F))
;; amount greater than but not a multiple of lane width
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 -9223372036854775808 -2147483648)
(i32.const 65))
(v128.const i64x2 13835058055282163712 18446744072635809792))
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 0x0C 0x0D)
(i32.const 65))
(v128.const i64x2 0x06 0x06))
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
(i32.const 129))
(v128.const i64x2 0 0x07))
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
(i32.const 257))
(v128.const i64x2 0 0x07))
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
(i32.const 513))
(v128.const i64x2 0 0x07))
(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
(i32.const 514))
(v128.const i64x2 0 0x03))
;; shifting by a constant amount
(assert_return (invoke "i64x2.shl_1" (v128.const i64x2 1 0x0F))
(v128.const i64x2 2 0x1E))
(assert_return (invoke "i64x2.shr_u_64" (v128.const i64x2 1 0x0F))
(v128.const i64x2 1 0x0F))
(assert_return (invoke "i64x2.shr_s_65" (v128.const i64x2 1 0x0F))
(v128.const i64x2 0 0x07))
;; Combination
(module (memory 1)
(func (export "i8x16.shl-in-block")
(block
(drop
(block (result v128)
(i8x16.shl
(block (result v128) (v128.load (i32.const 0))) (i32.const 1)
)
)
)
)
)
(func (export "i8x16.shr_s-in-block")
(block
(drop
(block (result v128)
(i8x16.shr_s
(block (result v128) (v128.load (i32.const 0))) (i32.const 1)
)
)
)
)
)
(func (export "i8x16.shr_u-in-block")
(block
(drop
(block (result v128)
(i8x16.shr_u
(block (result v128) (v128.load (i32.const 0))) (i32.const 1)
)
)
)
)
)
(func (export "i16x8.shl-in-block")
(block
(drop
(block (result v128)
(i16x8.shl
(block (result v128) (v128.load (i32.const 0))) (i32.const 1)
)
)
)
)
)
(func (export "i16x8.shr_s-in-block")
(block
(drop
(block (result v128)
(i16x8.shr_s
(block (result v128) (v128.load (i32.const 0))) (i32.const 1)
)
)
)
)
)
(func (export "i16x8.shr_u-in-block")
(block
(drop
(block (result v128)
(i16x8.shr_u
(block (result v128) (v128.load (i32.const 0))) (i32.const 1)
)
)
)
)
)
(func (export "i32x4.shl-in-block")
(block
(drop
(block (result v128)
(i32x4.shl
(block (result v128) (v128.load (i32.const 0))) (i32.const 1)
)
)
)
)
)
(func (export "i32x4.shr_s-in-block")
(block
(drop
(block (result v128)
(i32x4.shr_s
(block (result v128) (v128.load (i32.const 0))) (i32.const 1)
)
)
)
)
)
(func (export "i32x4.shr_u-in-block")
(block
(drop
(block (result v128)
(i32x4.shr_u
(block (result v128) (v128.load (i32.const 0))) (i32.const 1)
)
)
)
)
)
(func (export "i64x2.shl-in-block")
(block
(drop
(block (result v128)
(i64x2.shl
(block (result v128) (v128.load (i32.const 0))) (i32.const 1)
)
)
)
)
)
(func (export "i64x2.shr_s-in-block")
(block
(drop
(block (result v128)
(i64x2.shr_s
(block (result v128) (v128.load (i32.const 0))) (i32.const 1)
)
)
)
)
)
(func (export "i64x2.shr_u-in-block")
(block
(drop
(block (result v128)
(i64x2.shr_u
(block (result v128) (v128.load (i32.const 0))) (i32.const 1)
)
)
)
)
)
(func (export "nested-i8x16.shl")
(drop
(i8x16.shl
(i8x16.shl
(i8x16.shl
(v128.load (i32.const 0)) (i32.const 1)
)
(i32.const 1)
)
(i32.const 1)
)
)
)
(func (export "nested-i8x16.shr_s")
(drop
(i8x16.shr_s
(i8x16.shr_s
(i8x16.shr_s
(v128.load (i32.const 0)) (i32.const 1)
)
(i32.const 1)
)
(i32.const 1)
)
)
)
(func (export "nested-i8x16.shr_u")
(drop
(i8x16.shr_u
(i8x16.shr_u
(i8x16.shr_u
(v128.load (i32.const 0)) (i32.const 1)
)
(i32.const 1)
)
(i32.const 1)
)
)
)
(func (export "nested-i16x8.shl")
(drop
(i16x8.shl
(i16x8.shl
(i16x8.shl
(v128.load (i32.const 0)) (i32.const 1)
)
(i32.const 1)
)
(i32.const 1)
)
)
)
(func (export "nested-i16x8.shr_s")
(drop
(i16x8.shr_s
(i16x8.shr_s
(i16x8.shr_s
(v128.load (i32.const 0)) (i32.const 1)
)
(i32.const 1)
)
(i32.const 1)
)
)
)
(func (export "nested-i16x8.shr_u")
(drop
(i16x8.shr_u
(i16x8.shr_u
(i16x8.shr_u
(v128.load (i32.const 0)) (i32.const 1)
)
(i32.const 1)
)
(i32.const 1)
)
)
)
(func (export "nested-i32x4.shl")
(drop
(i32x4.shl
(i32x4.shl
(i32x4.shl
(v128.load (i32.const 0)) (i32.const 1)
)
(i32.const 1)
)
(i32.const 1)
)
)
)
(func (export "nested-i32x4.shr_s")
(drop
(i32x4.shr_s
(i32x4.shr_s
(i32x4.shr_s
(v128.load (i32.const 0)) (i32.const 1)
)
(i32.const 1)
)
(i32.const 1)
)
)
)
(func (export "nested-i32x4.shr_u")
(drop
(i32x4.shr_u
(i32x4.shr_u
(i32x4.shr_u
(v128.load (i32.const 0)) (i32.const 1)
)
(i32.const 1)
)
(i32.const 1)
)
)
)
(func (export "nested-i64x2.shl")
(drop
(i64x2.shl
(i64x2.shl
(i64x2.shl
(v128.load (i32.const 0)) (i32.const 1)
)
(i32.const 1)
)
(i32.const 1)
)
)
)
(func (export "nested-i64x2.shr_s")
(drop
(i64x2.shr_s
(i64x2.shr_s
(i64x2.shr_s
(v128.load (i32.const 0)) (i32.const 1)
)
(i32.const 1)
)
(i32.const 1)
)
)
)
(func (export "nested-i64x2.shr_u")
(drop
(i64x2.shr_u
(i64x2.shr_u
(i64x2.shr_u
(v128.load (i32.const 0)) (i32.const 1)
)
(i32.const 1)
)
(i32.const 1)
)
)
)
)
(assert_return (invoke "i8x16.shl-in-block"))
(assert_return (invoke "i8x16.shr_s-in-block"))
(assert_return (invoke "i8x16.shr_u-in-block"))
(assert_return (invoke "i16x8.shl-in-block"))
(assert_return (invoke "i16x8.shr_s-in-block"))
(assert_return (invoke "i16x8.shr_u-in-block"))
(assert_return (invoke "i32x4.shl-in-block"))
(assert_return (invoke "i32x4.shr_s-in-block"))
(assert_return (invoke "i32x4.shr_u-in-block"))
(assert_return (invoke "i64x2.shl-in-block"))
(assert_return (invoke "i64x2.shr_s-in-block"))
(assert_return (invoke "i64x2.shr_u-in-block"))
(assert_return (invoke "nested-i8x16.shl"))
(assert_return (invoke "nested-i8x16.shr_s"))
(assert_return (invoke "nested-i8x16.shr_u"))
(assert_return (invoke "nested-i16x8.shl"))
(assert_return (invoke "nested-i16x8.shr_s"))
(assert_return (invoke "nested-i16x8.shr_u"))
(assert_return (invoke "nested-i32x4.shl"))
(assert_return (invoke "nested-i32x4.shr_s"))
(assert_return (invoke "nested-i32x4.shr_u"))
(assert_return (invoke "nested-i64x2.shl"))
(assert_return (invoke "nested-i64x2.shr_s"))
(assert_return (invoke "nested-i64x2.shr_u"))
;; Type check
(assert_invalid (module (func (result v128) (i8x16.shl (i32.const 0) (i32.const 0)))) "type mismatch")
(assert_invalid (module (func (result v128) (i8x16.shr_s (i32.const 0) (i32.const 0)))) "type mismatch")
(assert_invalid (module (func (result v128) (i8x16.shr_u (i32.const 0) (i32.const 0)))) "type mismatch")
(assert_invalid (module (func (result v128) (i16x8.shl (i32.const 0) (i32.const 0)))) "type mismatch")
(assert_invalid (module (func (result v128) (i16x8.shr_s (i32.const 0) (i32.const 0)))) "type mismatch")
(assert_invalid (module (func (result v128) (i16x8.shr_u (i32.const 0) (i32.const 0)))) "type mismatch")
(assert_invalid (module (func (result v128) (i32x4.shl (i32.const 0) (i32.const 0)))) "type mismatch")
(assert_invalid (module (func (result v128) (i32x4.shr_s (i32.const 0) (i32.const 0)))) "type mismatch")
(assert_invalid (module (func (result v128) (i32x4.shr_u (i32.const 0) (i32.const 0)))) "type mismatch")
(assert_invalid (module (func (result v128) (i64x2.shl (i32.const 0) (i32.const 0)))) "type mismatch")
(assert_invalid (module (func (result v128) (i64x2.shr_s (i32.const 0) (i32.const 0)))) "type mismatch")
(assert_invalid (module (func (result v128) (i64x2.shr_u (i32.const 0) (i32.const 0)))) "type mismatch")
;; Unknown operators
(assert_malformed (module quote "(memory 1) (func (result v128) (i8x16.shl_s (v128.const i32x4 0 0 0 0)))") "unknown operator")
(assert_malformed (module quote "(memory 1) (func (result v128) (i8x16.shl_r (v128.const i32x4 0 0 0 0)))") "unknown operator")
(assert_malformed (module quote "(memory 1) (func (result v128) (i8x16.shr (v128.const i32x4 0 0 0 0)))") "unknown operator")
(assert_malformed (module quote "(memory 1) (func (result v128) (i16x8.shl_s (v128.const i32x4 0 0 0 0)))") "unknown operator")
(assert_malformed (module quote "(memory 1) (func (result v128) (i16x8.shl_r (v128.const i32x4 0 0 0 0)))") "unknown operator")
(assert_malformed (module quote "(memory 1) (func (result v128) (i16x8.shr (v128.const i32x4 0 0 0 0)))") "unknown operator")
(assert_malformed (module quote "(memory 1) (func (result v128) (i32x4.shl_s (v128.const i32x4 0 0 0 0)))") "unknown operator")
(assert_malformed (module quote "(memory 1) (func (result v128) (i32x4.shl_r (v128.const i32x4 0 0 0 0)))") "unknown operator")
(assert_malformed (module quote "(memory 1) (func (result v128) (i32x4.shr (v128.const i32x4 0 0 0 0)))") "unknown operator")
(assert_malformed (module quote "(memory 1) (func (result v128) (i64x2.shl_s (v128.const i32x4 0 0 0 0)))") "unknown operator")