blob: a5cabbc52f955203313b51b23302152f2ae33c53 [file] [log] [blame]
Wouter van Oortmerssen8a9cb242018-08-27 15:45:51 +00001; RUN: llc < %s -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-unimplemented-simd -mattr=+simd128,+sign-ext --show-mc-encoding | FileCheck %s --check-prefixes CHECK,SIMD128
2; RUN: llc < %s -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128,+sign-ext --show-mc-encoding | FileCheck %s --check-prefixes CHECK,SIMD128-VM
3; RUN: llc < %s -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=-simd128,+sign-ext --show-mc-encoding | FileCheck %s --check-prefixes CHECK,NO-SIMD128
Heejin Ahna0fd9c32018-08-14 18:53:27 +00004
5; Test that basic SIMD128 vector manipulation operations assemble as expected.
6
7target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
8target triple = "wasm32-unknown-unknown"
9
10; ==============================================================================
11; 16 x i8
12; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +000013; CHECK-LABEL: const_v16i8:
14; NO-SIMD128-NOT: i8x16
15; SIMD128: .result v128{{$}}
16; SIMD128: v128.const $push0=,
17; SIMD128-SAME: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
18; SIMD128-SAME: # encoding: [0xfd,0x00,
19; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
20; SIMD128-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]{{$}}
21define <16 x i8> @const_v16i8() {
22 ret <16 x i8> <i8 00, i8 01, i8 02, i8 03, i8 04, i8 05, i8 06, i8 07,
23 i8 08, i8 09, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>
24}
25
Derek Schuff4ec8bca2018-08-15 00:30:27 +000026; CHECK-LABEL: splat_v16i8:
27; NO-SIMD128-NOT: i8x16
28; SIMD128: .param i32{{$}}
29; SIMD128: .result v128{{$}}
30; SIMD128: i8x16.splat $push0=, $0 # encoding: [0xfd,0x03]{{$}}
31; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
32define <16 x i8> @splat_v16i8(i8 %x) {
33 %v = insertelement <16 x i8> undef, i8 %x, i32 0
34 %res = shufflevector <16 x i8> %v, <16 x i8> undef,
35 <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0,
36 i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
37 ret <16 x i8> %res
38}
39
Thomas Lively1b55b2b2018-09-04 21:26:17 +000040; CHECK-LABEL: const_splat_v16i8:
Thomas Livelyda26b842018-08-23 19:23:13 +000041; SIMD128; i8x16.splat
42define <16 x i8> @const_splat_v16i8() {
43 ret <16 x i8> <i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42,
44 i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42>
45}
46
Heejin Ahnc15a8782018-08-14 19:10:50 +000047; CHECK-LABEL: extract_v16i8_s:
Heejin Ahna0fd9c32018-08-14 18:53:27 +000048; NO-SIMD128-NOT: i8x16
49; SIMD128: .param v128{{$}}
50; SIMD128: .result i32{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +000051; SIMD128: i8x16.extract_lane_s $push0=, $0, 13 # encoding: [0xfd,0x09,0x0d]{{$}}
52; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +000053define i32 @extract_v16i8_s(<16 x i8> %v) {
54 %elem = extractelement <16 x i8> %v, i8 13
55 %a = sext i8 %elem to i32
56 ret i32 %a
57}
58
Heejin Ahnc15a8782018-08-14 19:10:50 +000059; CHECK-LABEL: extract_v16i8_u:
Heejin Ahna0fd9c32018-08-14 18:53:27 +000060; NO-SIMD128-NOT: i8x16
61; SIMD128: .param v128{{$}}
62; SIMD128: .result i32{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +000063; SIMD128: i8x16.extract_lane_u $push0=, $0, 13 # encoding: [0xfd,0x0a,0x0d]{{$}}
64; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +000065define i32 @extract_v16i8_u(<16 x i8> %v) {
66 %elem = extractelement <16 x i8> %v, i8 13
67 %a = zext i8 %elem to i32
68 ret i32 %a
69}
70
Heejin Ahnc15a8782018-08-14 19:10:50 +000071; CHECK-LABEL: extract_v16i8:
Heejin Ahna0fd9c32018-08-14 18:53:27 +000072; NO-SIMD128-NOT: i8x16
73; SIMD128: .param v128{{$}}
74; SIMD128: .result i32{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +000075; SIMD128: i8x16.extract_lane_u $push0=, $0, 13 # encoding: [0xfd,0x0a,0x0d]{{$}}
76; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +000077define i8 @extract_v16i8(<16 x i8> %v) {
78 %elem = extractelement <16 x i8> %v, i8 13
79 ret i8 %elem
80}
81
Derek Schuff82812fb2018-08-15 16:18:51 +000082; CHECK-LABEL: replace_v16i8:
83; NO-SIMD128-NOT: i8x16
84; SIMD128: .param v128, i32{{$}}
85; SIMD128: .result v128{{$}}
86; SIMD128: i8x16.replace_lane $push0=, $0, 11, $1 # encoding: [0xfd,0x11,0x0b]{{$}}
87; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
88define <16 x i8> @replace_v16i8(<16 x i8> %v, i8 %x) {
89 %res = insertelement <16 x i8> %v, i8 %x, i32 11
90 ret <16 x i8> %res
91}
92
Thomas Livelya0d25812018-09-07 21:54:46 +000093; CHECK-LABEL: shuffle_v16i8:
94; NO-SIMD128-NOT: v8x16
95; SIMD128: .param v128, v128{{$}}
96; SIMD128: .result v128{{$}}
97; SIMD128: v8x16.shuffle $push0=, $0, $1,
98; SIMD128-SAME: 0, 17, 2, 19, 4, 21, 6, 23, 8, 25, 10, 27, 12, 29, 14, 31
99; SIMD128-SAME: # encoding: [0xfd,0x17,
100; SIMD128-SAME: 0x00,0x11,0x02,0x13,0x04,0x15,0x06,0x17,
101; SIMD128-SAME: 0x08,0x19,0x0a,0x1b,0x0c,0x1d,0x0e,0x1f]
102; SIMD128: return $pop0 #
103define <16 x i8> @shuffle_v16i8(<16 x i8> %x, <16 x i8> %y) {
104 %res = shufflevector <16 x i8> %x, <16 x i8> %y,
105 <16 x i32> <i32 0, i32 17, i32 2, i32 19, i32 4, i32 21, i32 6, i32 23,
106 i32 8, i32 25, i32 10, i32 27, i32 12, i32 29, i32 14, i32 31>
107 ret <16 x i8> %res
108}
109
Thomas Lively2ee686d2018-08-22 23:06:27 +0000110; CHECK-LABEL: build_v16i8:
111; NO-SIMD128-NOT: i8x16
112; SIMD128: .param i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32{{$}}
113; SIMD128: .result v128{{$}}
114; SIMD128: i8x16.splat $push0=, $0 # encoding: [0xfd,0x03]
115; SIMD128: i8x16.replace_lane $push1=, $pop0, 1, $1 # encoding: [0xfd,0x11,0x01]
116; SIMD128: i8x16.replace_lane $push2=, $pop1, 2, $2 # encoding: [0xfd,0x11,0x02]
117; SIMD128: i8x16.replace_lane $push3=, $pop2, 3, $3 # encoding: [0xfd,0x11,0x03]
118; SIMD128: i8x16.replace_lane $push4=, $pop3, 4, $4 # encoding: [0xfd,0x11,0x04]
119; SIMD128: i8x16.replace_lane $push5=, $pop4, 5, $5 # encoding: [0xfd,0x11,0x05]
120; SIMD128: i8x16.replace_lane $push6=, $pop5, 6, $6 # encoding: [0xfd,0x11,0x06]
121; SIMD128: i8x16.replace_lane $push7=, $pop6, 7, $7 # encoding: [0xfd,0x11,0x07]
122; SIMD128: i8x16.replace_lane $push8=, $pop7, 8, $8 # encoding: [0xfd,0x11,0x08]
123; SIMD128: i8x16.replace_lane $push9=, $pop8, 9, $9 # encoding: [0xfd,0x11,0x09]
124; SIMD128: i8x16.replace_lane $push10=, $pop9, 10, $10 # encoding: [0xfd,0x11,0x0a]
125; SIMD128: i8x16.replace_lane $push11=, $pop10, 11, $11 # encoding: [0xfd,0x11,0x0b]
126; SIMD128: i8x16.replace_lane $push12=, $pop11, 12, $12 # encoding: [0xfd,0x11,0x0c]
127; SIMD128: i8x16.replace_lane $push13=, $pop12, 13, $13 # encoding: [0xfd,0x11,0x0d]
128; SIMD128: i8x16.replace_lane $push14=, $pop13, 14, $14 # encoding: [0xfd,0x11,0x0e]
129; SIMD128: i8x16.replace_lane $push15=, $pop14, 15, $15 # encoding: [0xfd,0x11,0x0f]
130; SIMD128: return $pop15 # encoding: [0x0f]
131define <16 x i8> @build_v16i8(i8 %x0, i8 %x1, i8 %x2, i8 %x3,
132 i8 %x4, i8 %x5, i8 %x6, i8 %x7,
133 i8 %x8, i8 %x9, i8 %x10, i8 %x11,
134 i8 %x12, i8 %x13, i8 %x14, i8 %x15) {
135 %t0 = insertelement <16 x i8> undef, i8 %x0, i32 0
136 %t1 = insertelement <16 x i8> %t0, i8 %x1, i32 1
137 %t2 = insertelement <16 x i8> %t1, i8 %x2, i32 2
138 %t3 = insertelement <16 x i8> %t2, i8 %x3, i32 3
139 %t4 = insertelement <16 x i8> %t3, i8 %x4, i32 4
140 %t5 = insertelement <16 x i8> %t4, i8 %x5, i32 5
141 %t6 = insertelement <16 x i8> %t5, i8 %x6, i32 6
142 %t7 = insertelement <16 x i8> %t6, i8 %x7, i32 7
143 %t8 = insertelement <16 x i8> %t7, i8 %x8, i32 8
144 %t9 = insertelement <16 x i8> %t8, i8 %x9, i32 9
145 %t10 = insertelement <16 x i8> %t9, i8 %x10, i32 10
146 %t11 = insertelement <16 x i8> %t10, i8 %x11, i32 11
147 %t12 = insertelement <16 x i8> %t11, i8 %x12, i32 12
148 %t13 = insertelement <16 x i8> %t12, i8 %x13, i32 13
149 %t14 = insertelement <16 x i8> %t13, i8 %x14, i32 14
150 %res = insertelement <16 x i8> %t14, i8 %x15, i32 15
151 ret <16 x i8> %res
152}
153
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000154; ==============================================================================
155; 8 x i16
156; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000157; CHECK-LABEL: const_v8i16:
158; NO-SIMD128-NOT: i16x8
159; SIMD128: .result v128{{$}}
160; SIMD128: v128.const $push0=, 256, 770, 1284, 1798, 2312, 2826, 3340, 3854
161; SIMD128-SAME: # encoding: [0xfd,0x00,
162; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
163; SIMD128-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]{{$}}
164define <8 x i16> @const_v8i16() {
165 ret <8 x i16> <i16 256, i16 770, i16 1284, i16 1798,
166 i16 2312, i16 2826, i16 3340, i16 3854>
167}
168
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000169; CHECK-LABEL: splat_v8i16:
170; NO-SIMD128-NOT: i16x8
171; SIMD128: .param i32{{$}}
172; SIMD128: .result v128{{$}}
173; SIMD128: i16x8.splat $push0=, $0 # encoding: [0xfd,0x04]{{$}}
174; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
175define <8 x i16> @splat_v8i16(i16 %x) {
176 %v = insertelement <8 x i16> undef, i16 %x, i32 0
177 %res = shufflevector <8 x i16> %v, <8 x i16> undef,
178 <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
179 ret <8 x i16> %res
180}
181
Thomas Livelycfab8b42018-09-04 21:51:32 +0000182; CHECK-LABEL: const_splat_v8i16:
Thomas Livelyda26b842018-08-23 19:23:13 +0000183; SIMD128; i16x8.splat
184define <8 x i16> @const_splat_v8i16() {
185 ret <8 x i16> <i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42>
186}
187
Heejin Ahnc15a8782018-08-14 19:10:50 +0000188; CHECK-LABEL: extract_v8i16_s:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000189; NO-SIMD128-NOT: i16x8
190; SIMD128: .param v128{{$}}
191; SIMD128: .result i32{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +0000192; SIMD128: i16x8.extract_lane_s $push0=, $0, 5 # encoding: [0xfd,0x0b,0x05]{{$}}
193; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000194define i32 @extract_v8i16_s(<8 x i16> %v) {
195 %elem = extractelement <8 x i16> %v, i16 5
196 %a = sext i16 %elem to i32
197 ret i32 %a
198}
199
Heejin Ahnc15a8782018-08-14 19:10:50 +0000200; CHECK-LABEL: extract_v8i16_u:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000201; NO-SIMD128-NOT: i16x8
202; SIMD128: .param v128{{$}}
203; SIMD128: .result i32{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +0000204; SIMD128: i16x8.extract_lane_u $push0=, $0, 5 # encoding: [0xfd,0x0c,0x05]{{$}}
205; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000206define i32 @extract_v8i16_u(<8 x i16> %v) {
207 %elem = extractelement <8 x i16> %v, i16 5
208 %a = zext i16 %elem to i32
209 ret i32 %a
210}
211
Heejin Ahnc15a8782018-08-14 19:10:50 +0000212; CHECK-LABEL: extract_v8i16:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000213; NO-SIMD128-NOT: i16x8
214; SIMD128: .param v128{{$}}
215; SIMD128: .result i32{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +0000216; SIMD128: i16x8.extract_lane_u $push0=, $0, 5 # encoding: [0xfd,0x0c,0x05]{{$}}
217; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000218define i16 @extract_v8i16(<8 x i16> %v) {
219 %elem = extractelement <8 x i16> %v, i16 5
220 ret i16 %elem
221}
222
Derek Schuff82812fb2018-08-15 16:18:51 +0000223; CHECK-LABEL: replace_v8i16:
224; NO-SIMD128-NOT: i16x8
225; SIMD128: .param v128, i32{{$}}
226; SIMD128: .result v128{{$}}
227; SIMD128: i16x8.replace_lane $push0=, $0, 7, $1 # encoding: [0xfd,0x12,0x07]{{$}}
228; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
229define <8 x i16> @replace_v8i16(<8 x i16> %v, i16 %x) {
230 %res = insertelement <8 x i16> %v, i16 %x, i32 7
231 ret <8 x i16> %res
232}
233
Thomas Livelya0d25812018-09-07 21:54:46 +0000234; CHECK-LABEL: shuffle_v8i16:
235; NO-SIMD128-NOT: v8x16
236; SIMD128: .param v128, v128{{$}}
237; SIMD128: .result v128{{$}}
238; SIMD128: v8x16.shuffle $push0=, $0, $1,
239; SIMD128-SAME: 0, 1, 18, 19, 4, 5, 22, 23, 8, 9, 26, 27, 12, 13, 30, 31
240; SIMD128-SAME: # encoding: [0xfd,0x17,
241; SIMD128-SAME: 0x00,0x01,0x12,0x13,0x04,0x05,0x16,0x17,
242; SIMD128-SAME: 0x08,0x09,0x1a,0x1b,0x0c,0x0d,0x1e,0x1f]
243; SIMD128: return $pop0 #
244define <8 x i16> @shuffle_v8i16(<8 x i16> %x, <8 x i16> %y) {
245 %res = shufflevector <8 x i16> %x, <8 x i16> %y,
246 <8 x i32> <i32 0, i32 9, i32 2, i32 11, i32 4, i32 13, i32 6, i32 15>
247 ret <8 x i16> %res
248}
249
Thomas Lively2ee686d2018-08-22 23:06:27 +0000250; CHECK-LABEL: build_v8i16:
251; NO-SIMD128-NOT: i16x8
252; SIMD128: .param i32, i32, i32, i32, i32, i32, i32, i32{{$}}
253; SIMD128: .result v128{{$}}
254; SIMD128: i16x8.splat $push0=, $0 # encoding: [0xfd,0x04]
255; SIMD128: i16x8.replace_lane $push1=, $pop0, 1, $1 # encoding: [0xfd,0x12,0x01]
256; SIMD128: i16x8.replace_lane $push2=, $pop1, 2, $2 # encoding: [0xfd,0x12,0x02]
257; SIMD128: i16x8.replace_lane $push3=, $pop2, 3, $3 # encoding: [0xfd,0x12,0x03]
258; SIMD128: i16x8.replace_lane $push4=, $pop3, 4, $4 # encoding: [0xfd,0x12,0x04]
259; SIMD128: i16x8.replace_lane $push5=, $pop4, 5, $5 # encoding: [0xfd,0x12,0x05]
260; SIMD128: i16x8.replace_lane $push6=, $pop5, 6, $6 # encoding: [0xfd,0x12,0x06]
261; SIMD128: i16x8.replace_lane $push7=, $pop6, 7, $7 # encoding: [0xfd,0x12,0x07]
262; SIMD128: return $pop7 # encoding: [0x0f]
263define <8 x i16> @build_v8i16(i16 %x0, i16 %x1, i16 %x2, i16 %x3,
264 i16 %x4, i16 %x5, i16 %x6, i16 %x7) {
265 %t0 = insertelement <8 x i16> undef, i16 %x0, i32 0
266 %t1 = insertelement <8 x i16> %t0, i16 %x1, i32 1
267 %t2 = insertelement <8 x i16> %t1, i16 %x2, i32 2
268 %t3 = insertelement <8 x i16> %t2, i16 %x3, i32 3
269 %t4 = insertelement <8 x i16> %t3, i16 %x4, i32 4
270 %t5 = insertelement <8 x i16> %t4, i16 %x5, i32 5
271 %t6 = insertelement <8 x i16> %t5, i16 %x6, i32 6
272 %res = insertelement <8 x i16> %t6, i16 %x7, i32 7
273 ret <8 x i16> %res
274}
275
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000276; ==============================================================================
277; 4 x i32
278; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000279; CHECK-LABEL: const_v4i32:
280; NO-SIMD128-NOT: i32x4
281; SIMD128: .result v128{{$}}
282; SIMD128: v128.const $push0=, 50462976, 117835012, 185207048, 252579084
283; SIMD128-SAME: # encoding: [0xfd,0x00,
284; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
285; SIMD128-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]{{$}}
286define <4 x i32> @const_v4i32() {
287 ret <4 x i32> <i32 50462976, i32 117835012, i32 185207048, i32 252579084>
288}
289
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000290; CHECK-LABEL: splat_v4i32:
291; NO-SIMD128-NOT: i32x4
292; SIMD128: .param i32{{$}}
293; SIMD128: .result v128{{$}}
294; SIMD128: i32x4.splat $push0=, $0 # encoding: [0xfd,0x05]{{$}}
295; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
296define <4 x i32> @splat_v4i32(i32 %x) {
297 %v = insertelement <4 x i32> undef, i32 %x, i32 0
298 %res = shufflevector <4 x i32> %v, <4 x i32> undef,
299 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
300 ret <4 x i32> %res
301}
302
Thomas Lively1b55b2b2018-09-04 21:26:17 +0000303; CHECK-LABEL: const_splat_v4i32:
Thomas Livelyda26b842018-08-23 19:23:13 +0000304; SIMD128; i32x4.splat
305define <4 x i32> @const_splat_v4i32() {
306 ret <4 x i32> <i32 42, i32 42, i32 42, i32 42>
307}
308
Heejin Ahnc15a8782018-08-14 19:10:50 +0000309; CHECK-LABEL: extract_v4i32:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000310; NO-SIMD128-NOT: i32x4
311; SIMD128: .param v128{{$}}
312; SIMD128: .result i32{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +0000313; SIMD128: i32x4.extract_lane $push0=, $0, 3 # encoding: [0xfd,0x0d,0x03]{{$}}
314; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000315define i32 @extract_v4i32(<4 x i32> %v) {
316 %elem = extractelement <4 x i32> %v, i32 3
317 ret i32 %elem
318}
319
Derek Schuff82812fb2018-08-15 16:18:51 +0000320; CHECK-LABEL: replace_v4i32:
321; NO-SIMD128-NOT: i32x4
322; SIMD128: .param v128, i32{{$}}
323; SIMD128: .result v128{{$}}
324; SIMD128: i32x4.replace_lane $push0=, $0, 2, $1 # encoding: [0xfd,0x13,0x02]{{$}}
325; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
326define <4 x i32> @replace_v4i32(<4 x i32> %v, i32 %x) {
327 %res = insertelement <4 x i32> %v, i32 %x, i32 2
328 ret <4 x i32> %res
329}
330
Thomas Livelya0d25812018-09-07 21:54:46 +0000331; CHECK-LABEL: shuffle_v4i32:
332; NO-SIMD128-NOT: v8x16
333; SIMD128: .param v128, v128{{$}}
334; SIMD128: .result v128{{$}}
335; SIMD128: v8x16.shuffle $push0=, $0, $1,
336; SIMD128-SAME: 0, 1, 2, 3, 20, 21, 22, 23, 8, 9, 10, 11, 28, 29, 30, 31
337; SIMD128-SAME: # encoding: [0xfd,0x17,
338; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x14,0x15,0x16,0x17,
339; SIMD128-SAME: 0x08,0x09,0x0a,0x0b,0x1c,0x1d,0x1e,0x1f]
340; SIMD128: return $pop0 #
341define <4 x i32> @shuffle_v4i32(<4 x i32> %x, <4 x i32> %y) {
342 %res = shufflevector <4 x i32> %x, <4 x i32> %y,
343 <4 x i32> <i32 0, i32 5, i32 2, i32 7>
344 ret <4 x i32> %res
345}
346
Thomas Lively2ee686d2018-08-22 23:06:27 +0000347; CHECK-LABEL: build_v4i32:
348; NO-SIMD128-NOT: i32x4
349; SIMD128: .param i32, i32, i32, i32{{$}}
350; SIMD128: .result v128{{$}}
351; SIMD128: i32x4.splat $push0=, $0 # encoding: [0xfd,0x05]
352; SIMD128: i32x4.replace_lane $push1=, $pop0, 1, $1 # encoding: [0xfd,0x13,0x01]
353; SIMD128: i32x4.replace_lane $push2=, $pop1, 2, $2 # encoding: [0xfd,0x13,0x02]
354; SIMD128: i32x4.replace_lane $push3=, $pop2, 3, $3 # encoding: [0xfd,0x13,0x03]
355; SIMD128: return $pop3 # encoding: [0x0f]
356define <4 x i32> @build_v4i32(i32 %x0, i32 %x1, i32 %x2, i32 %x3) {
357 %t0 = insertelement <4 x i32> undef, i32 %x0, i32 0
358 %t1 = insertelement <4 x i32> %t0, i32 %x1, i32 1
359 %t2 = insertelement <4 x i32> %t1, i32 %x2, i32 2
360 %res = insertelement <4 x i32> %t2, i32 %x3, i32 3
361 ret <4 x i32> %res
362}
363
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000364; ==============================================================================
365; 2 x i64
366; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000367; CHECK-LABEL: const_v2i64:
368; NO-SIMD128-NOT: i64x2
369; SIMD128-VM-NOT: i64x2
370; SIMD128: .result v128{{$}}
371; SIMD128: v128.const $push0=, 506097522914230528, 1084818905618843912
372; SIMD128-SAME: # encoding: [0xfd,0x00,
373; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
374; SIMD128-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]{{$}}
375define <2 x i64> @const_v2i64() {
376 ret <2 x i64> <i64 506097522914230528, i64 1084818905618843912>
377}
378
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000379; CHECK-LABEL: splat_v2i64:
380; NO-SIMD128-NOT: i64x2
381; SIMD128-VM-NOT: i64x2
382; SIMD128: .param i64{{$}}
383; SIMD128: .result v128{{$}}
384; SIMD128: i64x2.splat $push0=, $0 # encoding: [0xfd,0x06]{{$}}
385; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
386define <2 x i64> @splat_v2i64(i64 %x) {
387 %t1 = insertelement <2 x i64> zeroinitializer, i64 %x, i32 0
388 %res = insertelement <2 x i64> %t1, i64 %x, i32 1
389 ret <2 x i64> %res
390}
391
Thomas Lively1b55b2b2018-09-04 21:26:17 +0000392; CHECK-LABEL: const_splat_v2i64:
393; SIMD128; i64x2.splat
394define <2 x i64> @const_splat_v2i64() {
395 ret <2 x i64> <i64 42, i64 42>
396}
397
Heejin Ahnc15a8782018-08-14 19:10:50 +0000398; CHECK-LABEL: extract_v2i64:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000399; NO-SIMD128-NOT: i64x2
400; SIMD128-VM-NOT: i64x2
401; SIMD128: .param v128{{$}}
402; SIMD128: .result i64{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +0000403; SIMD128: i64x2.extract_lane $push0=, $0, 1 # encoding: [0xfd,0x0e,0x01]{{$}}
404; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000405define i64 @extract_v2i64(<2 x i64> %v) {
406 %elem = extractelement <2 x i64> %v, i64 1
407 ret i64 %elem
408}
409
Derek Schuff82812fb2018-08-15 16:18:51 +0000410; CHECK-LABEL: replace_v2i64:
411; NO-SIMD128-NOT: i64x2
412; SIMD128-VM-NOT: i64x2
413; SIMD128: .param v128, i64{{$}}
414; SIMD128: .result v128{{$}}
415; SIMD128: i64x2.replace_lane $push0=, $0, 0, $1 # encoding: [0xfd,0x14,0x00]{{$}}
416; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
417define <2 x i64> @replace_v2i64(<2 x i64> %v, i64 %x) {
418 %res = insertelement <2 x i64> %v, i64 %x, i32 0
419 ret <2 x i64> %res
420}
421
Thomas Livelya0d25812018-09-07 21:54:46 +0000422; CHECK-LABEL: shuffle_v2i64:
423; NO-SIMD128-NOT: v8x16
424; SIMD128: .param v128, v128{{$}}
425; SIMD128: .result v128{{$}}
426; SIMD128: v8x16.shuffle $push0=, $0, $1,
427; SIMD128-SAME: 0, 1, 2, 3, 4, 5, 6, 7, 24, 25, 26, 27, 28, 29, 30, 31
428; SIMD128-SAME: # encoding: [0xfd,0x17,
429; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
430; SIMD128-SAME: 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f]
431; SIMD128: return $pop0 #
432define <2 x i64> @shuffle_v2i64(<2 x i64> %x, <2 x i64> %y) {
433 %res = shufflevector <2 x i64> %x, <2 x i64> %y, <2 x i32> <i32 0, i32 3>
434 ret <2 x i64> %res
435}
436
Thomas Lively2ee686d2018-08-22 23:06:27 +0000437; CHECK-LABEL: build_v2i64:
438; NO-SIMD128-NOT: i64x2
439; SIMD128-VM-NOT: i64x2
440; SIMD128: .param i64, i64{{$}}
441; SIMD128: .result v128{{$}}
442; SIMD128: i64x2.splat $push0=, $0 # encoding: [0xfd,0x06]
443; SIMD128: i64x2.replace_lane $push1=, $pop0, 1, $1 # encoding: [0xfd,0x14,0x01]
444; SIMD128: return $pop1 # encoding: [0x0f]
445define <2 x i64> @build_v2i64(i64 %x0, i64 %x1) {
446 %t0 = insertelement <2 x i64> undef, i64 %x0, i32 0
447 %res = insertelement <2 x i64> %t0, i64 %x1, i32 1
448 ret <2 x i64> %res
449}
450
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000451; ==============================================================================
452; 4 x f32
453; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000454; CHECK-LABEL: const_v4f32:
455; NO-SIMD128-NOT: f32x4
456; SIMD128: .result v128{{$}}
457; SIMD128: v128.const $push0=,
458; SIMD128-SAME: 0x1.0402p-121, 0x1.0c0a08p-113, 0x1.14121p-105, 0x1.1c1a18p-97
459; SIMD128-SAME: # encoding: [0xfd,0x00,
460; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
461; SIMD128-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]{{$}}
462define <4 x float> @const_v4f32() {
463 ret <4 x float> <float 0x3860402000000000, float 0x38e0c0a080000000,
464 float 0x3961412100000000, float 0x39e1c1a180000000>
465}
466
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000467; CHECK-LABEL: splat_v4f32:
468; NO-SIMD128-NOT: f32x4
469; SIMD128: .param f32{{$}}
470; SIMD128: .result v128{{$}}
471; SIMD128: f32x4.splat $push0=, $0 # encoding: [0xfd,0x07]{{$}}
472; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
473define <4 x float> @splat_v4f32(float %x) {
474 %v = insertelement <4 x float> undef, float %x, i32 0
475 %res = shufflevector <4 x float> %v, <4 x float> undef,
476 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
477 ret <4 x float> %res
478}
479
Thomas Livelyda26b842018-08-23 19:23:13 +0000480; CHECK-LABEL: const_splat_v4f32
481; SIMD128; f32x4.splat
482define <4 x float> @const_splat_v4f32() {
483 ret <4 x float> <float 42., float 42., float 42., float 42.>
484}
485
Heejin Ahnc15a8782018-08-14 19:10:50 +0000486; CHECK-LABEL: extract_v4f32:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000487; NO-SIMD128-NOT: f32x4
488; SIMD128: .param v128{{$}}
489; SIMD128: .result f32{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +0000490; SIMD128: f32x4.extract_lane $push0=, $0, 3 # encoding: [0xfd,0x0f,0x03]{{$}}
491; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000492define float @extract_v4f32(<4 x float> %v) {
493 %elem = extractelement <4 x float> %v, i32 3
494 ret float %elem
495}
496
Derek Schuff82812fb2018-08-15 16:18:51 +0000497; CHECK-LABEL: replace_v4f32:
498; NO-SIMD128-NOT: f32x4
499; SIMD128: .param v128, f32{{$}}
500; SIMD128: .result v128{{$}}
501; SIMD128: f32x4.replace_lane $push0=, $0, 2, $1 # encoding: [0xfd,0x15,0x02]{{$}}
502; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
503define <4 x float> @replace_v4f32(<4 x float> %v, float %x) {
504 %res = insertelement <4 x float> %v, float %x, i32 2
505 ret <4 x float> %res
506}
507
Thomas Livelya0d25812018-09-07 21:54:46 +0000508; CHECK-LABEL: shuffle_v4f32:
509; NO-SIMD128-NOT: v8x16
510; SIMD128: .param v128, v128{{$}}
511; SIMD128: .result v128{{$}}
512; SIMD128: v8x16.shuffle $push0=, $0, $1,
513; SIMD128-SAME: 0, 1, 2, 3, 20, 21, 22, 23, 8, 9, 10, 11, 28, 29, 30, 31
514; SIMD128-SAME: # encoding: [0xfd,0x17,
515; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x14,0x15,0x16,0x17,
516; SIMD128-SAME: 0x08,0x09,0x0a,0x0b,0x1c,0x1d,0x1e,0x1f]
517; SIMD128: return $pop0 #
518define <4 x float> @shuffle_v4f32(<4 x float> %x, <4 x float> %y) {
519 %res = shufflevector <4 x float> %x, <4 x float> %y,
520 <4 x i32> <i32 0, i32 5, i32 2, i32 7>
521 ret <4 x float> %res
522}
523
Thomas Lively2ee686d2018-08-22 23:06:27 +0000524; CHECK-LABEL: build_v4f32:
525; NO-SIMD128-NOT: f32x4
526; SIMD128: .param f32, f32, f32, f32{{$}}
527; SIMD128: .result v128{{$}}
528; SIMD128: f32x4.splat $push0=, $0 # encoding: [0xfd,0x07]
529; SIMD128: f32x4.replace_lane $push1=, $pop0, 1, $1 # encoding: [0xfd,0x15,0x01]
530; SIMD128: f32x4.replace_lane $push2=, $pop1, 2, $2 # encoding: [0xfd,0x15,0x02]
531; SIMD128: f32x4.replace_lane $push3=, $pop2, 3, $3 # encoding: [0xfd,0x15,0x03]
532; SIMD128: return $pop3 # encoding: [0x0f]
533define <4 x float> @build_v4f32(float %x0, float %x1, float %x2, float %x3) {
534 %t0 = insertelement <4 x float> undef, float %x0, i32 0
535 %t1 = insertelement <4 x float> %t0, float %x1, i32 1
536 %t2 = insertelement <4 x float> %t1, float %x2, i32 2
537 %res = insertelement <4 x float> %t2, float %x3, i32 3
538 ret <4 x float> %res
539}
540
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000541; ==============================================================================
542; 2 x f64
543; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000544; CHECK-LABEL: const_v2f64:
545; NO-SIMD128-NOT: f64x2
546; SIMD128: .result v128{{$}}
547; SIMD128: v128.const $push0=, 0x1.60504030201p-911, 0x1.e0d0c0b0a0908p-783
548; SIMD128-SAME: # encoding: [0xfd,0x00,
549; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
550; SIMD128-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]{{$}}
551define <2 x double> @const_v2f64() {
552 ret <2 x double> <double 0x0706050403020100, double 0x0F0E0D0C0B0A0908>
553}
554
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000555; CHECK-LABEL: splat_v2f64:
556; NO-SIMD128-NOT: f64x2
557; SIMD128-VM-NOT: f64x2
558; SIMD128: .param f64{{$}}
559; SIMD128: .result v128{{$}}
560; SIMD128: f64x2.splat $push0=, $0 # encoding: [0xfd,0x08]{{$}}
561; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
562define <2 x double> @splat_v2f64(double %x) {
563 %t1 = insertelement <2 x double> zeroinitializer, double %x, i3 0
564 %res = insertelement <2 x double> %t1, double %x, i32 1
565 ret <2 x double> %res
566}
567
Thomas Livelyda26b842018-08-23 19:23:13 +0000568; CHECK-LABEL: const_splat_v2f64:
569; SIMD128; f64x2.splat
570define <2 x double> @const_splat_v2f64() {
571 ret <2 x double> <double 42., double 42.>
572}
573
Heejin Ahnc15a8782018-08-14 19:10:50 +0000574; CHECK-LABEL: extract_v2f64:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000575; NO-SIMD128-NOT: f64x2
576; SIMD128-VM-NOT: f64x2
577; SIMD128: .param v128{{$}}
578; SIMD128: .result f64{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +0000579; SIMD128: f64x2.extract_lane $push0=, $0, 1 # encoding: [0xfd,0x10,0x01]{{$}}
580; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000581define double @extract_v2f64(<2 x double> %v) {
582 %elem = extractelement <2 x double> %v, i32 1
583 ret double %elem
584}
Derek Schuff82812fb2018-08-15 16:18:51 +0000585
586; CHECK-LABEL: replace_v2f64:
587; NO-SIMD128-NOT: f64x2
588; SIMD128-VM-NOT: f64x2
589; SIMD128: .param v128, f64{{$}}
590; SIMD128: .result v128{{$}}
591; SIMD128: f64x2.replace_lane $push0=, $0, 0, $1 # encoding: [0xfd,0x16,0x00]{{$}}
592; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
593define <2 x double> @replace_v2f64(<2 x double> %v, double %x) {
594 %res = insertelement <2 x double> %v, double %x, i32 0
595 ret <2 x double> %res
596}
Thomas Lively2ee686d2018-08-22 23:06:27 +0000597
Thomas Livelya0d25812018-09-07 21:54:46 +0000598; CHECK-LABEL: shuffle_v2f64:
599; NO-SIMD128-NOT: v8x16
600; SIMD128: .param v128, v128{{$}}
601; SIMD128: .result v128{{$}}
602; SIMD128: v8x16.shuffle $push0=, $0, $1,
603; SIMD128-SAME: 0, 1, 2, 3, 4, 5, 6, 7, 24, 25, 26, 27, 28, 29, 30, 31
604; SIMD128-SAME: # encoding: [0xfd,0x17,
605; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
606; SIMD128-SAME: 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f]
607; SIMD128: return $pop0 #
608define <2 x double> @shuffle_v2f64(<2 x double> %x, <2 x double> %y) {
609 %res = shufflevector <2 x double> %x, <2 x double> %y,
610 <2 x i32> <i32 0, i32 3>
611 ret <2 x double> %res
612}
613
Thomas Lively2ee686d2018-08-22 23:06:27 +0000614; CHECK-LABEL: build_v2f64:
615; NO-SIMD128-NOT: f64x2
616; SIMD128-VM-NOT: f64x2
617; SIMD128: .param f64, f64{{$}}
618; SIMD128: .result v128{{$}}
619; SIMD128: f64x2.splat $push0=, $0 # encoding: [0xfd,0x08]
620; SIMD128: f64x2.replace_lane $push1=, $pop0, 1, $1 # encoding: [0xfd,0x16,0x01]
621; SIMD128: return $pop1 # encoding: [0x0f]
622define <2 x double> @build_v2f64(double %x0, double %x1) {
623 %t0 = insertelement <2 x double> undef, double %x0, i32 0
624 %res = insertelement <2 x double> %t0, double %x1, i32 1
625 ret <2 x double> %res
626}