blob: 35f77c0da55236e40de98e7610855cd17b1a43ea [file] [log] [blame]
Thomas Lively64a39a12019-01-10 22:32:11 +00001; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+unimplemented-simd128,+sign-ext | FileCheck %s --check-prefixes CHECK,SIMD128
Thomas Livelyb6dac892018-12-21 06:58:15 +00002; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128,+sign-ext | FileCheck %s --check-prefixes CHECK,SIMD128-VM
Thomas Lively64a39a12019-01-10 22:32:11 +00003; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | 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
Thomas Lively8dbf29af2018-12-20 02:10:22 +000015; SIMD128-VM-NOT: v128.const
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000016; SIMD128-NEXT: .functype const_v16i8 () -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000017; SIMD128-NEXT: v128.const $push[[R:[0-9]+]]=,
Thomas Lively22442922018-08-21 21:03:18 +000018; SIMD128-SAME: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
Thomas Lively66f3dc02018-09-15 01:12:48 +000019; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively22442922018-08-21 21:03:18 +000020define <16 x i8> @const_v16i8() {
21 ret <16 x i8> <i8 00, i8 01, i8 02, i8 03, i8 04, i8 05, i8 06, i8 07,
22 i8 08, i8 09, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>
23}
24
Derek Schuff4ec8bca2018-08-15 00:30:27 +000025; CHECK-LABEL: splat_v16i8:
26; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000027; SIMD128-NEXT: .functype splat_v16i8 (i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000028; SIMD128-NEXT: i8x16.splat $push[[R:[0-9]+]]=, $0{{$}}
29; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff4ec8bca2018-08-15 00:30:27 +000030define <16 x i8> @splat_v16i8(i8 %x) {
31 %v = insertelement <16 x i8> undef, i8 %x, i32 0
32 %res = shufflevector <16 x i8> %v, <16 x i8> undef,
33 <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0,
34 i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
35 ret <16 x i8> %res
36}
37
Thomas Lively1b55b2b2018-09-04 21:26:17 +000038; CHECK-LABEL: const_splat_v16i8:
Thomas Livelya3937b22018-09-14 21:21:42 +000039; SIMD128: i8x16.splat
Thomas Livelyda26b842018-08-23 19:23:13 +000040define <16 x i8> @const_splat_v16i8() {
41 ret <16 x i8> <i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42,
42 i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42>
43}
44
Heejin Ahnc15a8782018-08-14 19:10:50 +000045; CHECK-LABEL: extract_v16i8_s:
Heejin Ahna0fd9c32018-08-14 18:53:27 +000046; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000047; SIMD128-NEXT: .functype extract_v16i8_s (v128) -> (i32){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000048; SIMD128-NEXT: i8x16.extract_lane_s $push[[R:[0-9]+]]=, $0, 13{{$}}
49; SIMD128-NEXT: return $pop[[R]]{{$}}
Heejin Ahna0fd9c32018-08-14 18:53:27 +000050define i32 @extract_v16i8_s(<16 x i8> %v) {
51 %elem = extractelement <16 x i8> %v, i8 13
52 %a = sext i8 %elem to i32
53 ret i32 %a
54}
55
Thomas Livelyfb84fd72018-11-02 00:06:56 +000056; CHECK-LABEL: extract_var_v16i8_s:
57; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000058; SIMD128-NEXT: .functype extract_var_v16i8_s (v128, i32) -> (i32){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +000059; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer
Thomas Livelyfb84fd72018-11-02 00:06:56 +000060; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16
61; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]
Thomas Lively6a87dda2019-01-08 06:25:55 +000062; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $2=, $pop[[L2]]
Thomas Livelyfb84fd72018-11-02 00:06:56 +000063; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0
64; SIMD128-NEXT: i32.const $push[[L4:[0-9]+]]=, 15
65; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L4]]
66; SIMD128-NEXT: i32.or $push[[L6:[0-9]+]]=, $2, $pop[[L5]]
67; SIMD128-NEXT: i32.load8_s $push[[R:[0-9]+]]=, 0($pop[[L6]])
68; SIMD128-NEXT: return $pop[[R]]
69define i32 @extract_var_v16i8_s(<16 x i8> %v, i32 %i) {
70 %elem = extractelement <16 x i8> %v, i32 %i
71 %a = sext i8 %elem to i32
72 ret i32 %a
73}
74
Thomas Lively11a332d02018-10-19 19:08:06 +000075; CHECK-LABEL: extract_undef_v16i8_s:
76; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000077; SIMD128-NEXT: .functype extract_undef_v16i8_s (v128) -> (i32){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +000078; SIMD128-NEXT: i8x16.extract_lane_s $push[[R:[0-9]+]]=, $0, 0{{$}}
79; SIMD128-NEXT: return $pop[[R]]{{$}}
80define i32 @extract_undef_v16i8_s(<16 x i8> %v) {
81 %elem = extractelement <16 x i8> %v, i8 undef
82 %a = sext i8 %elem to i32
83 ret i32 %a
84}
85
Heejin Ahnc15a8782018-08-14 19:10:50 +000086; CHECK-LABEL: extract_v16i8_u:
Heejin Ahna0fd9c32018-08-14 18:53:27 +000087; NO-SIMD128-NOT: i8x16
Thomas Lively8dbf29af2018-12-20 02:10:22 +000088; SIMD128-VM-NOT: i8x16.extract_lane_u
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000089; SIMD128-NEXT: .functype extract_v16i8_u (v128) -> (i32){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000090; SIMD128-NEXT: i8x16.extract_lane_u $push[[R:[0-9]+]]=, $0, 13{{$}}
91; SIMD128-NEXT: return $pop[[R]]{{$}}
Heejin Ahna0fd9c32018-08-14 18:53:27 +000092define i32 @extract_v16i8_u(<16 x i8> %v) {
93 %elem = extractelement <16 x i8> %v, i8 13
94 %a = zext i8 %elem to i32
95 ret i32 %a
96}
97
Thomas Livelyfb84fd72018-11-02 00:06:56 +000098; CHECK-LABEL: extract_var_v16i8_u:
99; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000100; SIMD128-NEXT: .functype extract_var_v16i8_u (v128, i32) -> (i32){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +0000101; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000102; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
103; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +0000104; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $2=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000105; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
106; SIMD128-NEXT: i32.const $push[[L4:[0-9]+]]=, 15{{$}}
107; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L4]]{{$}}
108; SIMD128-NEXT: i32.or $push[[L6:[0-9]+]]=, $2, $pop[[L5]]{{$}}
109; SIMD128-NEXT: i32.load8_u $push[[R:[0-9]+]]=, 0($pop[[L6]]){{$}}
110; SIMD128-NEXT: return $pop[[R]]{{$}}
111define i32 @extract_var_v16i8_u(<16 x i8> %v, i32 %i) {
112 %elem = extractelement <16 x i8> %v, i32 %i
113 %a = zext i8 %elem to i32
114 ret i32 %a
115}
116
Thomas Lively11a332d02018-10-19 19:08:06 +0000117; CHECK-LABEL: extract_undef_v16i8_u:
118; NO-SIMD128-NOT: i8x16
Thomas Lively8dbf29af2018-12-20 02:10:22 +0000119; SIMD128-VM-NOT: i8x16.extract_lane_u
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000120; SIMD128-NEXT: .functype extract_undef_v16i8_u (v128) -> (i32){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000121; SIMD128-NEXT: i8x16.extract_lane_u $push[[R:[0-9]+]]=, $0, 0{{$}}
122; SIMD128-NEXT: return $pop[[R]]{{$}}
123define i32 @extract_undef_v16i8_u(<16 x i8> %v) {
124 %elem = extractelement <16 x i8> %v, i8 undef
125 %a = zext i8 %elem to i32
126 ret i32 %a
127}
128
Heejin Ahnc15a8782018-08-14 19:10:50 +0000129; CHECK-LABEL: extract_v16i8:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000130; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000131; SIMD128-NEXT: .functype extract_v16i8 (v128) -> (i32){{$}}
Thomas Lively8dbf29af2018-12-20 02:10:22 +0000132; SIMD128-NEXT: i8x16.extract_lane_s $push[[R:[0-9]+]]=, $0, 13{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000133; SIMD128-NEXT: return $pop[[R]]{{$}}
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000134define i8 @extract_v16i8(<16 x i8> %v) {
135 %elem = extractelement <16 x i8> %v, i8 13
136 ret i8 %elem
137}
138
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000139; CHECK-LABEL: extract_var_v16i8:
140; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000141; SIMD128-NEXT: .functype extract_var_v16i8 (v128, i32) -> (i32){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +0000142; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000143; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
144; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +0000145; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $2=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000146; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
147; SIMD128-NEXT: i32.const $push[[L4:[0-9]+]]=, 15{{$}}
148; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L4]]{{$}}
149; SIMD128-NEXT: i32.or $push[[L6:[0-9]+]]=, $2, $pop[[L5]]{{$}}
150; SIMD128-NEXT: i32.load8_u $push[[R:[0-9]+]]=, 0($pop[[L6]]){{$}}
151; SIMD128-NEXT: return $pop[[R]]{{$}}
152define i8 @extract_var_v16i8(<16 x i8> %v, i32 %i) {
153 %elem = extractelement <16 x i8> %v, i32 %i
154 ret i8 %elem
155}
156
Thomas Lively11a332d02018-10-19 19:08:06 +0000157; CHECK-LABEL: extract_undef_v16i8:
158; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000159; SIMD128-NEXT: .functype extract_undef_v16i8 (v128) -> (i32){{$}}
Thomas Lively8dbf29af2018-12-20 02:10:22 +0000160; SIMD128-NEXT: i8x16.extract_lane_s $push[[R:[0-9]+]]=, $0, 0{{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000161; SIMD128-NEXT: return $pop[[R]]{{$}}
162define i8 @extract_undef_v16i8(<16 x i8> %v) {
163 %elem = extractelement <16 x i8> %v, i8 undef
164 ret i8 %elem
165}
166
Derek Schuff82812fb2018-08-15 16:18:51 +0000167; CHECK-LABEL: replace_v16i8:
168; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000169; SIMD128-NEXT: .functype replace_v16i8 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000170; SIMD128-NEXT: i8x16.replace_lane $push[[R:[0-9]+]]=, $0, 11, $1{{$}}
171; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff82812fb2018-08-15 16:18:51 +0000172define <16 x i8> @replace_v16i8(<16 x i8> %v, i8 %x) {
173 %res = insertelement <16 x i8> %v, i8 %x, i32 11
174 ret <16 x i8> %res
175}
176
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000177; CHECK-LABEL: replace_var_v16i8:
178; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000179; SIMD128-NEXT: .functype replace_var_v16i8 (v128, i32, i32) -> (v128){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +0000180; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000181; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
182; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +0000183; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $3=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000184; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
185; SIMD128-NEXT: i32.const $push[[L4:[0-9]+]]=, 15{{$}}
186; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L4]]{{$}}
187; SIMD128-NEXT: i32.or $push[[L6:[0-9]+]]=, $3, $pop[[L5]]{{$}}
188; SIMD128-NEXT: i32.store8 0($pop[[L6]]), $2{{$}}
189; SIMD128-NEXT: v128.load $push[[R:[0-9]+]]=, 0($3){{$}}
190; SIMD128-NEXT: return $pop[[R]]{{$}}
191define <16 x i8> @replace_var_v16i8(<16 x i8> %v, i32 %i, i8 %x) {
192 %res = insertelement <16 x i8> %v, i8 %x, i32 %i
193 ret <16 x i8> %res
194}
195
Thomas Lively11a332d02018-10-19 19:08:06 +0000196; CHECK-LABEL: replace_undef_v16i8:
197; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000198; SIMD128-NEXT: .functype replace_undef_v16i8 (v128, i32) -> (v128){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000199; SIMD128-NEXT: i8x16.replace_lane $push[[R:[0-9]+]]=, $0, 0, $1{{$}}
200; SIMD128-NEXT: return $pop[[R]]{{$}}
201define <16 x i8> @replace_undef_v16i8(<16 x i8> %v, i8 %x) {
202 %res = insertelement <16 x i8> %v, i8 %x, i32 undef
203 ret <16 x i8> %res
204}
205
Thomas Livelya0d25812018-09-07 21:54:46 +0000206; CHECK-LABEL: shuffle_v16i8:
207; NO-SIMD128-NOT: v8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000208; SIMD128-NEXT: .functype shuffle_v16i8 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000209; SIMD128-NEXT: v8x16.shuffle $push[[R:[0-9]+]]=, $0, $1,
Thomas Livelya3937b22018-09-14 21:21:42 +0000210; SIMD128-SAME: 0, 17, 2, 19, 4, 21, 6, 23, 8, 25, 10, 27, 12, 29, 14, 31{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000211; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelya0d25812018-09-07 21:54:46 +0000212define <16 x i8> @shuffle_v16i8(<16 x i8> %x, <16 x i8> %y) {
213 %res = shufflevector <16 x i8> %x, <16 x i8> %y,
214 <16 x i32> <i32 0, i32 17, i32 2, i32 19, i32 4, i32 21, i32 6, i32 23,
215 i32 8, i32 25, i32 10, i32 27, i32 12, i32 29, i32 14, i32 31>
216 ret <16 x i8> %res
217}
218
Thomas Lively11a332d02018-10-19 19:08:06 +0000219; CHECK-LABEL: shuffle_undef_v16i8:
220; NO-SIMD128-NOT: v8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000221; SIMD128-NEXT: .functype shuffle_undef_v16i8 (v128, v128) -> (v128){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000222; SIMD128-NEXT: v8x16.shuffle $push[[R:[0-9]+]]=, $0, $0,
223; SIMD128-SAME: 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0{{$}}
224; SIMD128-NEXT: return $pop[[R]]{{$}}
225define <16 x i8> @shuffle_undef_v16i8(<16 x i8> %x, <16 x i8> %y) {
226 %res = shufflevector <16 x i8> %x, <16 x i8> %y,
227 <16 x i32> <i32 1, i32 undef, i32 undef, i32 undef,
228 i32 undef, i32 undef, i32 undef, i32 undef,
229 i32 undef, i32 undef, i32 undef, i32 undef,
230 i32 undef, i32 undef, i32 undef, i32 undef>
231 ret <16 x i8> %res
232}
233
Thomas Lively2ee686d2018-08-22 23:06:27 +0000234; CHECK-LABEL: build_v16i8:
235; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000236; SIMD128-NEXT: .functype build_v16i8 (i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000237; SIMD128-NEXT: i8x16.splat $push[[L0:[0-9]+]]=, $0{{$}}
238; SIMD128-NEXT: i8x16.replace_lane $push[[L1:[0-9]+]]=, $pop[[L0]], 1, $1{{$}}
239; SIMD128-NEXT: i8x16.replace_lane $push[[L2:[0-9]+]]=, $pop[[L1]], 2, $2{{$}}
240; SIMD128-NEXT: i8x16.replace_lane $push[[L3:[0-9]+]]=, $pop[[L2]], 3, $3{{$}}
241; SIMD128-NEXT: i8x16.replace_lane $push[[L4:[0-9]+]]=, $pop[[L3]], 4, $4{{$}}
242; SIMD128-NEXT: i8x16.replace_lane $push[[L5:[0-9]+]]=, $pop[[L4]], 5, $5{{$}}
243; SIMD128-NEXT: i8x16.replace_lane $push[[L6:[0-9]+]]=, $pop[[L5]], 6, $6{{$}}
244; SIMD128-NEXT: i8x16.replace_lane $push[[L7:[0-9]+]]=, $pop[[L6]], 7, $7{{$}}
245; SIMD128-NEXT: i8x16.replace_lane $push[[L8:[0-9]+]]=, $pop[[L7]], 8, $8{{$}}
246; SIMD128-NEXT: i8x16.replace_lane $push[[L9:[0-9]+]]=, $pop[[L8]], 9, $9{{$}}
247; SIMD128-NEXT: i8x16.replace_lane $push[[L10:[0-9]+]]=, $pop[[L9]], 10, $10{{$}}
248; SIMD128-NEXT: i8x16.replace_lane $push[[L11:[0-9]+]]=, $pop[[L10]], 11, $11{{$}}
249; SIMD128-NEXT: i8x16.replace_lane $push[[L12:[0-9]+]]=, $pop[[L11]], 12, $12{{$}}
250; SIMD128-NEXT: i8x16.replace_lane $push[[L13:[0-9]+]]=, $pop[[L12]], 13, $13{{$}}
251; SIMD128-NEXT: i8x16.replace_lane $push[[L14:[0-9]+]]=, $pop[[L13]], 14, $14{{$}}
252; SIMD128-NEXT: i8x16.replace_lane $push[[R:[0-9]+]]=, $pop[[L14]], 15, $15{{$}}
253; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively2ee686d2018-08-22 23:06:27 +0000254define <16 x i8> @build_v16i8(i8 %x0, i8 %x1, i8 %x2, i8 %x3,
255 i8 %x4, i8 %x5, i8 %x6, i8 %x7,
256 i8 %x8, i8 %x9, i8 %x10, i8 %x11,
257 i8 %x12, i8 %x13, i8 %x14, i8 %x15) {
258 %t0 = insertelement <16 x i8> undef, i8 %x0, i32 0
259 %t1 = insertelement <16 x i8> %t0, i8 %x1, i32 1
260 %t2 = insertelement <16 x i8> %t1, i8 %x2, i32 2
261 %t3 = insertelement <16 x i8> %t2, i8 %x3, i32 3
262 %t4 = insertelement <16 x i8> %t3, i8 %x4, i32 4
263 %t5 = insertelement <16 x i8> %t4, i8 %x5, i32 5
264 %t6 = insertelement <16 x i8> %t5, i8 %x6, i32 6
265 %t7 = insertelement <16 x i8> %t6, i8 %x7, i32 7
266 %t8 = insertelement <16 x i8> %t7, i8 %x8, i32 8
267 %t9 = insertelement <16 x i8> %t8, i8 %x9, i32 9
268 %t10 = insertelement <16 x i8> %t9, i8 %x10, i32 10
269 %t11 = insertelement <16 x i8> %t10, i8 %x11, i32 11
270 %t12 = insertelement <16 x i8> %t11, i8 %x12, i32 12
271 %t13 = insertelement <16 x i8> %t12, i8 %x13, i32 13
272 %t14 = insertelement <16 x i8> %t13, i8 %x14, i32 14
273 %res = insertelement <16 x i8> %t14, i8 %x15, i32 15
274 ret <16 x i8> %res
275}
276
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000277; ==============================================================================
278; 8 x i16
279; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000280; CHECK-LABEL: const_v8i16:
281; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000282; SIMD128-NEXT: .functype const_v8i16 () -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000283; SIMD128-NEXT: v128.const $push[[R:[0-9]+]]=, 256, 770, 1284, 1798, 2312, 2826, 3340, 3854{{$}}
284; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively22442922018-08-21 21:03:18 +0000285define <8 x i16> @const_v8i16() {
286 ret <8 x i16> <i16 256, i16 770, i16 1284, i16 1798,
287 i16 2312, i16 2826, i16 3340, i16 3854>
288}
289
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000290; CHECK-LABEL: splat_v8i16:
291; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000292; SIMD128-NEXT: .functype splat_v8i16 (i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000293; SIMD128-NEXT: i16x8.splat $push[[R:[0-9]+]]=, $0{{$}}
294; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000295define <8 x i16> @splat_v8i16(i16 %x) {
296 %v = insertelement <8 x i16> undef, i16 %x, i32 0
297 %res = shufflevector <8 x i16> %v, <8 x i16> undef,
298 <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
299 ret <8 x i16> %res
300}
301
Thomas Livelycfab8b42018-09-04 21:51:32 +0000302; CHECK-LABEL: const_splat_v8i16:
Thomas Livelya3937b22018-09-14 21:21:42 +0000303; SIMD128: i16x8.splat
Thomas Livelyda26b842018-08-23 19:23:13 +0000304define <8 x i16> @const_splat_v8i16() {
305 ret <8 x i16> <i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42>
306}
307
Heejin Ahnc15a8782018-08-14 19:10:50 +0000308; CHECK-LABEL: extract_v8i16_s:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000309; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000310; SIMD128-NEXT: .functype extract_v8i16_s (v128) -> (i32){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000311; SIMD128-NEXT: i16x8.extract_lane_s $push[[R:[0-9]+]]=, $0, 5{{$}}
312; SIMD128-NEXT: return $pop[[R]]{{$}}
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000313define i32 @extract_v8i16_s(<8 x i16> %v) {
314 %elem = extractelement <8 x i16> %v, i16 5
315 %a = sext i16 %elem to i32
316 ret i32 %a
317}
318
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000319; CHECK-LABEL: extract_var_v8i16_s:
320; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000321; SIMD128-NEXT: .functype extract_var_v8i16_s (v128, i32) -> (i32){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +0000322; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000323; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
324; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +0000325; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $2=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000326; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
327; SIMD128-NEXT: i32.const $push[[L4:[0-9]+]]=, 7{{$}}
328; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L4]]{{$}}
329; SIMD128-NEXT: i32.const $push[[L6:[0-9]+]]=, 1{{$}}
330; SIMD128-NEXT: i32.shl $push[[L7:[0-9]+]]=, $pop[[L5]], $pop[[L6]]{{$}}
331; SIMD128-NEXT: i32.or $push[[L8:[0-9]+]]=, $2, $pop[[L7]]{{$}}
332; SIMD128-NEXT: i32.load16_s $push[[R:[0-9]+]]=, 0($pop[[L8]]){{$}}
333; SIMD128-NEXT: return $pop[[R]]{{$}}
334define i32 @extract_var_v8i16_s(<8 x i16> %v, i32 %i) {
335 %elem = extractelement <8 x i16> %v, i32 %i
336 %a = sext i16 %elem to i32
337 ret i32 %a
338}
339
Thomas Lively11a332d02018-10-19 19:08:06 +0000340; CHECK-LABEL: extract_undef_v8i16_s:
341; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000342; SIMD128-NEXT: .functype extract_undef_v8i16_s (v128) -> (i32){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000343; SIMD128-NEXT: i16x8.extract_lane_s $push[[R:[0-9]+]]=, $0, 0{{$}}
344; SIMD128-NEXT: return $pop[[R]]{{$}}
345define i32 @extract_undef_v8i16_s(<8 x i16> %v) {
346 %elem = extractelement <8 x i16> %v, i16 undef
347 %a = sext i16 %elem to i32
348 ret i32 %a
349}
350
Heejin Ahnc15a8782018-08-14 19:10:50 +0000351; CHECK-LABEL: extract_v8i16_u:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000352; NO-SIMD128-NOT: i16x8
Thomas Lively8dbf29af2018-12-20 02:10:22 +0000353; SIMD128-VM-NOT: i16x8.extract_lane_u
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000354; SIMD128-NEXT: .functype extract_v8i16_u (v128) -> (i32){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000355; SIMD128-NEXT: i16x8.extract_lane_u $push[[R:[0-9]+]]=, $0, 5{{$}}
356; SIMD128-NEXT: return $pop[[R]]{{$}}
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000357define i32 @extract_v8i16_u(<8 x i16> %v) {
358 %elem = extractelement <8 x i16> %v, i16 5
359 %a = zext i16 %elem to i32
360 ret i32 %a
361}
362
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000363; CHECK-LABEL: extract_var_v8i16_u:
364; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000365; SIMD128-NEXT: .functype extract_var_v8i16_u (v128, i32) -> (i32){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +0000366; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000367; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
368; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +0000369; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $2=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000370; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
371; SIMD128-NEXT: i32.const $push[[L4:[0-9]+]]=, 7{{$}}
372; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L4]]{{$}}
373; SIMD128-NEXT: i32.const $push[[L6:[0-9]+]]=, 1{{$}}
374; SIMD128-NEXT: i32.shl $push[[L7:[0-9]+]]=, $pop[[L5]], $pop[[L6]]{{$}}
375; SIMD128-NEXT: i32.or $push[[L8:[0-9]+]]=, $2, $pop[[L7]]{{$}}
376; SIMD128-NEXT: i32.load16_u $push[[R:[0-9]+]]=, 0($pop[[L8]]){{$}}
377; SIMD128-NEXT: return $pop[[R]]{{$}}
378define i32 @extract_var_v8i16_u(<8 x i16> %v, i32 %i) {
379 %elem = extractelement <8 x i16> %v, i32 %i
380 %a = zext i16 %elem to i32
381 ret i32 %a
382}
383
Thomas Lively11a332d02018-10-19 19:08:06 +0000384; CHECK-LABEL: extract_undef_v8i16_u:
385; NO-SIMD128-NOT: i16x8
Thomas Lively8dbf29af2018-12-20 02:10:22 +0000386; SIMD128-VM-NOT: i16x8.extract_lane_u
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000387; SIMD128-NEXT: .functype extract_undef_v8i16_u (v128) -> (i32){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000388; SIMD128-NEXT: i16x8.extract_lane_u $push[[R:[0-9]+]]=, $0, 0{{$}}
389; SIMD128-NEXT: return $pop[[R]]{{$}}
390define i32 @extract_undef_v8i16_u(<8 x i16> %v) {
391 %elem = extractelement <8 x i16> %v, i16 undef
392 %a = zext i16 %elem to i32
393 ret i32 %a
394}
395
Heejin Ahnc15a8782018-08-14 19:10:50 +0000396; CHECK-LABEL: extract_v8i16:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000397; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000398; SIMD128-NEXT: .functype extract_v8i16 (v128) -> (i32){{$}}
Thomas Lively8dbf29af2018-12-20 02:10:22 +0000399; SIMD128-NEXT: i16x8.extract_lane_s $push[[R:[0-9]+]]=, $0, 5{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000400; SIMD128-NEXT: return $pop[[R]]{{$}}
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000401define i16 @extract_v8i16(<8 x i16> %v) {
402 %elem = extractelement <8 x i16> %v, i16 5
403 ret i16 %elem
404}
405
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000406; CHECK-LABEL: extract_var_v8i16:
407; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000408; SIMD128-NEXT: .functype extract_var_v8i16 (v128, i32) -> (i32){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +0000409; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000410; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
411; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +0000412; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $2=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000413; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
414; SIMD128-NEXT: i32.const $push[[L4:[0-9]+]]=, 7{{$}}
415; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L4]]{{$}}
416; SIMD128-NEXT: i32.const $push[[L6:[0-9]+]]=, 1{{$}}
417; SIMD128-NEXT: i32.shl $push[[L7:[0-9]+]]=, $pop[[L5]], $pop[[L6]]{{$}}
418; SIMD128-NEXT: i32.or $push[[L8:[0-9]+]]=, $2, $pop[[L7]]{{$}}
419; SIMD128-NEXT: i32.load16_u $push[[R:[0-9]+]]=, 0($pop[[L8]]){{$}}
420; SIMD128-NEXT: return $pop[[R]]{{$}}
421define i16 @extract_var_v8i16(<8 x i16> %v, i32 %i) {
422 %elem = extractelement <8 x i16> %v, i32 %i
423 ret i16 %elem
424}
425
Thomas Lively11a332d02018-10-19 19:08:06 +0000426; CHECK-LABEL: extract_undef_v8i16:
427; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000428; SIMD128-NEXT: .functype extract_undef_v8i16 (v128) -> (i32){{$}}
Thomas Lively8dbf29af2018-12-20 02:10:22 +0000429; SIMD128-NEXT: i16x8.extract_lane_s $push[[R:[0-9]+]]=, $0, 0{{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000430; SIMD128-NEXT: return $pop[[R]]{{$}}
431define i16 @extract_undef_v8i16(<8 x i16> %v) {
432 %elem = extractelement <8 x i16> %v, i16 undef
433 ret i16 %elem
434}
435
Derek Schuff82812fb2018-08-15 16:18:51 +0000436; CHECK-LABEL: replace_v8i16:
437; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000438; SIMD128-NEXT: .functype replace_v8i16 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000439; SIMD128-NEXT: i16x8.replace_lane $push[[R:[0-9]+]]=, $0, 7, $1{{$}}
440; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff82812fb2018-08-15 16:18:51 +0000441define <8 x i16> @replace_v8i16(<8 x i16> %v, i16 %x) {
442 %res = insertelement <8 x i16> %v, i16 %x, i32 7
443 ret <8 x i16> %res
444}
445
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000446; CHECK-LABEL: replace_var_v8i16:
447; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000448; SIMD128-NEXT: .functype replace_var_v8i16 (v128, i32, i32) -> (v128){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +0000449; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000450; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
451; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +0000452; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $3=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000453; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
454; SIMD128-NEXT: i32.const $push[[L4:[0-9]+]]=, 7{{$}}
455; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L4]]{{$}}
456; SIMD128-NEXT: i32.const $push[[L6:[0-9]+]]=, 1{{$}}
457; SIMD128-NEXT: i32.shl $push[[L7:[0-9]+]]=, $pop[[L5]], $pop[[L6]]{{$}}
458; SIMD128-NEXT: i32.or $push[[L8:[0-9]+]]=, $3, $pop[[L7]]{{$}}
459; SIMD128-NEXT: i32.store16 0($pop[[L8]]), $2{{$}}
460; SIMD128-NEXT: v128.load $push[[R:[0-9]+]]=, 0($3){{$}}
461; SIMD128-NEXT: return $pop[[R]]{{$}}
462define <8 x i16> @replace_var_v8i16(<8 x i16> %v, i32 %i, i16 %x) {
463 %res = insertelement <8 x i16> %v, i16 %x, i32 %i
464 ret <8 x i16> %res
465}
466
Thomas Lively11a332d02018-10-19 19:08:06 +0000467; CHECK-LABEL: replace_undef_v8i16:
468; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000469; SIMD128-NEXT: .functype replace_undef_v8i16 (v128, i32) -> (v128){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000470; SIMD128-NEXT: i16x8.replace_lane $push[[R:[0-9]+]]=, $0, 0, $1{{$}}
471; SIMD128-NEXT: return $pop[[R]]{{$}}
472define <8 x i16> @replace_undef_v8i16(<8 x i16> %v, i16 %x) {
473 %res = insertelement <8 x i16> %v, i16 %x, i32 undef
474 ret <8 x i16> %res
475}
476
Thomas Livelya0d25812018-09-07 21:54:46 +0000477; CHECK-LABEL: shuffle_v8i16:
478; NO-SIMD128-NOT: v8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000479; SIMD128-NEXT: .functype shuffle_v8i16 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000480; SIMD128-NEXT: v8x16.shuffle $push[[R:[0-9]+]]=, $0, $1,
Thomas Livelya3937b22018-09-14 21:21:42 +0000481; SIMD128-SAME: 0, 1, 18, 19, 4, 5, 22, 23, 8, 9, 26, 27, 12, 13, 30, 31{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000482; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelya0d25812018-09-07 21:54:46 +0000483define <8 x i16> @shuffle_v8i16(<8 x i16> %x, <8 x i16> %y) {
484 %res = shufflevector <8 x i16> %x, <8 x i16> %y,
485 <8 x i32> <i32 0, i32 9, i32 2, i32 11, i32 4, i32 13, i32 6, i32 15>
486 ret <8 x i16> %res
487}
488
Thomas Lively11a332d02018-10-19 19:08:06 +0000489; CHECK-LABEL: shuffle_undef_v8i16:
490; NO-SIMD128-NOT: v8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000491; SIMD128-NEXT: .functype shuffle_undef_v8i16 (v128, v128) -> (v128){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000492; SIMD128-NEXT: v8x16.shuffle $push[[R:[0-9]+]]=, $0, $0,
493; SIMD128-SAME: 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0{{$}}
494; SIMD128-NEXT: return $pop[[R]]{{$}}
495define <8 x i16> @shuffle_undef_v8i16(<8 x i16> %x, <8 x i16> %y) {
496 %res = shufflevector <8 x i16> %x, <8 x i16> %y,
497 <8 x i32> <i32 1, i32 undef, i32 undef, i32 undef,
498 i32 undef, i32 undef, i32 undef, i32 undef>
499 ret <8 x i16> %res
500}
501
Thomas Lively2ee686d2018-08-22 23:06:27 +0000502; CHECK-LABEL: build_v8i16:
503; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000504; SIMD128-NEXT: .functype build_v8i16 (i32, i32, i32, i32, i32, i32, i32, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000505; SIMD128-NEXT: i16x8.splat $push[[L0:[0-9]+]]=, $0{{$}}
506; SIMD128-NEXT: i16x8.replace_lane $push[[L1:[0-9]+]]=, $pop[[L0]], 1, $1{{$}}
507; SIMD128-NEXT: i16x8.replace_lane $push[[L2:[0-9]+]]=, $pop[[L1]], 2, $2{{$}}
508; SIMD128-NEXT: i16x8.replace_lane $push[[L3:[0-9]+]]=, $pop[[L2]], 3, $3{{$}}
509; SIMD128-NEXT: i16x8.replace_lane $push[[L4:[0-9]+]]=, $pop[[L3]], 4, $4{{$}}
510; SIMD128-NEXT: i16x8.replace_lane $push[[L5:[0-9]+]]=, $pop[[L4]], 5, $5{{$}}
511; SIMD128-NEXT: i16x8.replace_lane $push[[L6:[0-9]+]]=, $pop[[L5]], 6, $6{{$}}
512; SIMD128-NEXT: i16x8.replace_lane $push[[R:[0-9]+]]=, $pop[[L6]], 7, $7{{$}}
513; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively2ee686d2018-08-22 23:06:27 +0000514define <8 x i16> @build_v8i16(i16 %x0, i16 %x1, i16 %x2, i16 %x3,
515 i16 %x4, i16 %x5, i16 %x6, i16 %x7) {
516 %t0 = insertelement <8 x i16> undef, i16 %x0, i32 0
517 %t1 = insertelement <8 x i16> %t0, i16 %x1, i32 1
518 %t2 = insertelement <8 x i16> %t1, i16 %x2, i32 2
519 %t3 = insertelement <8 x i16> %t2, i16 %x3, i32 3
520 %t4 = insertelement <8 x i16> %t3, i16 %x4, i32 4
521 %t5 = insertelement <8 x i16> %t4, i16 %x5, i32 5
522 %t6 = insertelement <8 x i16> %t5, i16 %x6, i32 6
523 %res = insertelement <8 x i16> %t6, i16 %x7, i32 7
524 ret <8 x i16> %res
525}
526
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000527; ==============================================================================
528; 4 x i32
529; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000530; CHECK-LABEL: const_v4i32:
531; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000532; SIMD128-NEXT: .functype const_v4i32 () -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000533; SIMD128-NEXT: v128.const $push[[R:[0-9]+]]=, 50462976, 117835012, 185207048, 252579084{{$}}
534; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively22442922018-08-21 21:03:18 +0000535define <4 x i32> @const_v4i32() {
536 ret <4 x i32> <i32 50462976, i32 117835012, i32 185207048, i32 252579084>
537}
538
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000539; CHECK-LABEL: splat_v4i32:
540; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000541; SIMD128-NEXT: .functype splat_v4i32 (i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000542; SIMD128-NEXT: i32x4.splat $push[[R:[0-9]+]]=, $0{{$}}
543; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000544define <4 x i32> @splat_v4i32(i32 %x) {
545 %v = insertelement <4 x i32> undef, i32 %x, i32 0
546 %res = shufflevector <4 x i32> %v, <4 x i32> undef,
547 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
548 ret <4 x i32> %res
549}
550
Thomas Lively1b55b2b2018-09-04 21:26:17 +0000551; CHECK-LABEL: const_splat_v4i32:
Thomas Livelya3937b22018-09-14 21:21:42 +0000552; SIMD128: i32x4.splat
Thomas Livelyda26b842018-08-23 19:23:13 +0000553define <4 x i32> @const_splat_v4i32() {
554 ret <4 x i32> <i32 42, i32 42, i32 42, i32 42>
555}
556
Heejin Ahnc15a8782018-08-14 19:10:50 +0000557; CHECK-LABEL: extract_v4i32:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000558; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000559; SIMD128-NEXT: .functype extract_v4i32 (v128) -> (i32){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000560; SIMD128-NEXT: i32x4.extract_lane $push[[R:[0-9]+]]=, $0, 3{{$}}
561; SIMD128-NEXT: return $pop[[R]]{{$}}
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000562define i32 @extract_v4i32(<4 x i32> %v) {
563 %elem = extractelement <4 x i32> %v, i32 3
564 ret i32 %elem
565}
566
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000567; CHECK-LABEL: extract_var_v4i32:
568; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000569; SIMD128-NEXT: .functype extract_var_v4i32 (v128, i32) -> (i32){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +0000570; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000571; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
572; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +0000573; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $2=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000574; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
575; SIMD128-NEXT: i32.const $push[[L4:[0-9]+]]=, 3{{$}}
576; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L4]]{{$}}
577; SIMD128-NEXT: i32.const $push[[L6:[0-9]+]]=, 2{{$}}
578; SIMD128-NEXT: i32.shl $push[[L7:[0-9]+]]=, $pop[[L5]], $pop[[L6]]{{$}}
579; SIMD128-NEXT: i32.or $push[[L4:[0-9]+]]=, $2, $pop[[L7]]{{$}}
580; SIMD128-NEXT: i32.load $push[[R:[0-9]+]]=, 0($pop[[L4]]){{$}}
581; SIMD128-NEXT: return $pop[[R]]{{$}}
582define i32 @extract_var_v4i32(<4 x i32> %v, i32 %i) {
583 %elem = extractelement <4 x i32> %v, i32 %i
584 ret i32 %elem
585}
586
Thomas Lively11a332d02018-10-19 19:08:06 +0000587; CHECK-LABEL: extract_undef_v4i32:
588; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000589; SIMD128-NEXT: .functype extract_undef_v4i32 (v128) -> (i32){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000590; SIMD128-NEXT: i32x4.extract_lane $push[[R:[0-9]+]]=, $0, 0{{$}}
591; SIMD128-NEXT: return $pop[[R]]{{$}}
592define i32 @extract_undef_v4i32(<4 x i32> %v) {
593 %elem = extractelement <4 x i32> %v, i32 undef
594 ret i32 %elem
595}
596
Derek Schuff82812fb2018-08-15 16:18:51 +0000597; CHECK-LABEL: replace_v4i32:
598; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000599; SIMD128-NEXT: .functype replace_v4i32 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000600; SIMD128-NEXT: i32x4.replace_lane $push[[R:[0-9]+]]=, $0, 2, $1{{$}}
601; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff82812fb2018-08-15 16:18:51 +0000602define <4 x i32> @replace_v4i32(<4 x i32> %v, i32 %x) {
603 %res = insertelement <4 x i32> %v, i32 %x, i32 2
604 ret <4 x i32> %res
605}
606
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000607; CHECK-LABEL: replace_var_v4i32:
608; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000609; SIMD128-NEXT: .functype replace_var_v4i32 (v128, i32, i32) -> (v128){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +0000610; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000611; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
612; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +0000613; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $3=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000614; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
615; SIMD128-NEXT: i32.const $push[[L4:[0-9]+]]=, 3{{$}}
616; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L4]]{{$}}
617; SIMD128-NEXT: i32.const $push[[L6:[0-9]+]]=, 2{{$}}
618; SIMD128-NEXT: i32.shl $push[[L7:[0-9]+]]=, $pop[[L5]], $pop[[L6]]{{$}}
619; SIMD128-NEXT: i32.or $push[[L4:[0-9]+]]=, $3, $pop[[L7]]{{$}}
620; SIMD128-NEXT: i32.store 0($pop[[L4]]), $2{{$}}
621; SIMD128-NEXT: v128.load $push[[R:[0-9]+]]=, 0($3){{$}}
622; SIMD128-NEXT: return $pop[[R]]{{$}}
623define <4 x i32> @replace_var_v4i32(<4 x i32> %v, i32 %i, i32 %x) {
624 %res = insertelement <4 x i32> %v, i32 %x, i32 %i
625 ret <4 x i32> %res
626}
627
Thomas Lively11a332d02018-10-19 19:08:06 +0000628; CHECK-LABEL: replace_undef_v4i32:
629; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000630; SIMD128-NEXT: .functype replace_undef_v4i32 (v128, i32) -> (v128){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000631; SIMD128-NEXT: i32x4.replace_lane $push[[R:[0-9]+]]=, $0, 0, $1{{$}}
632; SIMD128-NEXT: return $pop[[R]]{{$}}
633define <4 x i32> @replace_undef_v4i32(<4 x i32> %v, i32 %x) {
634 %res = insertelement <4 x i32> %v, i32 %x, i32 undef
635 ret <4 x i32> %res
636}
637
Thomas Livelya0d25812018-09-07 21:54:46 +0000638; CHECK-LABEL: shuffle_v4i32:
639; NO-SIMD128-NOT: v8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000640; SIMD128-NEXT: .functype shuffle_v4i32 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000641; SIMD128-NEXT: v8x16.shuffle $push[[R:[0-9]+]]=, $0, $1,
Thomas Livelya3937b22018-09-14 21:21:42 +0000642; SIMD128-SAME: 0, 1, 2, 3, 20, 21, 22, 23, 8, 9, 10, 11, 28, 29, 30, 31{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000643; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelya0d25812018-09-07 21:54:46 +0000644define <4 x i32> @shuffle_v4i32(<4 x i32> %x, <4 x i32> %y) {
645 %res = shufflevector <4 x i32> %x, <4 x i32> %y,
646 <4 x i32> <i32 0, i32 5, i32 2, i32 7>
647 ret <4 x i32> %res
648}
649
Thomas Lively11a332d02018-10-19 19:08:06 +0000650; CHECK-LABEL: shuffle_undef_v4i32:
651; NO-SIMD128-NOT: v8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000652; SIMD128-NEXT: .functype shuffle_undef_v4i32 (v128, v128) -> (v128){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000653; SIMD128-NEXT: v8x16.shuffle $push[[R:[0-9]+]]=, $0, $0,
654; SIMD128-SAME: 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0{{$}}
655; SIMD128-NEXT: return $pop[[R]]{{$}}
656define <4 x i32> @shuffle_undef_v4i32(<4 x i32> %x, <4 x i32> %y) {
657 %res = shufflevector <4 x i32> %x, <4 x i32> %y,
658 <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
659 ret <4 x i32> %res
660}
661
Thomas Lively2ee686d2018-08-22 23:06:27 +0000662; CHECK-LABEL: build_v4i32:
663; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000664; SIMD128-NEXT: .functype build_v4i32 (i32, i32, i32, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000665; SIMD128-NEXT: i32x4.splat $push[[L0:[0-9]+]]=, $0{{$}}
666; SIMD128-NEXT: i32x4.replace_lane $push[[L1:[0-9]+]]=, $pop[[L0]], 1, $1{{$}}
667; SIMD128-NEXT: i32x4.replace_lane $push[[L2:[0-9]+]]=, $pop[[L1]], 2, $2{{$}}
668; SIMD128-NEXT: i32x4.replace_lane $push[[R:[0-9]+]]=, $pop[[L2]], 3, $3{{$}}
669; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively2ee686d2018-08-22 23:06:27 +0000670define <4 x i32> @build_v4i32(i32 %x0, i32 %x1, i32 %x2, i32 %x3) {
671 %t0 = insertelement <4 x i32> undef, i32 %x0, i32 0
672 %t1 = insertelement <4 x i32> %t0, i32 %x1, i32 1
673 %t2 = insertelement <4 x i32> %t1, i32 %x2, i32 2
674 %res = insertelement <4 x i32> %t2, i32 %x3, i32 3
675 ret <4 x i32> %res
676}
677
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000678; ==============================================================================
679; 2 x i64
680; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000681; CHECK-LABEL: const_v2i64:
682; NO-SIMD128-NOT: i64x2
683; SIMD128-VM-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000684; SIMD128-NEXT: .functype const_v2i64 () -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000685; SIMD128-NEXT: v128.const $push[[R:[0-9]+]]=, 506097522914230528, 1084818905618843912{{$}}
686; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively22442922018-08-21 21:03:18 +0000687define <2 x i64> @const_v2i64() {
688 ret <2 x i64> <i64 506097522914230528, i64 1084818905618843912>
689}
690
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000691; CHECK-LABEL: splat_v2i64:
692; NO-SIMD128-NOT: i64x2
693; SIMD128-VM-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000694; SIMD128-NEXT: .functype splat_v2i64 (i64) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000695; SIMD128-NEXT: i64x2.splat $push[[R:[0-9]+]]=, $0{{$}}
696; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000697define <2 x i64> @splat_v2i64(i64 %x) {
698 %t1 = insertelement <2 x i64> zeroinitializer, i64 %x, i32 0
699 %res = insertelement <2 x i64> %t1, i64 %x, i32 1
700 ret <2 x i64> %res
701}
702
Thomas Lively1b55b2b2018-09-04 21:26:17 +0000703; CHECK-LABEL: const_splat_v2i64:
Thomas Livelya3937b22018-09-14 21:21:42 +0000704; SIMD128: i64x2.splat
Thomas Lively1b55b2b2018-09-04 21:26:17 +0000705define <2 x i64> @const_splat_v2i64() {
706 ret <2 x i64> <i64 42, i64 42>
707}
708
Heejin Ahnc15a8782018-08-14 19:10:50 +0000709; CHECK-LABEL: extract_v2i64:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000710; NO-SIMD128-NOT: i64x2
711; SIMD128-VM-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000712; SIMD128-NEXT: .functype extract_v2i64 (v128) -> (i64){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000713; SIMD128-NEXT: i64x2.extract_lane $push[[R:[0-9]+]]=, $0, 1{{$}}
714; SIMD128-NEXT: return $pop[[R]]{{$}}
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000715define i64 @extract_v2i64(<2 x i64> %v) {
716 %elem = extractelement <2 x i64> %v, i64 1
717 ret i64 %elem
718}
719
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000720; CHECK-LABEL: extract_var_v2i64:
721; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000722; SIMD128-NEXT: .functype extract_var_v2i64 (v128, i32) -> (i64){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +0000723; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000724; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
725; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +0000726; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $2=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000727; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
728; SIMD128-NEXT: i32.const $push[[L2:[0-9]+]]=, 1{{$}}
729; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L2]]{{$}}
730; SIMD128-NEXT: i32.const $push[[L6:[0-9]+]]=, 3{{$}}
731; SIMD128-NEXT: i32.shl $push[[L7:[0-9]+]]=, $pop[[L5]], $pop[[L6]]{{$}}
732; SIMD128-NEXT: i32.or $push[[L2:[0-9]+]]=, $2, $pop[[L7]]{{$}}
733; SIMD128-NEXT: i64.load $push[[R:[0-9]+]]=, 0($pop[[L2]]){{$}}
734; SIMD128-NEXT: return $pop[[R]]{{$}}
735define i64 @extract_var_v2i64(<2 x i64> %v, i32 %i) {
736 %elem = extractelement <2 x i64> %v, i32 %i
737 ret i64 %elem
738}
739
Thomas Lively11a332d02018-10-19 19:08:06 +0000740; CHECK-LABEL: extract_undef_v2i64:
741; NO-SIMD128-NOT: i64x2
742; SIMD128-VM-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000743; SIMD128-NEXT: .functype extract_undef_v2i64 (v128) -> (i64){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000744; SIMD128-NEXT: i64x2.extract_lane $push[[R:[0-9]+]]=, $0, 0{{$}}
745; SIMD128-NEXT: return $pop[[R]]{{$}}
746define i64 @extract_undef_v2i64(<2 x i64> %v) {
747 %elem = extractelement <2 x i64> %v, i64 undef
748 ret i64 %elem
749}
750
Derek Schuff82812fb2018-08-15 16:18:51 +0000751; CHECK-LABEL: replace_v2i64:
752; NO-SIMD128-NOT: i64x2
753; SIMD128-VM-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000754; SIMD128-NEXT: .functype replace_v2i64 (v128, i64) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000755; SIMD128-NEXT: i64x2.replace_lane $push[[R:[0-9]+]]=, $0, 0, $1{{$}}
756; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff82812fb2018-08-15 16:18:51 +0000757define <2 x i64> @replace_v2i64(<2 x i64> %v, i64 %x) {
758 %res = insertelement <2 x i64> %v, i64 %x, i32 0
759 ret <2 x i64> %res
760}
761
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000762; CHECK-LABEL: replace_var_v2i64:
763; NO-SIMD128-NOT: i64x2
764; SIMD128-VM-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000765; SIMD128-NEXT: .functype replace_var_v2i64 (v128, i32, i64) -> (v128){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +0000766; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000767; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
768; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +0000769; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $3=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000770; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
771; SIMD128-NEXT: i32.const $push[[L2:[0-9]+]]=, 1{{$}}
772; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L2]]{{$}}
773; SIMD128-NEXT: i32.const $push[[L6:[0-9]+]]=, 3{{$}}
774; SIMD128-NEXT: i32.shl $push[[L7:[0-9]+]]=, $pop[[L5]], $pop[[L6]]{{$}}
775; SIMD128-NEXT: i32.or $push[[L2:[0-9]+]]=, $3, $pop[[L7]]{{$}}
776; SIMD128-NEXT: i64.store 0($pop[[L2]]), $2{{$}}
777; SIMD128-NEXT: v128.load $push[[R:[0-9]+]]=, 0($3){{$}}
778; SIMD128-NEXT: return $pop[[R]]{{$}}
779define <2 x i64> @replace_var_v2i64(<2 x i64> %v, i32 %i, i64 %x) {
780 %res = insertelement <2 x i64> %v, i64 %x, i32 %i
781 ret <2 x i64> %res
782}
783
Thomas Lively11a332d02018-10-19 19:08:06 +0000784; CHECK-LABEL: replace_undef_v2i64:
785; NO-SIMD128-NOT: i64x2
786; SIMD128-VM-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000787; SIMD128-NEXT: .functype replace_undef_v2i64 (v128, i64) -> (v128){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000788; SIMD128-NEXT: i64x2.replace_lane $push[[R:[0-9]+]]=, $0, 0, $1{{$}}
789; SIMD128-NEXT: return $pop[[R]]{{$}}
790define <2 x i64> @replace_undef_v2i64(<2 x i64> %v, i64 %x) {
791 %res = insertelement <2 x i64> %v, i64 %x, i32 undef
792 ret <2 x i64> %res
793}
794
Thomas Livelya0d25812018-09-07 21:54:46 +0000795; CHECK-LABEL: shuffle_v2i64:
796; NO-SIMD128-NOT: v8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000797; SIMD128-NEXT: .functype shuffle_v2i64 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000798; SIMD128-NEXT: v8x16.shuffle $push[[R:[0-9]+]]=, $0, $1,
Thomas Livelya3937b22018-09-14 21:21:42 +0000799; SIMD128-SAME: 0, 1, 2, 3, 4, 5, 6, 7, 24, 25, 26, 27, 28, 29, 30, 31{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000800; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelya0d25812018-09-07 21:54:46 +0000801define <2 x i64> @shuffle_v2i64(<2 x i64> %x, <2 x i64> %y) {
802 %res = shufflevector <2 x i64> %x, <2 x i64> %y, <2 x i32> <i32 0, i32 3>
803 ret <2 x i64> %res
804}
805
Thomas Lively11a332d02018-10-19 19:08:06 +0000806; CHECK-LABEL: shuffle_undef_v2i64:
807; NO-SIMD128-NOT: v8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000808; SIMD128-NEXT: .functype shuffle_undef_v2i64 (v128, v128) -> (v128){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000809; SIMD128-NEXT: v8x16.shuffle $push[[R:[0-9]+]]=, $0, $0,
810; SIMD128-SAME: 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0{{$}}
811; SIMD128-NEXT: return $pop[[R]]{{$}}
812define <2 x i64> @shuffle_undef_v2i64(<2 x i64> %x, <2 x i64> %y) {
813 %res = shufflevector <2 x i64> %x, <2 x i64> %y,
814 <2 x i32> <i32 1, i32 undef>
815 ret <2 x i64> %res
816}
817
Thomas Lively2ee686d2018-08-22 23:06:27 +0000818; CHECK-LABEL: build_v2i64:
819; NO-SIMD128-NOT: i64x2
820; SIMD128-VM-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000821; SIMD128-NEXT: .functype build_v2i64 (i64, i64) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000822; SIMD128-NEXT: i64x2.splat $push[[L0:[0-9]+]]=, $0{{$}}
823; SIMD128-NEXT: i64x2.replace_lane $push[[R:[0-9]+]]=, $pop[[L0]], 1, $1{{$}}
824; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively2ee686d2018-08-22 23:06:27 +0000825define <2 x i64> @build_v2i64(i64 %x0, i64 %x1) {
826 %t0 = insertelement <2 x i64> undef, i64 %x0, i32 0
827 %res = insertelement <2 x i64> %t0, i64 %x1, i32 1
828 ret <2 x i64> %res
829}
830
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000831; ==============================================================================
832; 4 x f32
833; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000834; CHECK-LABEL: const_v4f32:
835; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000836; SIMD128-NEXT: .functype const_v4f32 () -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000837; SIMD128-NEXT: v128.const $push[[R:[0-9]+]]=,
Thomas Livelya3937b22018-09-14 21:21:42 +0000838; SIMD128-SAME: 0x1.0402p-121, 0x1.0c0a08p-113, 0x1.14121p-105, 0x1.1c1a18p-97{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000839; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively22442922018-08-21 21:03:18 +0000840define <4 x float> @const_v4f32() {
841 ret <4 x float> <float 0x3860402000000000, float 0x38e0c0a080000000,
842 float 0x3961412100000000, float 0x39e1c1a180000000>
843}
844
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000845; CHECK-LABEL: splat_v4f32:
846; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000847; SIMD128-NEXT: .functype splat_v4f32 (f32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000848; SIMD128-NEXT: f32x4.splat $push[[R:[0-9]+]]=, $0{{$}}
849; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000850define <4 x float> @splat_v4f32(float %x) {
851 %v = insertelement <4 x float> undef, float %x, i32 0
852 %res = shufflevector <4 x float> %v, <4 x float> undef,
853 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
854 ret <4 x float> %res
855}
856
Thomas Livelyda26b842018-08-23 19:23:13 +0000857; CHECK-LABEL: const_splat_v4f32
Thomas Livelya3937b22018-09-14 21:21:42 +0000858; SIMD128: f32x4.splat
Thomas Livelyda26b842018-08-23 19:23:13 +0000859define <4 x float> @const_splat_v4f32() {
860 ret <4 x float> <float 42., float 42., float 42., float 42.>
861}
862
Heejin Ahnc15a8782018-08-14 19:10:50 +0000863; CHECK-LABEL: extract_v4f32:
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000864; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000865; SIMD128-NEXT: .functype extract_v4f32 (v128) -> (f32){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000866; SIMD128-NEXT: f32x4.extract_lane $push[[R:[0-9]+]]=, $0, 3{{$}}
867; SIMD128-NEXT: return $pop[[R]]{{$}}
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000868define float @extract_v4f32(<4 x float> %v) {
869 %elem = extractelement <4 x float> %v, i32 3
870 ret float %elem
871}
872
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000873; CHECK-LABEL: extract_var_v4f32:
874; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000875; SIMD128-NEXT: .functype extract_var_v4f32 (v128, i32) -> (f32){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +0000876; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000877; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
878; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +0000879; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $2=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000880; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
881; SIMD128-NEXT: i32.const $push[[L2:[0-9]+]]=, 3{{$}}
882; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L2]]{{$}}
883; SIMD128-NEXT: i32.const $push[[L6:[0-9]+]]=, 2{{$}}
884; SIMD128-NEXT: i32.shl $push[[L7:[0-9]+]]=, $pop[[L5]], $pop[[L6]]{{$}}
885; SIMD128-NEXT: i32.or $push[[L2:[0-9]+]]=, $2, $pop[[L7]]{{$}}
886; SIMD128-NEXT: f32.load $push[[R:[0-9]+]]=, 0($pop[[L2]]){{$}}
887; SIMD128-NEXT: return $pop[[R]]{{$}}
888define float @extract_var_v4f32(<4 x float> %v, i32 %i) {
889 %elem = extractelement <4 x float> %v, i32 %i
890 ret float %elem
891}
892
Thomas Lively11a332d02018-10-19 19:08:06 +0000893; CHECK-LABEL: extract_undef_v4f32:
894; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000895; SIMD128-NEXT: .functype extract_undef_v4f32 (v128) -> (f32){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000896; SIMD128-NEXT: f32x4.extract_lane $push[[R:[0-9]+]]=, $0, 0{{$}}
897; SIMD128-NEXT: return $pop[[R]]{{$}}
898define float @extract_undef_v4f32(<4 x float> %v) {
899 %elem = extractelement <4 x float> %v, i32 undef
900 ret float %elem
901}
902
Derek Schuff82812fb2018-08-15 16:18:51 +0000903; CHECK-LABEL: replace_v4f32:
904; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000905; SIMD128-NEXT: .functype replace_v4f32 (v128, f32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000906; SIMD128-NEXT: f32x4.replace_lane $push[[R:[0-9]+]]=, $0, 2, $1{{$}}
907; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff82812fb2018-08-15 16:18:51 +0000908define <4 x float> @replace_v4f32(<4 x float> %v, float %x) {
909 %res = insertelement <4 x float> %v, float %x, i32 2
910 ret <4 x float> %res
911}
912
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000913; CHECK-LABEL: replace_var_v4f32:
914; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000915; SIMD128-NEXT: .functype replace_var_v4f32 (v128, i32, f32) -> (v128){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +0000916; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000917; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
918; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +0000919; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $3=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +0000920; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
921; SIMD128-NEXT: i32.const $push[[L2:[0-9]+]]=, 3{{$}}
922; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L2]]{{$}}
923; SIMD128-NEXT: i32.const $push[[L6:[0-9]+]]=, 2{{$}}
924; SIMD128-NEXT: i32.shl $push[[L7:[0-9]+]]=, $pop[[L5]], $pop[[L6]]{{$}}
925; SIMD128-NEXT: i32.or $push[[L2:[0-9]+]]=, $3, $pop[[L7]]{{$}}
926; SIMD128-NEXT: f32.store 0($pop[[L2]]), $2{{$}}
927; SIMD128-NEXT: v128.load $push[[R:[0-9]+]]=, 0($3){{$}}
928; SIMD128-NEXT: return $pop[[R]]{{$}}
929define <4 x float> @replace_var_v4f32(<4 x float> %v, i32 %i, float %x) {
930 %res = insertelement <4 x float> %v, float %x, i32 %i
931 ret <4 x float> %res
932}
933
Thomas Lively11a332d02018-10-19 19:08:06 +0000934; CHECK-LABEL: replace_undef_v4f32:
935; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000936; SIMD128-NEXT: .functype replace_undef_v4f32 (v128, f32) -> (v128){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000937; SIMD128-NEXT: f32x4.replace_lane $push[[R:[0-9]+]]=, $0, 0, $1{{$}}
938; SIMD128-NEXT: return $pop[[R]]{{$}}
939define <4 x float> @replace_undef_v4f32(<4 x float> %v, float %x) {
940 %res = insertelement <4 x float> %v, float %x, i32 undef
941 ret <4 x float> %res
942}
943
Thomas Livelya0d25812018-09-07 21:54:46 +0000944; CHECK-LABEL: shuffle_v4f32:
945; NO-SIMD128-NOT: v8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000946; SIMD128-NEXT: .functype shuffle_v4f32 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000947; SIMD128-NEXT: v8x16.shuffle $push[[R:[0-9]+]]=, $0, $1,
Thomas Livelya3937b22018-09-14 21:21:42 +0000948; SIMD128-SAME: 0, 1, 2, 3, 20, 21, 22, 23, 8, 9, 10, 11, 28, 29, 30, 31{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000949; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelya0d25812018-09-07 21:54:46 +0000950define <4 x float> @shuffle_v4f32(<4 x float> %x, <4 x float> %y) {
951 %res = shufflevector <4 x float> %x, <4 x float> %y,
952 <4 x i32> <i32 0, i32 5, i32 2, i32 7>
953 ret <4 x float> %res
954}
955
Thomas Lively11a332d02018-10-19 19:08:06 +0000956; CHECK-LABEL: shuffle_undef_v4f32:
957; NO-SIMD128-NOT: v8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000958; SIMD128-NEXT: .functype shuffle_undef_v4f32 (v128, v128) -> (v128){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +0000959; SIMD128-NEXT: v8x16.shuffle $push[[R:[0-9]+]]=, $0, $0,
960; SIMD128-SAME: 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0{{$}}
961; SIMD128-NEXT: return $pop[[R]]{{$}}
962define <4 x float> @shuffle_undef_v4f32(<4 x float> %x, <4 x float> %y) {
963 %res = shufflevector <4 x float> %x, <4 x float> %y,
964 <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
965 ret <4 x float> %res
966}
967
Thomas Lively2ee686d2018-08-22 23:06:27 +0000968; CHECK-LABEL: build_v4f32:
969; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000970; SIMD128-NEXT: .functype build_v4f32 (f32, f32, f32, f32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000971; SIMD128-NEXT: f32x4.splat $push[[L0:[0-9]+]]=, $0{{$}}
972; SIMD128-NEXT: f32x4.replace_lane $push[[L1:[0-9]+]]=, $pop[[L0]], 1, $1{{$}}
973; SIMD128-NEXT: f32x4.replace_lane $push[[L2:[0-9]+]]=, $pop[[L1]], 2, $2{{$}}
974; SIMD128-NEXT: f32x4.replace_lane $push[[R:[0-9]+]]=, $pop[[L2]], 3, $3{{$}}
975; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively2ee686d2018-08-22 23:06:27 +0000976define <4 x float> @build_v4f32(float %x0, float %x1, float %x2, float %x3) {
977 %t0 = insertelement <4 x float> undef, float %x0, i32 0
978 %t1 = insertelement <4 x float> %t0, float %x1, i32 1
979 %t2 = insertelement <4 x float> %t1, float %x2, i32 2
980 %res = insertelement <4 x float> %t2, float %x3, i32 3
981 ret <4 x float> %res
982}
983
Heejin Ahna0fd9c32018-08-14 18:53:27 +0000984; ==============================================================================
985; 2 x f64
986; ==============================================================================
Thomas Lively22442922018-08-21 21:03:18 +0000987; CHECK-LABEL: const_v2f64:
988; NO-SIMD128-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000989; SIMD128-NEXT: .functype const_v2f64 () -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000990; SIMD128-NEXT: v128.const $push[[R:[0-9]+]]=, 0x1.60504030201p-911, 0x1.e0d0c0b0a0908p-783{{$}}
991; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively22442922018-08-21 21:03:18 +0000992define <2 x double> @const_v2f64() {
993 ret <2 x double> <double 0x0706050403020100, double 0x0F0E0D0C0B0A0908>
994}
995
Derek Schuff4ec8bca2018-08-15 00:30:27 +0000996; CHECK-LABEL: splat_v2f64:
997; NO-SIMD128-NOT: f64x2
998; SIMD128-VM-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000999; SIMD128-NEXT: .functype splat_v2f64 (f64) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001000; SIMD128-NEXT: f64x2.splat $push[[R:[0-9]+]]=, $0{{$}}
1001; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff4ec8bca2018-08-15 00:30:27 +00001002define <2 x double> @splat_v2f64(double %x) {
1003 %t1 = insertelement <2 x double> zeroinitializer, double %x, i3 0
1004 %res = insertelement <2 x double> %t1, double %x, i32 1
1005 ret <2 x double> %res
1006}
1007
Thomas Livelyda26b842018-08-23 19:23:13 +00001008; CHECK-LABEL: const_splat_v2f64:
Thomas Livelya3937b22018-09-14 21:21:42 +00001009; SIMD128: f64x2.splat
Thomas Livelyda26b842018-08-23 19:23:13 +00001010define <2 x double> @const_splat_v2f64() {
1011 ret <2 x double> <double 42., double 42.>
1012}
1013
Heejin Ahnc15a8782018-08-14 19:10:50 +00001014; CHECK-LABEL: extract_v2f64:
Heejin Ahna0fd9c32018-08-14 18:53:27 +00001015; NO-SIMD128-NOT: f64x2
1016; SIMD128-VM-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001017; SIMD128-NEXT: .functype extract_v2f64 (v128) -> (f64){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001018; SIMD128-NEXT: f64x2.extract_lane $push[[R:[0-9]+]]=, $0, 1{{$}}
1019; SIMD128-NEXT: return $pop[[R]]{{$}}
Heejin Ahna0fd9c32018-08-14 18:53:27 +00001020define double @extract_v2f64(<2 x double> %v) {
1021 %elem = extractelement <2 x double> %v, i32 1
1022 ret double %elem
1023}
Derek Schuff82812fb2018-08-15 16:18:51 +00001024
Thomas Livelyfb84fd72018-11-02 00:06:56 +00001025; CHECK-LABEL: extract_var_v2f64:
1026; NO-SIMD128-NOT: i62x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001027; SIMD128-NEXT: .functype extract_var_v2f64 (v128, i32) -> (f64){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +00001028; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +00001029; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
1030; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +00001031; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $2=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +00001032; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
1033; SIMD128-NEXT: i32.const $push[[L2:[0-9]+]]=, 1{{$}}
1034; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L2]]{{$}}
1035; SIMD128-NEXT: i32.const $push[[L6:[0-9]+]]=, 3{{$}}
1036; SIMD128-NEXT: i32.shl $push[[L7:[0-9]+]]=, $pop[[L5]], $pop[[L6]]{{$}}
1037; SIMD128-NEXT: i32.or $push[[L2:[0-9]+]]=, $2, $pop[[L7]]{{$}}
1038; SIMD128-NEXT: f64.load $push[[R:[0-9]+]]=, 0($pop[[L2]]){{$}}
1039; SIMD128-NEXT: return $pop[[R]]{{$}}
1040define double @extract_var_v2f64(<2 x double> %v, i32 %i) {
1041 %elem = extractelement <2 x double> %v, i32 %i
1042 ret double %elem
1043}
1044
Thomas Lively11a332d02018-10-19 19:08:06 +00001045; CHECK-LABEL: extract_undef_v2f64:
1046; NO-SIMD128-NOT: f64x2
1047; SIMD128-VM-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001048; SIMD128-NEXT: .functype extract_undef_v2f64 (v128) -> (f64){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +00001049; SIMD128-NEXT: f64x2.extract_lane $push[[R:[0-9]+]]=, $0, 0{{$}}
1050; SIMD128-NEXT: return $pop[[R]]{{$}}
1051define double @extract_undef_v2f64(<2 x double> %v) {
1052 %elem = extractelement <2 x double> %v, i32 undef
1053 ret double %elem
1054}
1055
Derek Schuff82812fb2018-08-15 16:18:51 +00001056; CHECK-LABEL: replace_v2f64:
1057; NO-SIMD128-NOT: f64x2
1058; SIMD128-VM-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001059; SIMD128-NEXT: .functype replace_v2f64 (v128, f64) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001060; SIMD128-NEXT: f64x2.replace_lane $push[[R:[0-9]+]]=, $0, 0, $1{{$}}
1061; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff82812fb2018-08-15 16:18:51 +00001062define <2 x double> @replace_v2f64(<2 x double> %v, double %x) {
1063 %res = insertelement <2 x double> %v, double %x, i32 0
1064 ret <2 x double> %res
1065}
Thomas Lively2ee686d2018-08-22 23:06:27 +00001066
Thomas Livelyfb84fd72018-11-02 00:06:56 +00001067; CHECK-LABEL: replace_var_v2f64:
1068; NO-SIMD128-NOT: f64x2
1069; SIMD128-VM-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001070; SIMD128-NEXT: .functype replace_var_v2f64 (v128, i32, f64) -> (v128){{$}}
Sam Clegg275d15e2019-02-23 00:07:39 +00001071; SIMD128-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +00001072; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
1073; SIMD128-NEXT: i32.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
Thomas Lively6a87dda2019-01-08 06:25:55 +00001074; SIMD128-NEXT: local.tee $push[[L3:[0-9]+]]=, $3=, $pop[[L2]]{{$}}
Thomas Livelyfb84fd72018-11-02 00:06:56 +00001075; SIMD128-NEXT: v128.store 0($pop[[L3]]), $0{{$}}
1076; SIMD128-NEXT: i32.const $push[[L2:[0-9]+]]=, 1{{$}}
1077; SIMD128-NEXT: i32.and $push[[L5:[0-9]+]]=, $1, $pop[[L2]]{{$}}
1078; SIMD128-NEXT: i32.const $push[[L6:[0-9]+]]=, 3{{$}}
1079; SIMD128-NEXT: i32.shl $push[[L7:[0-9]+]]=, $pop[[L5]], $pop[[L6]]{{$}}
1080; SIMD128-NEXT: i32.or $push[[L2:[0-9]+]]=, $3, $pop[[L7]]{{$}}
1081; SIMD128-NEXT: f64.store 0($pop[[L2]]), $2{{$}}
1082; SIMD128-NEXT: v128.load $push[[R:[0-9]+]]=, 0($3){{$}}
1083; SIMD128-NEXT: return $pop[[R]]{{$}}
1084define <2 x double> @replace_var_v2f64(<2 x double> %v, i32 %i, double %x) {
1085 %res = insertelement <2 x double> %v, double %x, i32 %i
1086 ret <2 x double> %res
1087}
1088
Thomas Lively11a332d02018-10-19 19:08:06 +00001089; CHECK-LABEL: replace_undef_v2f64:
1090; NO-SIMD128-NOT: f64x2
1091; SIMD128-VM-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001092; SIMD128-NEXT: .functype replace_undef_v2f64 (v128, f64) -> (v128){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +00001093; SIMD128-NEXT: f64x2.replace_lane $push[[R:[0-9]+]]=, $0, 0, $1{{$}}
1094; SIMD128-NEXT: return $pop[[R]]{{$}}
1095define <2 x double> @replace_undef_v2f64(<2 x double> %v, double %x) {
1096 %res = insertelement <2 x double> %v, double %x, i32 undef
1097 ret <2 x double> %res
1098}
1099
Thomas Livelya0d25812018-09-07 21:54:46 +00001100; CHECK-LABEL: shuffle_v2f64:
1101; NO-SIMD128-NOT: v8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001102; SIMD128-NEXT: .functype shuffle_v2f64 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001103; SIMD128-NEXT: v8x16.shuffle $push[[R:[0-9]+]]=, $0, $1,
Thomas Livelya3937b22018-09-14 21:21:42 +00001104; SIMD128-SAME: 0, 1, 2, 3, 4, 5, 6, 7, 24, 25, 26, 27, 28, 29, 30, 31{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001105; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelya0d25812018-09-07 21:54:46 +00001106define <2 x double> @shuffle_v2f64(<2 x double> %x, <2 x double> %y) {
1107 %res = shufflevector <2 x double> %x, <2 x double> %y,
1108 <2 x i32> <i32 0, i32 3>
1109 ret <2 x double> %res
1110}
1111
Thomas Lively11a332d02018-10-19 19:08:06 +00001112; CHECK-LABEL: shuffle_undef_v2f64:
1113; NO-SIMD128-NOT: v8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001114; SIMD128-NEXT: .functype shuffle_undef_v2f64 (v128, v128) -> (v128){{$}}
Thomas Lively11a332d02018-10-19 19:08:06 +00001115; SIMD128-NEXT: v8x16.shuffle $push[[R:[0-9]+]]=, $0, $0,
1116; SIMD128-SAME: 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0{{$}}
1117; SIMD128-NEXT: return $pop[[R]]{{$}}
1118define <2 x double> @shuffle_undef_v2f64(<2 x double> %x, <2 x double> %y) {
1119 %res = shufflevector <2 x double> %x, <2 x double> %y,
1120 <2 x i32> <i32 1, i32 undef>
1121 ret <2 x double> %res
1122}
1123
Thomas Lively2ee686d2018-08-22 23:06:27 +00001124; CHECK-LABEL: build_v2f64:
1125; NO-SIMD128-NOT: f64x2
1126; SIMD128-VM-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001127; SIMD128-NEXT: .functype build_v2f64 (f64, f64) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001128; SIMD128-NEXT: f64x2.splat $push[[L0:[0-9]+]]=, $0{{$}}
1129; SIMD128-NEXT: f64x2.replace_lane $push[[R:[0-9]+]]=, $pop[[L0]], 1, $1{{$}}
1130; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively2ee686d2018-08-22 23:06:27 +00001131define <2 x double> @build_v2f64(double %x0, double %x1) {
1132 %t0 = insertelement <2 x double> undef, double %x0, i32 0
1133 %res = insertelement <2 x double> %t0, double %x1, i32 1
1134 ret <2 x double> %res
1135}