98e155651e4935918949bff7fa5141c3a76d42a3
[platform/framework/web/lwnode.git] /
1 ;; Test all the bit shift operators on major boundary values and all special values.
2
3 (module
4   (func (export "i8x16.shl") (param $0 v128) (param $1 i32) (result v128) (i8x16.shl (local.get $0) (local.get $1)))
5   (func (export "i8x16.shr_s") (param $0 v128) (param $1 i32) (result v128) (i8x16.shr_s (local.get $0) (local.get $1)))
6   (func (export "i8x16.shr_u") (param $0 v128) (param $1 i32) (result v128) (i8x16.shr_u (local.get $0) (local.get $1)))
7
8   (func (export "i16x8.shl") (param $0 v128) (param $1 i32) (result v128) (i16x8.shl (local.get $0) (local.get $1)))
9   (func (export "i16x8.shr_s") (param $0 v128) (param $1 i32) (result v128) (i16x8.shr_s (local.get $0) (local.get $1)))
10   (func (export "i16x8.shr_u") (param $0 v128) (param $1 i32) (result v128) (i16x8.shr_u (local.get $0) (local.get $1)))
11
12   (func (export "i32x4.shl") (param $0 v128) (param $1 i32) (result v128) (i32x4.shl (local.get $0) (local.get $1)))
13   (func (export "i32x4.shr_s") (param $0 v128) (param $1 i32) (result v128) (i32x4.shr_s (local.get $0) (local.get $1)))
14   (func (export "i32x4.shr_u") (param $0 v128) (param $1 i32) (result v128) (i32x4.shr_u (local.get $0) (local.get $1)))
15
16   (func (export "i64x2.shl") (param $0 v128) (param $1 i32) (result v128) (i64x2.shl (local.get $0) (local.get $1)))
17   (func (export "i64x2.shr_s") (param $0 v128) (param $1 i32) (result v128) (i64x2.shr_s (local.get $0) (local.get $1)))
18   (func (export "i64x2.shr_u") (param $0 v128) (param $1 i32) (result v128) (i64x2.shr_u (local.get $0) (local.get $1)))
19
20   ;; shifting by a constant amount
21   ;; i8x16
22   (func (export "i8x16.shl_1") (param $0 v128) (result v128) (i8x16.shl (local.get $0) (i32.const 1)))
23   (func (export "i8x16.shr_u_8") (param $0 v128) (result v128) (i8x16.shr_u (local.get $0) (i32.const 8)))
24   (func (export "i8x16.shr_s_9") (param $0 v128) (result v128) (i8x16.shr_s (local.get $0) (i32.const 9)))
25
26   ;; i16x8
27   (func (export "i16x8.shl_1") (param $0 v128) (result v128) (i16x8.shl (local.get $0) (i32.const 1)))
28   (func (export "i16x8.shr_u_16") (param $0 v128) (result v128) (i16x8.shr_u (local.get $0) (i32.const 16)))
29   (func (export "i16x8.shr_s_17") (param $0 v128) (result v128) (i16x8.shr_s (local.get $0) (i32.const 17)))
30
31   ;; i32x4
32   (func (export "i32x4.shl_1") (param $0 v128) (result v128) (i32x4.shl (local.get $0) (i32.const 1)))
33   (func (export "i32x4.shr_u_32") (param $0 v128) (result v128) (i32x4.shr_u (local.get $0) (i32.const 32)))
34   (func (export "i32x4.shr_s_33") (param $0 v128) (result v128) (i32x4.shr_s (local.get $0) (i32.const 33)))
35
36   ;; i64x2
37   (func (export "i64x2.shl_1") (param $0 v128) (result v128) (i64x2.shl (local.get $0) (i32.const 1)))
38   (func (export "i64x2.shr_u_64") (param $0 v128) (result v128) (i64x2.shr_u (local.get $0) (i32.const 64)))
39   (func (export "i64x2.shr_s_65") (param $0 v128) (result v128) (i64x2.shr_s (local.get $0) (i32.const 65)))
40 )
41
42 ;; i8x16 shl
43 ;; amount less than lane width
44 (assert_return (invoke "i8x16.shl" (v128.const i8x16 -128 -64 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D)
45                                    (i32.const 1))
46                                    (v128.const i8x16 0 -128 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A))
47 (assert_return (invoke "i8x16.shl" (v128.const i8x16 0xAA 0xBB 0xCC 0xDD 0xEE 0xFF 0xA0 0xB0 0xC0 0xD0 0xE0 0xF0 0x0A 0x0B 0x0C 0x0D)
48                                    (i32.const 4))
49                                    (v128.const i8x16 0xA0 0xB0 0xC0 0xD0 0xE0 0xF0 0x00 0x00 0x00 0x00 0x00 0x00 0xA0 0xB0 0xC0 0xD0))
50 ;; amount is multiple of lane width
51 (assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
52                                    (i32.const 8))
53                                    (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
54 (assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
55                                    (i32.const 32))
56                                    (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
57 (assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
58                                    (i32.const 128))
59                                    (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
60 (assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
61                                    (i32.const 256))
62                                    (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
63 ;; amount greater than but not a multiple of lane width
64 (assert_return (invoke "i8x16.shl" (v128.const i8x16 -128 -64 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D)
65                                    (i32.const 9))
66                                    (v128.const i8x16 0 -128 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A))
67 (assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
68                                    (i32.const 9))
69                                    (v128.const i8x16 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A 0x1C 0x1E))
70 (assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
71                                    (i32.const 17))
72                                    (v128.const i8x16 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A 0x1C 0x1E))
73 (assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
74                                    (i32.const 33))
75                                    (v128.const i8x16 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A 0x1C 0x1E))
76 (assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
77                                    (i32.const 129))
78                                    (v128.const i8x16 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A 0x1C 0x1E))
79 (assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
80                                    (i32.const 257))
81                                    (v128.const i8x16 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A 0x1C 0x1E))
82 (assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
83                                    (i32.const 513))
84                                    (v128.const i8x16 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A 0x1C 0x1E))
85 (assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F)
86                                    (i32.const 514))
87                                    (v128.const i8x16 0 4 8 12 16 20 24 28 32 36 0x28 0x2C 0x30 0x34 0x38 0x3C))
88 ;; i8x16 shr_u
89 ;; amount less than lane width
90 (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)
91                                      (i32.const 1))
92                                      (v128.const i8x16 64 96 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06))
93 (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)
94                                      (i32.const 4))
95                                      (v128.const i8x16 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x00 0x00 0x00 0x00))
96 ;; amount is multiple of lane width
97 (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)
98                                      (i32.const 8))
99                                      (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
100 (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)
101                                      (i32.const 32))
102                                      (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
103 (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)
104                                      (i32.const 128))
105                                      (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
106 (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)
107                                      (i32.const 256))
108                                      (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
109 ;; amount greater than but not a multiple of lane width
110 (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)
111                                      (i32.const 9))
112                                      (v128.const i8x16 64 96 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06))
113 (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)
114                                      (i32.const 9))
115                                      (v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
116 (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)
117                                      (i32.const 17))
118                                      (v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
119 (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)
120                                      (i32.const 33))
121                                      (v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
122 (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)
123                                      (i32.const 129))
124                                      (v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
125 (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)
126                                      (i32.const 257))
127                                      (v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
128 (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)
129                                      (i32.const 513))
130                                      (v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
131 (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)
132                                      (i32.const 514))
133                                      (v128.const i8x16 0 0 0 0 1 1 1 1 2 2 0x02 0x02 0x03 0x03 0x03 0x03))
134 ;; i8x16 shr_s
135 ;; amount less than lane width
136 (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)
137                                      (i32.const 1))
138                                      (v128.const i8x16 192 224 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06))
139 (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)
140                                      (i32.const 4))
141                                      (v128.const i8x16 0xFA 0xFB 0xFC 0xFD 0xFE 0xFF 0xFA 0xFB 0xFC 0xFD 0xFE 0xFF 0x00 0x00 0x00 0x00))
142 ;; amount is multiple of lane width
143 (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)
144                                      (i32.const 8))
145                                      (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
146 (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)
147                                      (i32.const 32))
148                                      (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
149 (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)
150                                      (i32.const 128))
151                                      (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
152 (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)
153                                      (i32.const 256))
154                                      (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
155 ;; amount greater than but not a multiple of lane width
156 (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)
157                                      (i32.const 9))
158                                      (v128.const i8x16 192 224 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06))
159 (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)
160                                      (i32.const 9))
161                                      (v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
162 (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)
163                                      (i32.const 17))
164                                      (v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
165 (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)
166                                      (i32.const 33))
167                                      (v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
168 (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)
169                                      (i32.const 129))
170                                      (v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
171 (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)
172                                      (i32.const 257))
173                                      (v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
174 (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)
175                                      (i32.const 513))
176                                      (v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
177 (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)
178                                      (i32.const 514))
179                                      (v128.const i8x16 0 0 0 0 1 1 1 1 2 2 0x02 0x02 0x03 0x03 0x03 0x03))
180 ;; shifting by a constant amount
181 (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))
182                                      (v128.const i8x16 0 2 4 6 8 10 12 14 16 18 0x14 0x16 0x18 0x1A 0x1C 0x1E))
183 (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))
184                                        (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 0x0A 0x0B 0x0C 0x0D 0x0e 0x0F))
185 (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))
186                                        (v128.const i8x16 0 0 1 1 2 2 3 3 4 4 0x05 0x05 0x06 0x06 0x07 0x07))
187
188 ;; i16x8 shl
189 ;; amount less than lane width
190 (assert_return (invoke "i16x8.shl" (v128.const i16x8 -128 -64 0 1 2 3 4 5)
191                                    (i32.const 1))
192                                    (v128.const i16x8 65280 65408 0 2 4 6 8 10))
193 (assert_return (invoke "i16x8.shl" (v128.const i16x8 012_345 012_345 012_345 012_345 012_345 012_345 012_345 012_345)
194                                    (i32.const 2))
195                                    (v128.const i16x8 49380 49380 49380 49380 49380 49380 49380 49380))
196 (assert_return (invoke "i16x8.shl" (v128.const i16x8 0x0_1234 0x0_1234 0x0_1234 0x0_1234 0x0_1234 0x0_1234 0x0_1234 0x0_1234)
197                                    (i32.const 2))
198                                    (v128.const i16x8 0x48d0 0x48d0 0x48d0 0x48d0 0x48d0 0x48d0 0x48d0 0x48d0))
199 (assert_return (invoke "i16x8.shl" (v128.const i16x8 0xAABB 0xCCDD 0xEEFF 0xA0B0 0xC0D0 0xE0F0 0x0A0B 0x0C0D)
200                                    (i32.const 4))
201                                    (v128.const i16x8 0xABB0 0xCDD0 0xEFF0 0xB00 0xD00 0xF00 0xA0B0 0xC0D0))
202 (assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
203                                    (i32.const 8))
204                                    (v128.const i16x8 0 256 512 768 1024 1280 1536 1792))
205 ;; amount is multiple of lane width
206 (assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
207                                    (i32.const 32))
208                                    (v128.const i16x8 0 1 2 3 4 5 6 7))
209 (assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
210                                    (i32.const 128))
211                                    (v128.const i16x8 0 1 2 3 4 5 6 7))
212 (assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
213                                    (i32.const 256))
214                                    (v128.const i16x8 0 1 2 3 4 5 6 7))
215 ;; amount greater than but not a multiple of lane width
216 (assert_return (invoke "i16x8.shl" (v128.const i16x8 -128 -64 0 1 2 3 4 5)
217                                    (i32.const 17))
218                                    (v128.const i16x8 65280 65408 0 2 4 6 8 10))
219 (assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
220                                    (i32.const 17))
221                                    (v128.const i16x8 0 2 4 6 8 10 12 14))
222 (assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
223                                    (i32.const 33))
224                                    (v128.const i16x8 0 2 4 6 8 10 12 14))
225 (assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
226                                    (i32.const 129))
227                                    (v128.const i16x8 0 2 4 6 8 10 12 14))
228 (assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
229                                    (i32.const 257))
230                                    (v128.const i16x8 0 2 4 6 8 10 12 14))
231 (assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
232                                    (i32.const 513))
233                                    (v128.const i16x8 0 2 4 6 8 10 12 14))
234 (assert_return (invoke "i16x8.shl" (v128.const i16x8 0 1 2 3 4 5 6 7)
235                                    (i32.const 514))
236                                    (v128.const i16x8 0 4 8 12 16 20 24 28))
237
238 ;; i16x8 shr_u
239 ;; amount less than lane width
240 (assert_return (invoke "i16x8.shr_u" (v128.const i16x8 -128 -64 0 1 2 3 4 5)
241                                      (i32.const 1))
242                                      (v128.const i16x8 32704 32736 0 0 1 1 2 2))
243 (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)
244                                      (i32.const 2))
245                                      (v128.const i16x8 3086 3086 3086 3086 3086 3086 3086 3086))
246 (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)
247                                      (i32.const 2))
248                                      (v128.const i16x8 0x242a 0x242a 0x242a 0x242a 0x242a 0x242a 0x242a 0x242a))
249 (assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0xAABB 0xCCDD 0xEEFF 0xA0B0 0xC0D0 0xE0F0 0x0A0B 0x0C0D)
250                                      (i32.const 4))
251                                      (v128.const i16x8 0xAAB 0xCCD 0xEEF 0xA0B 0xC0D 0xE0F 0x0A0 0x0C0))
252 (assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
253                                      (i32.const 8))
254                                      (v128.const i16x8 0 0 0 0 0 0 0 0))
255 ;; amount is multiple of lane width
256 (assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
257                                      (i32.const 32))
258                                      (v128.const i16x8 0 1 2 3 4 5 6 7))
259 (assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
260                                      (i32.const 128))
261                                      (v128.const i16x8 0 1 2 3 4 5 6 7))
262 (assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
263                                      (i32.const 256))
264                                      (v128.const i16x8 0 1 2 3 4 5 6 7))
265 ;; amount greater than but not a multiple of lane width
266 (assert_return (invoke "i16x8.shr_u" (v128.const i16x8 -128 -64 0 1 2 3 4 5)
267                                      (i32.const 17))
268                                      (v128.const i16x8 32704 32736 0 0 1 1 2 2))
269 (assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
270                                      (i32.const 17))
271                                      (v128.const i16x8 0 0 1 1 2 2 3 3))
272 (assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
273                                      (i32.const 33))
274                                      (v128.const i16x8 0 0 1 1 2 2 3 3))
275 (assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
276                                      (i32.const 129))
277                                      (v128.const i16x8 0 0 1 1 2 2 3 3))
278 (assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
279                                      (i32.const 257))
280                                      (v128.const i16x8 0 0 1 1 2 2 3 3))
281 (assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
282                                      (i32.const 513))
283                                      (v128.const i16x8 0 0 1 1 2 2 3 3))
284 (assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 1 2 3 4 5 6 7)
285                                      (i32.const 514))
286                                      (v128.const i16x8 0 0 0 0 1 1 1 1))
287
288 ;; i16x8 shr_s
289 ;; amount less than lane width
290 (assert_return (invoke "i16x8.shr_s" (v128.const i16x8 -128 -64 0 1 2 3 4 5)
291                                      (i32.const 1))
292                                      (v128.const i16x8 65472 65504 0 0 1 1 2 2))
293 (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)
294                                      (i32.const 2))
295                                      (v128.const i16x8 3086 3086 3086 3086 3086 3086 3086 3086))
296 (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)
297                                      (i32.const 2))
298                                      (v128.const i16x8 0xe42a 0xe42a 0xe42a 0xe42a 0xe42a 0xe42a 0xe42a 0xe42a))
299 (assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0xAABB 0xCCDD 0xEEFF 0xA0B0 0xC0D0 0xE0F0 0x0A0B 0x0C0D)
300                                      (i32.const 4))
301                                      (v128.const i16x8 0xFAAB 0xFCCD 0xFEEF 0xFA0B 0xFC0D 0xFE0F 0x00A0 0x00C0))
302 (assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
303                                      (i32.const 8))
304                                      (v128.const i16x8 0 0 0 0 0 0 0 0))
305 ;; amount is multiple of lane width
306 (assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
307                                      (i32.const 32))
308                                      (v128.const i16x8 0 1 2 3 4 5 6 7))
309 (assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
310                                      (i32.const 128))
311                                      (v128.const i16x8 0 1 2 3 4 5 6 7))
312 (assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
313                                      (i32.const 256))
314                                      (v128.const i16x8 0 1 2 3 4 5 6 7))
315 ;; amount greater than but not a multiple of lane width
316 (assert_return (invoke "i16x8.shr_s" (v128.const i16x8 -128 -64 0 1 2 3 4 5)
317                                      (i32.const 17))
318                                      (v128.const i16x8 65472 65504 0 0 1 1 2 2))
319 (assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
320                                      (i32.const 17))
321                                      (v128.const i16x8 0 0 1 1 2 2 3 3))
322 (assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
323                                      (i32.const 33))
324                                      (v128.const i16x8 0 0 1 1 2 2 3 3))
325 (assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
326                                      (i32.const 129))
327                                      (v128.const i16x8 0 0 1 1 2 2 3 3))
328 (assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
329                                      (i32.const 257))
330                                      (v128.const i16x8 0 0 1 1 2 2 3 3))
331 (assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
332                                      (i32.const 513))
333                                      (v128.const i16x8 0 0 1 1 2 2 3 3))
334 (assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 1 2 3 4 5 6 7)
335                                      (i32.const 514))
336                                      (v128.const i16x8 0 0 0 0 1 1 1 1))
337
338 ;; shifting by a constant amount
339 (assert_return (invoke "i16x8.shl_1" (v128.const i16x8 0 1 2 3 4 5 6 7))
340                                      (v128.const i16x8 0 2 4 6 8 10 12 14))
341 (assert_return (invoke "i16x8.shr_u_16" (v128.const i16x8 0 1 2 3 4 5 6 7))
342                                         (v128.const i16x8 0 1 2 3 4 5 6 7))
343 (assert_return (invoke "i16x8.shr_s_17" (v128.const i16x8 0 1 2 3 4 5 6 7))
344                                         (v128.const i16x8 0 0 1 1 2 2 3 3))
345
346 ;; i32x4 shl
347 ;; amount less than lane width
348 (assert_return (invoke "i32x4.shl" (v128.const i32x4 -2147483648 -32768 0 0x0A0B0C0D)
349                                    (i32.const 1))
350                                    (v128.const i32x4 0 4294901760 0 0x1416181A))
351 (assert_return (invoke "i32x4.shl" (v128.const i32x4 01_234_567_890 01_234_567_890 01_234_567_890 01_234_567_890)
352                                    (i32.const 2))
353                                    (v128.const i32x4 643304264 643304264 643304264 643304264))
354 (assert_return (invoke "i32x4.shl" (v128.const i32x4 0x0_1234_5678 0x0_1234_5678 0x0_1234_5678 0x0_1234_5678)
355                                    (i32.const 2))
356                                    (v128.const i32x4 0x48d159e0 0x48d159e0 0x48d159e0 0x48d159e0))
357 (assert_return (invoke "i32x4.shl" (v128.const i32x4 0xAABBCCDD 0xEEFFA0B0 0xC0D0E0F0 0x0A0B0C0D)
358                                    (i32.const 4))
359                                    (v128.const i32x4 0xABBCCDD0 0xEFFA0B00 0x0D0E0F00 0xA0B0C0D0))
360 (assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
361                                    (i32.const 8))
362                                    (v128.const i32x4 0 256 0x00000E00 0x00000F00))
363 ;; amount is multiple of lane width
364 (assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
365                                    (i32.const 32))
366                                    (v128.const i32x4 0 1 0x0E 0x0F))
367 (assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
368                                    (i32.const 128))
369                                    (v128.const i32x4 0 1 0x0E 0x0F))
370 (assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
371                                    (i32.const 256))
372                                    (v128.const i32x4 0 1 0x0E 0x0F))
373 ;; amount greater than but not a multiple of lane width
374 (assert_return (invoke "i32x4.shl" (v128.const i32x4 -2147483648 -32768 0 0x0A0B0C0D)
375                                    (i32.const 33))
376                                    (v128.const i32x4 0 4294901760 0 0x1416181A))
377 (assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
378                                    (i32.const 33))
379                                    (v128.const i32x4 0 2 0x1C 0x1E))
380 (assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
381                                    (i32.const 65))
382                                    (v128.const i32x4 0 2 0x1C 0x1E))
383 (assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
384                                    (i32.const 129))
385                                    (v128.const i32x4 0 2 0x1C 0x1E))
386 (assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
387                                    (i32.const 257))
388                                    (v128.const i32x4 0 2 0x1C 0x1E))
389 (assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
390                                    (i32.const 513))
391                                    (v128.const i32x4 0 2 0x1C 0x1E))
392 (assert_return (invoke "i32x4.shl" (v128.const i32x4 0 1 0x0E 0x0F)
393                                    (i32.const 514))
394                                    (v128.const i32x4 0 4 0x38 0x3C))
395
396 ;; i32x4 shr_u
397 ;; amount less than lane width
398 (assert_return (invoke "i32x4.shr_u" (v128.const i32x4 -2147483648 -32768 0x0000000C 0x0000000D)
399                                      (i32.const 1))
400                                      (v128.const i32x4 1073741824 2147467264 0x00000006 0x00000006))
401 (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)
402                                      (i32.const 2))
403                                      (v128.const i32x4 308641972 308641972 308641972 308641972))
404 (assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0x0_90AB_cdef 0x0_90AB_cdef 0x0_90AB_cdef 0x0_90AB_cdef)
405                                      (i32.const 2))
406                                      (v128.const i32x4 0x242af37b 0x242af37b 0x242af37b 0x242af37b))
407 (assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0xAABBCCDD 0xEEFFA0B0 0xC0D0E0F0 0x0A0B0C0D)
408                                      (i32.const 4))
409                                      (v128.const i32x4 0x0AABBCCD 0x0EEFFA0B 0x0C0D0E0F 0x00A0B0C0))
410 (assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
411                                      (i32.const 8))
412                                      (v128.const i32x4 0 0 0x00000000 0x00000000))
413 ;; amount is multiple of lane width
414 (assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
415                                      (i32.const 32))
416                                      (v128.const i32x4 0 1 0x0E 0x0F))
417 (assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
418                                      (i32.const 128))
419                                      (v128.const i32x4 0 1 0x0E 0x0F))
420 (assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
421                                      (i32.const 256))
422                                      (v128.const i32x4 0 1 0x0E 0x0F))
423 ;; amount greater than but not a multiple of lane width
424 (assert_return (invoke "i32x4.shr_u" (v128.const i32x4 -2147483648 -32768 0x0000000C 0x0000000D)
425                                      (i32.const 33))
426                                      (v128.const i32x4 1073741824 2147467264 0x00000006 0x00000006))
427 (assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
428                                      (i32.const 33))
429                                      (v128.const i32x4 0 0 0x07 0x07))
430 (assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
431                                      (i32.const 65))
432                                      (v128.const i32x4 0 0 0x07 0x07))
433 (assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
434                                      (i32.const 129))
435                                      (v128.const i32x4 0 0 0x07 0x07))
436 (assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
437                                      (i32.const 257))
438                                      (v128.const i32x4 0 0 0x07 0x07))
439 (assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
440                                      (i32.const 513))
441                                      (v128.const i32x4 0 0 0x07 0x07))
442 (assert_return (invoke "i32x4.shr_u" (v128.const i32x4 0 1 0x0E 0x0F)
443                                      (i32.const 514))
444                                      (v128.const i32x4 0 0 0x03 0x03))
445
446 ;; i32x4 shr_s
447 ;; amount less than lane width
448 (assert_return (invoke "i32x4.shr_s" (v128.const i32x4 -2147483648 -32768 0x0C 0x0D)
449                                      (i32.const 1))
450                                      (v128.const i32x4 3221225472 4294950912 0x06 0x06))
451 (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)
452                                      (i32.const 2))
453                                      (v128.const i32x4 308641972 308641972 308641972 308641972))
454 (assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0x0_90AB_cdef 0x0_90AB_cdef 0x0_90AB_cdef 0x0_90AB_cdef)
455                                      (i32.const 2))
456                                      (v128.const i32x4 0xe42af37b 0xe42af37b 0xe42af37b 0xe42af37b))
457 (assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0xAABBCCDD 0xEEFFA0B0 0xC0D0E0F0 0x0A0B0C0D)
458                                      (i32.const 4))
459                                      (v128.const i32x4 0xfaabbccd 0xFEEFFA0B 0xFC0D0E0F 0x00A0B0C0))
460 ;; amount is multiple of lane width
461 (assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
462                                      (i32.const 8))
463                                      (v128.const i32x4 0 0 0x00000000 0x00000000))
464 (assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
465                                      (i32.const 32))
466                                      (v128.const i32x4 0 1 0x0E 0x0F))
467 (assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
468                                      (i32.const 128))
469                                      (v128.const i32x4 0 1 0x0E 0x0F))
470 (assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
471                                      (i32.const 256))
472                                      (v128.const i32x4 0 1 0x0E 0x0F))
473 ;; amount greater than but not a multiple of lane width
474 (assert_return (invoke "i32x4.shr_s" (v128.const i32x4 -2147483648 -32768 0x0C 0x0D)
475                                      (i32.const 33))
476                                      (v128.const i32x4 3221225472 4294950912 0x06 0x06))
477 (assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
478                                      (i32.const 33))
479                                      (v128.const i32x4 0 0 0x07 0x07))
480 (assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
481                                      (i32.const 65))
482                                      (v128.const i32x4 0 0 0x07 0x07))
483 (assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
484                                      (i32.const 129))
485                                      (v128.const i32x4 0 0 0x07 0x07))
486 (assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
487                                      (i32.const 257))
488                                      (v128.const i32x4 0 0 0x07 0x07))
489 (assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
490                                      (i32.const 513))
491                                      (v128.const i32x4 0 0 0x07 0x07))
492 (assert_return (invoke "i32x4.shr_s" (v128.const i32x4 0 1 0x0E 0x0F)
493                                      (i32.const 514))
494                                      (v128.const i32x4 0 0 0x03 0x03))
495
496 ;; shifting by a constant amount
497 (assert_return (invoke "i32x4.shl_1" (v128.const i32x4 0 1 0x0E 0x0F))
498                                      (v128.const i32x4 0 2 28 30))
499 (assert_return (invoke "i32x4.shr_u_32" (v128.const i32x4 0 1 0x0E 0x0F))
500                                         (v128.const i32x4 0 1 0x0E 0x0F))
501 (assert_return (invoke "i32x4.shr_s_33" (v128.const i32x4 0 1 0x0E 0x0F))
502                                         (v128.const i32x4 0 0 7 7))
503
504 ;; i64x2 shl
505 ;; amount less than lane width
506 (assert_return (invoke "i64x2.shl" (v128.const i64x2 -9223372036854775808 -2147483648)
507                                    (i32.const 1))
508                                    (v128.const i64x2 0 18446744069414584320))
509 (assert_return (invoke "i64x2.shl" (v128.const i64x2 01_234_567_890_123_456_789 01_234_567_890_123_456_789)
510                                    (i32.const 2))
511                                    (v128.const i64x2 4938271560493827156 4938271560493827156))
512 (assert_return (invoke "i64x2.shl" (v128.const i64x2 0x0_1234_5678_90AB_cdef 0x0_1234_5678_90AB_cdef)
513                                    (i32.const 2))
514                                    (v128.const i64x2 0x48d159e242af37bc 0x48d159e242af37bc))
515 (assert_return (invoke "i64x2.shl" (v128.const i64x2 0xAABBCCDDEEFFA0B0 0xC0D0E0F00A0B0C0D)
516                                    (i32.const 4))
517                                    (v128.const i64x2 0xABBCCDDEEFFA0B00 0xD0E0F00A0B0C0D0))
518 (assert_return (invoke "i64x2.shl" (v128.const i64x2 0xAABBCCDDEEFFA0B0 0xC0D0E0F00A0B0C0D)
519                                    (i32.const 8))
520                                    (v128.const i64x2 0xBBCCDDEEFFA0B000 0xD0E0F00A0B0C0D00))
521 (assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
522                                    (i32.const 16))
523                                    (v128.const i64x2 65536 0xF0000))
524 (assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
525                                    (i32.const 32))
526                                    (v128.const i64x2 4294967296 0xF00000000))
527 ;; amount is multiple of lane width
528 (assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
529                                    (i32.const 128))
530                                    (v128.const i64x2 1 0x0F))
531 (assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
532                                    (i32.const 256))
533                                    (v128.const i64x2 1 0x0F))
534 ;; amount greater than but not a multiple of lane width
535 (assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
536                                    (i32.const 65))
537                                    (v128.const i64x2 2 0x1E))
538 (assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
539                                    (i32.const 129))
540                                    (v128.const i64x2 2 0x1E))
541 (assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
542                                    (i32.const 257))
543                                    (v128.const i64x2 2 0x1E))
544 (assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
545                                    (i32.const 513))
546                                    (v128.const i64x2 2 0x1E))
547 (assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x0F)
548                                    (i32.const 514))
549                                    (v128.const i64x2 4 0x3C))
550
551 ;; i64x2 shr_u
552 ;; amount less than lane width
553 (assert_return (invoke "i64x2.shr_u" (v128.const i64x2 -9223372036854775808 -2147483648)
554                                      (i32.const 1))
555                                      (v128.const i64x2 4611686018427387904 9223372035781033984))
556 (assert_return (invoke "i64x2.shr_u" (v128.const i64x2 01_234_567_890_123_456_789 01_234_567_890_123_456_789)
557                                      (i32.const 2))
558                                      (v128.const i64x2 308641972530864197 308641972530864197))
559 (assert_return (invoke "i64x2.shr_u" (v128.const i64x2 0x0_90AB_cdef_8765_4321 0x0_90AB_cdef_8765_4321)
560                                      (i32.const 2))
561                                      (v128.const i64x2 0x242af37be1d950c8 0x242af37be1d950c8))
562 (assert_return (invoke "i64x2.shr_u" (v128.const i64x2 0xAABBCCDDEEFFA0B0 0xC0D0E0F00A0B0C0D)
563                                      (i32.const 4))
564                                      (v128.const i64x2 0xAABBCCDDEEFFA0B 0xC0D0E0F00A0B0C0))
565 (assert_return (invoke "i64x2.shr_u" (v128.const i64x2 0xAABBCCDDEEFFA0B0 0xC0D0E0F00A0B0C0D)
566                                      (i32.const 8))
567                                      (v128.const i64x2 0xAABBCCDDEEFFA0 0xC0D0E0F00A0B0C))
568 (assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
569                                      (i32.const 16))
570                                      (v128.const i64x2 0 0x00))
571 (assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
572                                      (i32.const 32))
573                                      (v128.const i64x2 0 0x00))
574 ;; amount is multiple of lane width
575 (assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
576                                      (i32.const 128))
577                                      (v128.const i64x2 1 0x0F))
578 (assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
579                                      (i32.const 256))
580                                      (v128.const i64x2 1 0x0F))
581 ;; amount greater than but not a multiple of lane width
582 (assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
583                                      (i32.const 65))
584                                      (v128.const i64x2 0 0x07))
585 (assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
586                                      (i32.const 129))
587                                      (v128.const i64x2 0 0x07))
588 (assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
589                                      (i32.const 257))
590                                      (v128.const i64x2 0 0x07))
591 (assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x0F)
592                                      (i32.const 513))
593                                      (v128.const i64x2 0 0x07))
594 (assert_return (invoke "i64x2.shr_u" (v128.const i64x2 0 0x0F)
595                                      (i32.const 514))
596                                      (v128.const i64x2 0 0x03))
597
598 ;; i64x2 shr_s
599 ;; amount less than lane width
600 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 -9223372036854775808 -2147483648)
601                                      (i32.const 1))
602                                      (v128.const i64x2 13835058055282163712 18446744072635809792))
603 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 01_234_567_890_123_456_789 01_234_567_890_123_456_789)
604                                      (i32.const 2))
605                                      (v128.const i64x2 308641972530864197 308641972530864197))
606 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 0x0_90AB_cdef_8765_4321 0x0_90AB_cdef_8765_4321)
607                                      (i32.const 2))
608                                      (v128.const i64x2 0xe42af37be1d950c8 0xe42af37be1d950c8))
609 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 0xAABBCCDDEEFFA0B0 0xC0D0E0F00A0B0C0D)
610                                      (i32.const 4))
611                                      (v128.const i64x2 0xFAABBCCDDEEFFA0B 0xFC0D0E0F00A0B0C0))
612 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 0xFFAABBCCDDEEFFA0 0xC0D0E0F00A0B0C0D)
613                                      (i32.const 8))
614                                      (v128.const i64x2 0xFFFFAABBCCDDEEFF 0xFFC0D0E0F00A0B0C))
615 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
616                                      (i32.const 16))
617                                      (v128.const i64x2 0 0x00))
618 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
619                                      (i32.const 32))
620                                      (v128.const i64x2 0 0x00))
621 ;; amount is multiple of lane width
622 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
623                                      (i32.const 128))
624                                      (v128.const i64x2 1 0x0F))
625 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
626                                      (i32.const 256))
627                                      (v128.const i64x2 1 0x0F))
628 ;; amount greater than but not a multiple of lane width
629 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 -9223372036854775808 -2147483648)
630                                      (i32.const 65))
631                                      (v128.const i64x2 13835058055282163712 18446744072635809792))
632 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 0x0C 0x0D)
633                                      (i32.const 65))
634                                      (v128.const i64x2 0x06 0x06))
635 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
636                                      (i32.const 129))
637                                      (v128.const i64x2 0 0x07))
638 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
639                                      (i32.const 257))
640                                      (v128.const i64x2 0 0x07))
641 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
642                                      (i32.const 513))
643                                      (v128.const i64x2 0 0x07))
644 (assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x0F)
645                                      (i32.const 514))
646                                      (v128.const i64x2 0 0x03))
647
648 ;; shifting by a constant amount
649 (assert_return (invoke "i64x2.shl_1" (v128.const i64x2 1 0x0F))
650                                      (v128.const i64x2 2 0x1E))
651 (assert_return (invoke "i64x2.shr_u_64" (v128.const i64x2 1 0x0F))
652                                         (v128.const i64x2 1 0x0F))
653 (assert_return (invoke "i64x2.shr_s_65" (v128.const i64x2 1 0x0F))
654                                         (v128.const i64x2 0 0x07))
655
656 ;; Combination
657
658 (module (memory 1)
659   (func (export "i8x16.shl-in-block")
660     (block
661       (drop
662         (block (result v128)
663           (i8x16.shl
664             (block (result v128) (v128.load (i32.const 0))) (i32.const 1)
665           )
666         )
667       )
668     )
669   )
670   (func (export "i8x16.shr_s-in-block")
671     (block
672       (drop
673         (block (result v128)
674           (i8x16.shr_s
675             (block (result v128) (v128.load (i32.const 0))) (i32.const 1)
676           )
677         )
678       )
679     )
680   )
681   (func (export "i8x16.shr_u-in-block")
682     (block
683       (drop
684         (block (result v128)
685           (i8x16.shr_u
686             (block (result v128) (v128.load (i32.const 0))) (i32.const 1)
687           )
688         )
689       )
690     )
691   )
692   (func (export "i16x8.shl-in-block")
693     (block
694       (drop
695         (block (result v128)
696           (i16x8.shl
697             (block (result v128) (v128.load (i32.const 0))) (i32.const 1)
698           )
699         )
700       )
701     )
702   )
703   (func (export "i16x8.shr_s-in-block")
704     (block
705       (drop
706         (block (result v128)
707           (i16x8.shr_s
708             (block (result v128) (v128.load (i32.const 0))) (i32.const 1)
709           )
710         )
711       )
712     )
713   )
714   (func (export "i16x8.shr_u-in-block")
715     (block
716       (drop
717         (block (result v128)
718           (i16x8.shr_u
719             (block (result v128) (v128.load (i32.const 0))) (i32.const 1)
720           )
721         )
722       )
723     )
724   )
725   (func (export "i32x4.shl-in-block")
726     (block
727       (drop
728         (block (result v128)
729           (i32x4.shl
730             (block (result v128) (v128.load (i32.const 0))) (i32.const 1)
731           )
732         )
733       )
734     )
735   )
736   (func (export "i32x4.shr_s-in-block")
737     (block
738       (drop
739         (block (result v128)
740           (i32x4.shr_s
741             (block (result v128) (v128.load (i32.const 0))) (i32.const 1)
742           )
743         )
744       )
745     )
746   )
747   (func (export "i32x4.shr_u-in-block")
748     (block
749       (drop
750         (block (result v128)
751           (i32x4.shr_u
752             (block (result v128) (v128.load (i32.const 0))) (i32.const 1)
753           )
754         )
755       )
756     )
757   )
758   (func (export "i64x2.shl-in-block")
759     (block
760       (drop
761         (block (result v128)
762           (i64x2.shl
763             (block (result v128) (v128.load (i32.const 0))) (i32.const 1)
764           )
765         )
766       )
767     )
768   )
769   (func (export "i64x2.shr_s-in-block")
770     (block
771       (drop
772         (block (result v128)
773           (i64x2.shr_s
774             (block (result v128) (v128.load (i32.const 0))) (i32.const 1)
775           )
776         )
777       )
778     )
779   )
780   (func (export "i64x2.shr_u-in-block")
781     (block
782       (drop
783         (block (result v128)
784           (i64x2.shr_u
785             (block (result v128) (v128.load (i32.const 0))) (i32.const 1)
786           )
787         )
788       )
789     )
790   )
791   (func (export "nested-i8x16.shl")
792     (drop
793       (i8x16.shl
794         (i8x16.shl
795           (i8x16.shl
796             (v128.load (i32.const 0)) (i32.const 1)
797           )
798           (i32.const 1)
799         )
800         (i32.const 1)
801       )
802     )
803   )
804   (func (export "nested-i8x16.shr_s")
805     (drop
806       (i8x16.shr_s
807         (i8x16.shr_s
808           (i8x16.shr_s
809             (v128.load (i32.const 0)) (i32.const 1)
810           )
811           (i32.const 1)
812         )
813         (i32.const 1)
814       )
815     )
816   )
817   (func (export "nested-i8x16.shr_u")
818     (drop
819       (i8x16.shr_u
820         (i8x16.shr_u
821           (i8x16.shr_u
822             (v128.load (i32.const 0)) (i32.const 1)
823           )
824           (i32.const 1)
825         )
826         (i32.const 1)
827       )
828     )
829   )
830   (func (export "nested-i16x8.shl")
831     (drop
832       (i16x8.shl
833         (i16x8.shl
834           (i16x8.shl
835             (v128.load (i32.const 0)) (i32.const 1)
836           )
837           (i32.const 1)
838         )
839         (i32.const 1)
840       )
841     )
842   )
843   (func (export "nested-i16x8.shr_s")
844     (drop
845       (i16x8.shr_s
846         (i16x8.shr_s
847           (i16x8.shr_s
848             (v128.load (i32.const 0)) (i32.const 1)
849           )
850           (i32.const 1)
851         )
852         (i32.const 1)
853       )
854     )
855   )
856   (func (export "nested-i16x8.shr_u")
857     (drop
858       (i16x8.shr_u
859         (i16x8.shr_u
860           (i16x8.shr_u
861             (v128.load (i32.const 0)) (i32.const 1)
862           )
863           (i32.const 1)
864         )
865         (i32.const 1)
866       )
867     )
868   )
869   (func (export "nested-i32x4.shl")
870     (drop
871       (i32x4.shl
872         (i32x4.shl
873           (i32x4.shl
874             (v128.load (i32.const 0)) (i32.const 1)
875           )
876           (i32.const 1)
877         )
878         (i32.const 1)
879       )
880     )
881   )
882   (func (export "nested-i32x4.shr_s")
883     (drop
884       (i32x4.shr_s
885         (i32x4.shr_s
886           (i32x4.shr_s
887             (v128.load (i32.const 0)) (i32.const 1)
888           )
889           (i32.const 1)
890         )
891         (i32.const 1)
892       )
893     )
894   )
895   (func (export "nested-i32x4.shr_u")
896     (drop
897       (i32x4.shr_u
898         (i32x4.shr_u
899           (i32x4.shr_u
900             (v128.load (i32.const 0)) (i32.const 1)
901           )
902           (i32.const 1)
903         )
904         (i32.const 1)
905       )
906     )
907   )
908   (func (export "nested-i64x2.shl")
909     (drop
910       (i64x2.shl
911         (i64x2.shl
912           (i64x2.shl
913             (v128.load (i32.const 0)) (i32.const 1)
914           )
915           (i32.const 1)
916         )
917         (i32.const 1)
918       )
919     )
920   )
921   (func (export "nested-i64x2.shr_s")
922     (drop
923       (i64x2.shr_s
924         (i64x2.shr_s
925           (i64x2.shr_s
926             (v128.load (i32.const 0)) (i32.const 1)
927           )
928           (i32.const 1)
929         )
930         (i32.const 1)
931       )
932     )
933   )
934   (func (export "nested-i64x2.shr_u")
935     (drop
936       (i64x2.shr_u
937         (i64x2.shr_u
938           (i64x2.shr_u
939             (v128.load (i32.const 0)) (i32.const 1)
940           )
941           (i32.const 1)
942         )
943         (i32.const 1)
944       )
945     )
946   )
947 )
948
949 (assert_return (invoke "i8x16.shl-in-block"))
950 (assert_return (invoke "i8x16.shr_s-in-block"))
951 (assert_return (invoke "i8x16.shr_u-in-block"))
952 (assert_return (invoke "i16x8.shl-in-block"))
953 (assert_return (invoke "i16x8.shr_s-in-block"))
954 (assert_return (invoke "i16x8.shr_u-in-block"))
955 (assert_return (invoke "i32x4.shl-in-block"))
956 (assert_return (invoke "i32x4.shr_s-in-block"))
957 (assert_return (invoke "i32x4.shr_u-in-block"))
958 (assert_return (invoke "i64x2.shl-in-block"))
959 (assert_return (invoke "i64x2.shr_s-in-block"))
960 (assert_return (invoke "i64x2.shr_u-in-block"))
961 (assert_return (invoke "nested-i8x16.shl"))
962 (assert_return (invoke "nested-i8x16.shr_s"))
963 (assert_return (invoke "nested-i8x16.shr_u"))
964 (assert_return (invoke "nested-i16x8.shl"))
965 (assert_return (invoke "nested-i16x8.shr_s"))
966 (assert_return (invoke "nested-i16x8.shr_u"))
967 (assert_return (invoke "nested-i32x4.shl"))
968 (assert_return (invoke "nested-i32x4.shr_s"))
969 (assert_return (invoke "nested-i32x4.shr_u"))
970 (assert_return (invoke "nested-i64x2.shl"))
971 (assert_return (invoke "nested-i64x2.shr_s"))
972 (assert_return (invoke "nested-i64x2.shr_u"))
973
974 ;; Type check
975
976 (assert_invalid (module (func (result v128) (i8x16.shl   (i32.const 0) (i32.const 0)))) "type mismatch")
977 (assert_invalid (module (func (result v128) (i8x16.shr_s (i32.const 0) (i32.const 0)))) "type mismatch")
978 (assert_invalid (module (func (result v128) (i8x16.shr_u (i32.const 0) (i32.const 0)))) "type mismatch")
979 (assert_invalid (module (func (result v128) (i16x8.shl   (i32.const 0) (i32.const 0)))) "type mismatch")
980 (assert_invalid (module (func (result v128) (i16x8.shr_s (i32.const 0) (i32.const 0)))) "type mismatch")
981 (assert_invalid (module (func (result v128) (i16x8.shr_u (i32.const 0) (i32.const 0)))) "type mismatch")
982 (assert_invalid (module (func (result v128) (i32x4.shl   (i32.const 0) (i32.const 0)))) "type mismatch")
983 (assert_invalid (module (func (result v128) (i32x4.shr_s (i32.const 0) (i32.const 0)))) "type mismatch")
984 (assert_invalid (module (func (result v128) (i32x4.shr_u (i32.const 0) (i32.const 0)))) "type mismatch")
985 (assert_invalid (module (func (result v128) (i64x2.shl   (i32.const 0) (i32.const 0)))) "type mismatch")
986 (assert_invalid (module (func (result v128) (i64x2.shr_s (i32.const 0) (i32.const 0)))) "type mismatch")
987 (assert_invalid (module (func (result v128) (i64x2.shr_u (i32.const 0) (i32.const 0)))) "type mismatch")
988
989 ;; Unknown operators
990
991 (assert_malformed (module quote "(memory 1) (func (result v128) (i8x16.shl_s (v128.const i32x4 0 0 0 0)))") "unknown operator")
992 (assert_malformed (module quote "(memory 1) (func (result v128) (i8x16.shl_r (v128.const i32x4 0 0 0 0)))") "unknown operator")
993 (assert_malformed (module quote "(memory 1) (func (result v128) (i8x16.shr   (v128.const i32x4 0 0 0 0)))") "unknown operator")
994 (assert_malformed (module quote "(memory 1) (func (result v128) (i16x8.shl_s (v128.const i32x4 0 0 0 0)))") "unknown operator")
995 (assert_malformed (module quote "(memory 1) (func (result v128) (i16x8.shl_r (v128.const i32x4 0 0 0 0)))") "unknown operator")
996 (assert_malformed (module quote "(memory 1) (func (result v128) (i16x8.shr   (v128.const i32x4 0 0 0 0)))") "unknown operator")
997 (assert_malformed (module quote "(memory 1) (func (result v128) (i32x4.shl_s (v128.const i32x4 0 0 0 0)))") "unknown operator")
998 (assert_malformed (module quote "(memory 1) (func (result v128) (i32x4.shl_r (v128.const i32x4 0 0 0 0)))") "unknown operator")
999 (assert_malformed (module quote "(memory 1) (func (result v128) (i32x4.shr   (v128.const i32x4 0 0 0 0)))") "unknown operator")
1000 (assert_malformed (module quote "(memory 1) (func (result v128) (i64x2.shl_s (v128.const i32x4 0 0 0 0)))") "unknown operator")
1001 (assert_malformed (module quote "(memory 1) (func (result v128) (i64x2.shl_r (v128.const i32x4 0 0 0 0)))") "unknown operator")
1002 (assert_malformed (module quote "(memory 1) (func (result v128) (i64x2.shr   (v128.const i32x4 0 0 0 0)))") "unknown operator")
1003 (assert_malformed (module quote "(memory 1) (func (result v128) (f32x4.shl   (v128.const i32x4 0 0 0 0)))") "unknown operator")
1004 (assert_malformed (module quote "(memory 1) (func (result v128) (f32x4.shr_s (v128.const i32x4 0 0 0 0)))") "unknown operator")
1005 (assert_malformed (module quote "(memory 1) (func (result v128) (f32x4.shr_u (v128.const i32x4 0 0 0 0)))") "unknown operator")
1006
1007 ;; Test operation with empty argument
1008
1009 (assert_invalid
1010   (module
1011     (func $i8x16.shl-1st-arg-empty (result v128)
1012       (i8x16.shl (i32.const 0))
1013     )
1014   )
1015   "type mismatch"
1016 )
1017 (assert_invalid
1018   (module
1019     (func $i8x16.shl-last-arg-empty (result v128)
1020       (i8x16.shl (v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0))
1021     )
1022   )
1023   "type mismatch"
1024 )
1025 (assert_invalid
1026   (module
1027     (func $i8x16.shl-arg-empty (result v128)
1028       (i8x16.shl)
1029     )
1030   )
1031   "type mismatch"
1032 )
1033 (assert_invalid
1034   (module
1035     (func $i16x8.shr_u-1st-arg-empty (result v128)
1036       (i16x8.shr_u (i32.const 0))
1037     )
1038   )
1039   "type mismatch"
1040 )
1041 (assert_invalid
1042   (module
1043     (func $i16x8.shr_u-last-arg-empty (result v128)
1044       (i16x8.shr_u (v128.const i16x8 0 0 0 0 0 0 0 0))
1045     )
1046   )
1047   "type mismatch"
1048 )
1049 (assert_invalid
1050   (module
1051     (func $i16x8.shr_u-arg-empty (result v128)
1052       (i16x8.shr_u)
1053     )
1054   )
1055   "type mismatch"
1056 )
1057 (assert_invalid
1058   (module
1059     (func $i32x4.shr_s-1st-arg-empty (result v128)
1060       (i32x4.shr_s (i32.const 0))
1061     )
1062   )
1063   "type mismatch"
1064 )
1065 (assert_invalid
1066   (module
1067     (func $i32x4.shr_s-last-arg-empty (result v128)
1068       (i32x4.shr_s (v128.const i32x4 0 0 0 0))
1069     )
1070   )
1071   "type mismatch"
1072 )
1073 (assert_invalid
1074   (module
1075     (func $i32x4.shr_s-arg-empty (result v128)
1076       (i32x4.shr_s)
1077     )
1078   )
1079   "type mismatch"
1080 )
1081 (assert_invalid
1082   (module
1083     (func $i64x2.shl-1st-arg-empty (result v128)
1084       (i64x2.shl (i32.const 0))
1085     )
1086   )
1087   "type mismatch"
1088 )
1089 (assert_invalid
1090   (module
1091     (func $i64x2.shr_u-last-arg-empty (result v128)
1092       (i64x2.shr_u (v128.const i64x2 0 0))
1093     )
1094   )
1095   "type mismatch"
1096 )
1097 (assert_invalid
1098   (module
1099     (func $i64x2.shr_s-arg-empty (result v128)
1100       (i64x2.shr_s)
1101     )
1102   )
1103   "type mismatch"
1104 )