blob: 7a12b29f2371c1b1c8d27d0559efb2361210dcdb [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 Lively2ee686d2018-08-22 23:06:27 +000093; CHECK-LABEL: build_v16i8:
94; NO-SIMD128-NOT: i8x16
95; SIMD128: .param i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32{{$}}
96; SIMD128: .result v128{{$}}
97; SIMD128: i8x16.splat $push0=, $0 # encoding: [0xfd,0x03]
98; SIMD128: i8x16.replace_lane $push1=, $pop0, 1, $1 # encoding: [0xfd,0x11,0x01]
99; SIMD128: i8x16.replace_lane $push2=, $pop1, 2, $2 # encoding: [0xfd,0x11,0x02]
100; SIMD128: i8x16.replace_lane $push3=, $pop2, 3, $3 # encoding: [0xfd,0x11,0x03]
101; SIMD128: i8x16.replace_lane $push4=, $pop3, 4, $4 # encoding: [0xfd,0x11,0x04]
102; SIMD128: i8x16.replace_lane $push5=, $pop4, 5, $5 # encoding: [0xfd,0x11,0x05]
103; SIMD128: i8x16.replace_lane $push6=, $pop5, 6, $6 # encoding: [0xfd,0x11,0x06]
104; SIMD128: i8x16.replace_lane $push7=, $pop6, 7, $7 # encoding: [0xfd,0x11,0x07]
105; SIMD128: i8x16.replace_lane $push8=, $pop7, 8, $8 # encoding: [0xfd,0x11,0x08]
106; SIMD128: i8x16.replace_lane $push9=, $pop8, 9, $9 # encoding: [0xfd,0x11,0x09]
107; SIMD128: i8x16.replace_lane $push10=, $pop9, 10, $10 # encoding: [0xfd,0x11,0x0a]
108; SIMD128: i8x16.replace_lane $push11=, $pop10, 11, $11 # encoding: [0xfd,0x11,0x0b]
109; SIMD128: i8x16.replace_lane $push12=, $pop11, 12, $12 # encoding: [0xfd,0x11,0x0c]
110; SIMD128: i8x16.replace_lane $push13=, $pop12, 13, $13 # encoding: [0xfd,0x11,0x0d]
111; SIMD128: i8x16.replace_lane $push14=, $pop13, 14, $14 # encoding: [0xfd,0x11,0x0e]
112; SIMD128: i8x16.replace_lane $push15=, $pop14, 15, $15 # encoding: [0xfd,0x11,0x0f]
113; SIMD128: return $pop15 # encoding: [0x0f]
114define <16 x i8> @build_v16i8(i8 %x0, i8 %x1, i8 %x2, i8 %x3,
115 i8 %x4, i8 %x5, i8 %x6, i8 %x7,
116 i8 %x8, i8 %x9, i8 %x10, i8 %x11,
117 i8 %x12, i8 %x13, i8 %x14, i8 %x15) {
118 %t0 = insertelement <16 x i8> undef, i8 %x0, i32 0
119 %t1 = insertelement <16 x i8> %t0, i8 %x1, i32 1
120 %t2 = insertelement <16 x i8> %t1, i8 %x2, i32 2
121 %t3 = insertelement <16 x i8> %t2, i8 %x3, i32 3
122 %t4 = insertelement <16 x i8> %t3, i8 %x4, i32 4
123 %t5 = insertelement <16 x i8> %t4, i8 %x5, i32 5
124 %t6 = insertelement <16 x i8> %t5, i8 %x6, i32 6
125 %t7 = insertelement <16 x i8> %t6, i8 %x7, i32 7
126 %t8 = insertelement <16 x i8> %t7, i8 %x8, i32 8
127 %t9 = insertelement <16 x i8> %t8, i8 %x9, i32 9
128 %t10 = insertelement <16 x i8> %t9, i8 %x10, i32 10
129 %t11 = insertelement <16 x i8> %t10, i8 %x11, i32 11
130 %t12 = insertelement <16 x i8> %t11, i8 %x12, i32 12
131 %t13 = insertelement <16 x i8> %t12, i8 %x13, i32 13
132 %t14 = insertelement <16 x i8> %t13, i8 %x14, i32 14
133 %res = insertelement <16 x i8> %t14, i8 %x15, i32 15
134 ret <16 x i8> %res
135}
136
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000137; ==============================================================================
138; 8 x i16
139; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000140; CHECK-LABEL: const_v8i16:
141; NO-SIMD128-NOT: i16x8
142; SIMD128: .result v128{{$}}
143; SIMD128: v128.const $push0=, 256, 770, 1284, 1798, 2312, 2826, 3340, 3854
144; SIMD128-SAME: # encoding: [0xfd,0x00,
145; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
146; SIMD128-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]{{$}}
147define <8 x i16> @const_v8i16() {
148 ret <8 x i16> <i16 256, i16 770, i16 1284, i16 1798,
149 i16 2312, i16 2826, i16 3340, i16 3854>
150}
151
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000152; CHECK-LABEL: splat_v8i16:
153; NO-SIMD128-NOT: i16x8
154; SIMD128: .param i32{{$}}
155; SIMD128: .result v128{{$}}
156; SIMD128: i16x8.splat $push0=, $0 # encoding: [0xfd,0x04]{{$}}
157; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
158define <8 x i16> @splat_v8i16(i16 %x) {
159 %v = insertelement <8 x i16> undef, i16 %x, i32 0
160 %res = shufflevector <8 x i16> %v, <8 x i16> undef,
161 <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
162 ret <8 x i16> %res
163}
164
Thomas Livelycfab8b42018-09-04 21:51:32 +0000165; CHECK-LABEL: const_splat_v8i16:
Thomas Livelyda26b842018-08-23 19:23:13 +0000166; SIMD128; i16x8.splat
167define <8 x i16> @const_splat_v8i16() {
168 ret <8 x i16> <i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42>
169}
170
Heejin Ahnc15a8782018-08-14 19:10:50 +0000171; CHECK-LABEL: extract_v8i16_s:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000172; NO-SIMD128-NOT: i16x8
173; SIMD128: .param v128{{$}}
174; SIMD128: .result i32{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +0000175; SIMD128: i16x8.extract_lane_s $push0=, $0, 5 # encoding: [0xfd,0x0b,0x05]{{$}}
176; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000177define i32 @extract_v8i16_s(<8 x i16> %v) {
178 %elem = extractelement <8 x i16> %v, i16 5
179 %a = sext i16 %elem to i32
180 ret i32 %a
181}
182
Heejin Ahnc15a8782018-08-14 19:10:50 +0000183; CHECK-LABEL: extract_v8i16_u:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000184; NO-SIMD128-NOT: i16x8
185; SIMD128: .param v128{{$}}
186; SIMD128: .result i32{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +0000187; SIMD128: i16x8.extract_lane_u $push0=, $0, 5 # encoding: [0xfd,0x0c,0x05]{{$}}
188; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000189define i32 @extract_v8i16_u(<8 x i16> %v) {
190 %elem = extractelement <8 x i16> %v, i16 5
191 %a = zext i16 %elem to i32
192 ret i32 %a
193}
194
Heejin Ahnc15a8782018-08-14 19:10:50 +0000195; CHECK-LABEL: extract_v8i16:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000196; NO-SIMD128-NOT: i16x8
197; SIMD128: .param v128{{$}}
198; SIMD128: .result i32{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +0000199; SIMD128: i16x8.extract_lane_u $push0=, $0, 5 # encoding: [0xfd,0x0c,0x05]{{$}}
200; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000201define i16 @extract_v8i16(<8 x i16> %v) {
202 %elem = extractelement <8 x i16> %v, i16 5
203 ret i16 %elem
204}
205
Derek Schuff82812fb2018-08-15 16:18:51 +0000206; CHECK-LABEL: replace_v8i16:
207; NO-SIMD128-NOT: i16x8
208; SIMD128: .param v128, i32{{$}}
209; SIMD128: .result v128{{$}}
210; SIMD128: i16x8.replace_lane $push0=, $0, 7, $1 # encoding: [0xfd,0x12,0x07]{{$}}
211; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
212define <8 x i16> @replace_v8i16(<8 x i16> %v, i16 %x) {
213 %res = insertelement <8 x i16> %v, i16 %x, i32 7
214 ret <8 x i16> %res
215}
216
Thomas Lively2ee686d2018-08-22 23:06:27 +0000217; CHECK-LABEL: build_v8i16:
218; NO-SIMD128-NOT: i16x8
219; SIMD128: .param i32, i32, i32, i32, i32, i32, i32, i32{{$}}
220; SIMD128: .result v128{{$}}
221; SIMD128: i16x8.splat $push0=, $0 # encoding: [0xfd,0x04]
222; SIMD128: i16x8.replace_lane $push1=, $pop0, 1, $1 # encoding: [0xfd,0x12,0x01]
223; SIMD128: i16x8.replace_lane $push2=, $pop1, 2, $2 # encoding: [0xfd,0x12,0x02]
224; SIMD128: i16x8.replace_lane $push3=, $pop2, 3, $3 # encoding: [0xfd,0x12,0x03]
225; SIMD128: i16x8.replace_lane $push4=, $pop3, 4, $4 # encoding: [0xfd,0x12,0x04]
226; SIMD128: i16x8.replace_lane $push5=, $pop4, 5, $5 # encoding: [0xfd,0x12,0x05]
227; SIMD128: i16x8.replace_lane $push6=, $pop5, 6, $6 # encoding: [0xfd,0x12,0x06]
228; SIMD128: i16x8.replace_lane $push7=, $pop6, 7, $7 # encoding: [0xfd,0x12,0x07]
229; SIMD128: return $pop7 # encoding: [0x0f]
230define <8 x i16> @build_v8i16(i16 %x0, i16 %x1, i16 %x2, i16 %x3,
231 i16 %x4, i16 %x5, i16 %x6, i16 %x7) {
232 %t0 = insertelement <8 x i16> undef, i16 %x0, i32 0
233 %t1 = insertelement <8 x i16> %t0, i16 %x1, i32 1
234 %t2 = insertelement <8 x i16> %t1, i16 %x2, i32 2
235 %t3 = insertelement <8 x i16> %t2, i16 %x3, i32 3
236 %t4 = insertelement <8 x i16> %t3, i16 %x4, i32 4
237 %t5 = insertelement <8 x i16> %t4, i16 %x5, i32 5
238 %t6 = insertelement <8 x i16> %t5, i16 %x6, i32 6
239 %res = insertelement <8 x i16> %t6, i16 %x7, i32 7
240 ret <8 x i16> %res
241}
242
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000243; ==============================================================================
244; 4 x i32
245; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000246; CHECK-LABEL: const_v4i32:
247; NO-SIMD128-NOT: i32x4
248; SIMD128: .result v128{{$}}
249; SIMD128: v128.const $push0=, 50462976, 117835012, 185207048, 252579084
250; SIMD128-SAME: # encoding: [0xfd,0x00,
251; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
252; SIMD128-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]{{$}}
253define <4 x i32> @const_v4i32() {
254 ret <4 x i32> <i32 50462976, i32 117835012, i32 185207048, i32 252579084>
255}
256
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000257; CHECK-LABEL: splat_v4i32:
258; NO-SIMD128-NOT: i32x4
259; SIMD128: .param i32{{$}}
260; SIMD128: .result v128{{$}}
261; SIMD128: i32x4.splat $push0=, $0 # encoding: [0xfd,0x05]{{$}}
262; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
263define <4 x i32> @splat_v4i32(i32 %x) {
264 %v = insertelement <4 x i32> undef, i32 %x, i32 0
265 %res = shufflevector <4 x i32> %v, <4 x i32> undef,
266 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
267 ret <4 x i32> %res
268}
269
Thomas Lively1b55b2b2018-09-04 21:26:17 +0000270; CHECK-LABEL: const_splat_v4i32:
Thomas Livelyda26b842018-08-23 19:23:13 +0000271; SIMD128; i32x4.splat
272define <4 x i32> @const_splat_v4i32() {
273 ret <4 x i32> <i32 42, i32 42, i32 42, i32 42>
274}
275
Heejin Ahnc15a8782018-08-14 19:10:50 +0000276; CHECK-LABEL: extract_v4i32:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000277; NO-SIMD128-NOT: i32x4
278; SIMD128: .param v128{{$}}
279; SIMD128: .result i32{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +0000280; SIMD128: i32x4.extract_lane $push0=, $0, 3 # encoding: [0xfd,0x0d,0x03]{{$}}
281; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000282define i32 @extract_v4i32(<4 x i32> %v) {
283 %elem = extractelement <4 x i32> %v, i32 3
284 ret i32 %elem
285}
286
Derek Schuff82812fb2018-08-15 16:18:51 +0000287; CHECK-LABEL: replace_v4i32:
288; NO-SIMD128-NOT: i32x4
289; SIMD128: .param v128, i32{{$}}
290; SIMD128: .result v128{{$}}
291; SIMD128: i32x4.replace_lane $push0=, $0, 2, $1 # encoding: [0xfd,0x13,0x02]{{$}}
292; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
293define <4 x i32> @replace_v4i32(<4 x i32> %v, i32 %x) {
294 %res = insertelement <4 x i32> %v, i32 %x, i32 2
295 ret <4 x i32> %res
296}
297
Thomas Lively2ee686d2018-08-22 23:06:27 +0000298; CHECK-LABEL: build_v4i32:
299; NO-SIMD128-NOT: i32x4
300; SIMD128: .param i32, i32, i32, i32{{$}}
301; SIMD128: .result v128{{$}}
302; SIMD128: i32x4.splat $push0=, $0 # encoding: [0xfd,0x05]
303; SIMD128: i32x4.replace_lane $push1=, $pop0, 1, $1 # encoding: [0xfd,0x13,0x01]
304; SIMD128: i32x4.replace_lane $push2=, $pop1, 2, $2 # encoding: [0xfd,0x13,0x02]
305; SIMD128: i32x4.replace_lane $push3=, $pop2, 3, $3 # encoding: [0xfd,0x13,0x03]
306; SIMD128: return $pop3 # encoding: [0x0f]
307define <4 x i32> @build_v4i32(i32 %x0, i32 %x1, i32 %x2, i32 %x3) {
308 %t0 = insertelement <4 x i32> undef, i32 %x0, i32 0
309 %t1 = insertelement <4 x i32> %t0, i32 %x1, i32 1
310 %t2 = insertelement <4 x i32> %t1, i32 %x2, i32 2
311 %res = insertelement <4 x i32> %t2, i32 %x3, i32 3
312 ret <4 x i32> %res
313}
314
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000315; ==============================================================================
316; 2 x i64
317; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000318; CHECK-LABEL: const_v2i64:
319; NO-SIMD128-NOT: i64x2
320; SIMD128-VM-NOT: i64x2
321; SIMD128: .result v128{{$}}
322; SIMD128: v128.const $push0=, 506097522914230528, 1084818905618843912
323; SIMD128-SAME: # encoding: [0xfd,0x00,
324; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
325; SIMD128-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]{{$}}
326define <2 x i64> @const_v2i64() {
327 ret <2 x i64> <i64 506097522914230528, i64 1084818905618843912>
328}
329
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000330; CHECK-LABEL: splat_v2i64:
331; NO-SIMD128-NOT: i64x2
332; SIMD128-VM-NOT: i64x2
333; SIMD128: .param i64{{$}}
334; SIMD128: .result v128{{$}}
335; SIMD128: i64x2.splat $push0=, $0 # encoding: [0xfd,0x06]{{$}}
336; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
337define <2 x i64> @splat_v2i64(i64 %x) {
338 %t1 = insertelement <2 x i64> zeroinitializer, i64 %x, i32 0
339 %res = insertelement <2 x i64> %t1, i64 %x, i32 1
340 ret <2 x i64> %res
341}
342
Thomas Lively1b55b2b2018-09-04 21:26:17 +0000343; CHECK-LABEL: const_splat_v2i64:
344; SIMD128; i64x2.splat
345define <2 x i64> @const_splat_v2i64() {
346 ret <2 x i64> <i64 42, i64 42>
347}
348
Heejin Ahnc15a8782018-08-14 19:10:50 +0000349; CHECK-LABEL: extract_v2i64:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000350; NO-SIMD128-NOT: i64x2
351; SIMD128-VM-NOT: i64x2
352; SIMD128: .param v128{{$}}
353; SIMD128: .result i64{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +0000354; SIMD128: i64x2.extract_lane $push0=, $0, 1 # encoding: [0xfd,0x0e,0x01]{{$}}
355; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000356define i64 @extract_v2i64(<2 x i64> %v) {
357 %elem = extractelement <2 x i64> %v, i64 1
358 ret i64 %elem
359}
360
Derek Schuff82812fb2018-08-15 16:18:51 +0000361; CHECK-LABEL: replace_v2i64:
362; NO-SIMD128-NOT: i64x2
363; SIMD128-VM-NOT: i64x2
364; SIMD128: .param v128, i64{{$}}
365; SIMD128: .result v128{{$}}
366; SIMD128: i64x2.replace_lane $push0=, $0, 0, $1 # encoding: [0xfd,0x14,0x00]{{$}}
367; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
368define <2 x i64> @replace_v2i64(<2 x i64> %v, i64 %x) {
369 %res = insertelement <2 x i64> %v, i64 %x, i32 0
370 ret <2 x i64> %res
371}
372
Thomas Lively2ee686d2018-08-22 23:06:27 +0000373; CHECK-LABEL: build_v2i64:
374; NO-SIMD128-NOT: i64x2
375; SIMD128-VM-NOT: i64x2
376; SIMD128: .param i64, i64{{$}}
377; SIMD128: .result v128{{$}}
378; SIMD128: i64x2.splat $push0=, $0 # encoding: [0xfd,0x06]
379; SIMD128: i64x2.replace_lane $push1=, $pop0, 1, $1 # encoding: [0xfd,0x14,0x01]
380; SIMD128: return $pop1 # encoding: [0x0f]
381define <2 x i64> @build_v2i64(i64 %x0, i64 %x1) {
382 %t0 = insertelement <2 x i64> undef, i64 %x0, i32 0
383 %res = insertelement <2 x i64> %t0, i64 %x1, i32 1
384 ret <2 x i64> %res
385}
386
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000387; ==============================================================================
388; 4 x f32
389; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000390; CHECK-LABEL: const_v4f32:
391; NO-SIMD128-NOT: f32x4
392; SIMD128: .result v128{{$}}
393; SIMD128: v128.const $push0=,
394; SIMD128-SAME: 0x1.0402p-121, 0x1.0c0a08p-113, 0x1.14121p-105, 0x1.1c1a18p-97
395; SIMD128-SAME: # encoding: [0xfd,0x00,
396; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
397; SIMD128-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]{{$}}
398define <4 x float> @const_v4f32() {
399 ret <4 x float> <float 0x3860402000000000, float 0x38e0c0a080000000,
400 float 0x3961412100000000, float 0x39e1c1a180000000>
401}
402
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000403; CHECK-LABEL: splat_v4f32:
404; NO-SIMD128-NOT: f32x4
405; SIMD128: .param f32{{$}}
406; SIMD128: .result v128{{$}}
407; SIMD128: f32x4.splat $push0=, $0 # encoding: [0xfd,0x07]{{$}}
408; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
409define <4 x float> @splat_v4f32(float %x) {
410 %v = insertelement <4 x float> undef, float %x, i32 0
411 %res = shufflevector <4 x float> %v, <4 x float> undef,
412 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
413 ret <4 x float> %res
414}
415
Thomas Livelyda26b842018-08-23 19:23:13 +0000416; CHECK-LABEL: const_splat_v4f32
417; SIMD128; f32x4.splat
418define <4 x float> @const_splat_v4f32() {
419 ret <4 x float> <float 42., float 42., float 42., float 42.>
420}
421
Heejin Ahnc15a8782018-08-14 19:10:50 +0000422; CHECK-LABEL: extract_v4f32:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000423; NO-SIMD128-NOT: f32x4
424; SIMD128: .param v128{{$}}
425; SIMD128: .result f32{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +0000426; SIMD128: f32x4.extract_lane $push0=, $0, 3 # encoding: [0xfd,0x0f,0x03]{{$}}
427; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000428define float @extract_v4f32(<4 x float> %v) {
429 %elem = extractelement <4 x float> %v, i32 3
430 ret float %elem
431}
432
Derek Schuff82812fb2018-08-15 16:18:51 +0000433; CHECK-LABEL: replace_v4f32:
434; NO-SIMD128-NOT: f32x4
435; SIMD128: .param v128, f32{{$}}
436; SIMD128: .result v128{{$}}
437; SIMD128: f32x4.replace_lane $push0=, $0, 2, $1 # encoding: [0xfd,0x15,0x02]{{$}}
438; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
439define <4 x float> @replace_v4f32(<4 x float> %v, float %x) {
440 %res = insertelement <4 x float> %v, float %x, i32 2
441 ret <4 x float> %res
442}
443
Thomas Lively2ee686d2018-08-22 23:06:27 +0000444; CHECK-LABEL: build_v4f32:
445; NO-SIMD128-NOT: f32x4
446; SIMD128: .param f32, f32, f32, f32{{$}}
447; SIMD128: .result v128{{$}}
448; SIMD128: f32x4.splat $push0=, $0 # encoding: [0xfd,0x07]
449; SIMD128: f32x4.replace_lane $push1=, $pop0, 1, $1 # encoding: [0xfd,0x15,0x01]
450; SIMD128: f32x4.replace_lane $push2=, $pop1, 2, $2 # encoding: [0xfd,0x15,0x02]
451; SIMD128: f32x4.replace_lane $push3=, $pop2, 3, $3 # encoding: [0xfd,0x15,0x03]
452; SIMD128: return $pop3 # encoding: [0x0f]
453define <4 x float> @build_v4f32(float %x0, float %x1, float %x2, float %x3) {
454 %t0 = insertelement <4 x float> undef, float %x0, i32 0
455 %t1 = insertelement <4 x float> %t0, float %x1, i32 1
456 %t2 = insertelement <4 x float> %t1, float %x2, i32 2
457 %res = insertelement <4 x float> %t2, float %x3, i32 3
458 ret <4 x float> %res
459}
460
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000461; ==============================================================================
462; 2 x f64
463; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000464; CHECK-LABEL: const_v2f64:
465; NO-SIMD128-NOT: f64x2
466; SIMD128: .result v128{{$}}
467; SIMD128: v128.const $push0=, 0x1.60504030201p-911, 0x1.e0d0c0b0a0908p-783
468; SIMD128-SAME: # encoding: [0xfd,0x00,
469; SIMD128-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
470; SIMD128-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]{{$}}
471define <2 x double> @const_v2f64() {
472 ret <2 x double> <double 0x0706050403020100, double 0x0F0E0D0C0B0A0908>
473}
474
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000475; CHECK-LABEL: splat_v2f64:
476; NO-SIMD128-NOT: f64x2
477; SIMD128-VM-NOT: f64x2
478; SIMD128: .param f64{{$}}
479; SIMD128: .result v128{{$}}
480; SIMD128: f64x2.splat $push0=, $0 # encoding: [0xfd,0x08]{{$}}
481; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
482define <2 x double> @splat_v2f64(double %x) {
483 %t1 = insertelement <2 x double> zeroinitializer, double %x, i3 0
484 %res = insertelement <2 x double> %t1, double %x, i32 1
485 ret <2 x double> %res
486}
487
Thomas Livelyda26b842018-08-23 19:23:13 +0000488; CHECK-LABEL: const_splat_v2f64:
489; SIMD128; f64x2.splat
490define <2 x double> @const_splat_v2f64() {
491 ret <2 x double> <double 42., double 42.>
492}
493
Heejin Ahnc15a8782018-08-14 19:10:50 +0000494; CHECK-LABEL: extract_v2f64:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000495; NO-SIMD128-NOT: f64x2
496; SIMD128-VM-NOT: f64x2
497; SIMD128: .param v128{{$}}
498; SIMD128: .result f64{{$}}
Heejin Ahnc15a8782018-08-14 19:10:50 +0000499; SIMD128: f64x2.extract_lane $push0=, $0, 1 # encoding: [0xfd,0x10,0x01]{{$}}
500; SIMD128: return $pop0 #
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000501define double @extract_v2f64(<2 x double> %v) {
502 %elem = extractelement <2 x double> %v, i32 1
503 ret double %elem
504}
Derek Schuff82812fb2018-08-15 16:18:51 +0000505
506; CHECK-LABEL: replace_v2f64:
507; NO-SIMD128-NOT: f64x2
508; SIMD128-VM-NOT: f64x2
509; SIMD128: .param v128, f64{{$}}
510; SIMD128: .result v128{{$}}
511; SIMD128: f64x2.replace_lane $push0=, $0, 0, $1 # encoding: [0xfd,0x16,0x00]{{$}}
512; SIMD128: return $pop0 # encoding: [0x0f]{{$}}
513define <2 x double> @replace_v2f64(<2 x double> %v, double %x) {
514 %res = insertelement <2 x double> %v, double %x, i32 0
515 ret <2 x double> %res
516}
Thomas Lively2ee686d2018-08-22 23:06:27 +0000517
518; CHECK-LABEL: build_v2f64:
519; NO-SIMD128-NOT: f64x2
520; SIMD128-VM-NOT: f64x2
521; SIMD128: .param f64, f64{{$}}
522; SIMD128: .result v128{{$}}
523; SIMD128: f64x2.splat $push0=, $0 # encoding: [0xfd,0x08]
524; SIMD128: f64x2.replace_lane $push1=, $pop0, 1, $1 # encoding: [0xfd,0x16,0x01]
525; SIMD128: return $pop1 # encoding: [0x0f]
526define <2 x double> @build_v2f64(double %x0, double %x1) {
527 %t0 = insertelement <2 x double> undef, double %x0, i32 0
528 %res = insertelement <2 x double> %t0, double %x1, i32 1
529 ret <2 x double> %res
530}