blob: f3e70156d8bbc1af4e8b8b0045ed43b55926e801 [file] [log] [blame]
Thomas Lively5d461c92018-10-03 23:02:23 +00001; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-unimplemented-simd -mattr=+simd128 | FileCheck %s --check-prefixes CHECK,SIMD128,SIMD128-SLOW
2; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-unimplemented-simd -mattr=+simd128 -fast-isel | FileCheck %s --check-prefixes CHECK,SIMD128,SIMD128-FAST
Thomas Lively4b47d082018-10-05 00:45:20 +00003; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128 | FileCheck %s --check-prefixes CHECK,SIMD128-VM
4; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128 -fast-isel | FileCheck %s --check-prefixes CHECK,SIMD128-VM
5; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=-simd128 | FileCheck %s --check-prefixes CHECK,NO-SIMD128
6; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=-simd128 -fast-isel | FileCheck %s --check-prefixes CHECK,NO-SIMD128
Derek Schuff39bf39f2016-08-02 23:16:09 +00007
Thomas Lively409f5842018-10-09 23:33:16 +00008; check that a non-test run (including explicit locals pass) at least finishes
9; RUN: llc < %s -O0 -wasm-enable-unimplemented-simd -mattr=+simd128,+sign-ext
10; RUN: llc < %s -O2 -wasm-enable-unimplemented-simd -mattr=+simd128,+sign-ext
11
Derek Schuff39bf39f2016-08-02 23:16:09 +000012; Test that basic SIMD128 arithmetic operations assemble as expected.
13
14target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
Sam Clegga5908002018-05-10 17:49:11 +000015target triple = "wasm32-unknown-unknown"
Derek Schuff39bf39f2016-08-02 23:16:09 +000016
Derek Schuff39bf39f2016-08-02 23:16:09 +000017; ==============================================================================
18; 16 x i8
19; ==============================================================================
Thomas Livelya3937b22018-09-14 21:21:42 +000020; CHECK-LABEL: add_v16i8:
Derek Schuff39bf39f2016-08-02 23:16:09 +000021; NO-SIMD128-NOT: i8x16
Thomas Livelya3937b22018-09-14 21:21:42 +000022; SIMD128-NEXT: .param v128, v128{{$}}
23; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000024; SIMD128-NEXT: i8x16.add $push[[R:[0-9]+]]=, $0, $1{{$}}
25; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +000026define <16 x i8> @add_v16i8(<16 x i8> %x, <16 x i8> %y) {
27 %a = add <16 x i8> %x, %y
28 ret <16 x i8> %a
29}
30
Thomas Livelya3937b22018-09-14 21:21:42 +000031; CHECK-LABEL: sub_v16i8:
Derek Schuff39bf39f2016-08-02 23:16:09 +000032; NO-SIMD128-NOT: i8x16
Thomas Livelya3937b22018-09-14 21:21:42 +000033; SIMD128-NEXT: .param v128, v128{{$}}
34; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000035; SIMD128-NEXT: i8x16.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
36; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +000037define <16 x i8> @sub_v16i8(<16 x i8> %x, <16 x i8> %y) {
38 %a = sub <16 x i8> %x, %y
39 ret <16 x i8> %a
40}
41
Thomas Livelya3937b22018-09-14 21:21:42 +000042; CHECK-LABEL: mul_v16i8:
Derek Schuff39bf39f2016-08-02 23:16:09 +000043; NO-SIMD128-NOT: i8x16
Thomas Livelya3937b22018-09-14 21:21:42 +000044; SIMD128-NEXT: .param v128, v128{{$}}
45; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000046; SIMD128-NEXT: i8x16.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
47; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +000048define <16 x i8> @mul_v16i8(<16 x i8> %x, <16 x i8> %y) {
49 %a = mul <16 x i8> %x, %y
50 ret <16 x i8> %a
51}
52
Thomas Lively88b74432018-09-14 22:35:12 +000053; CHECK-LABEL: neg_v16i8:
54; NO-SIMD128-NOT: i8x16
55; SIMD128-NEXT: .param v128{{$}}
56; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000057; SIMD128-NEXT: i8x16.neg $push[[R:[0-9]+]]=, $0{{$}}
58; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +000059define <16 x i8> @neg_v16i8(<16 x i8> %x) {
60 %a = sub <16 x i8> <i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0,
61 i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0>,
62 %x
63 ret <16 x i8> %a
64}
65
Thomas Livelyf2550e02018-09-15 00:45:31 +000066; CHECK-LABEL: shl_v16i8:
67; NO-SIMD128-NOT: i8x16
68; SIMD128-NEXT: .param v128, i32{{$}}
69; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000070; SIMD128-NEXT: i8x16.shl $push[[R:[0-9]+]]=, $0, $1{{$}}
71; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +000072define <16 x i8> @shl_v16i8(<16 x i8> %v, i8 %x) {
73 %t = insertelement <16 x i8> undef, i8 %x, i32 0
74 %s = shufflevector <16 x i8> %t, <16 x i8> undef,
75 <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0,
76 i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
77 %a = shl <16 x i8> %v, %s
78 ret <16 x i8> %a
79}
80
81; CHECK-LABEL: shl_const_v16i8:
82; NO-SIMD128-NOT: i8x16
83; SIMD128-NEXT: .param v128{{$}}
84; SIMD128-NEXT: .result v128{{$}}
85; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 5
86; SIMD128-NEXT: i8x16.shl $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
87; SIMD128-NEXT: return $pop[[R]]{{$}}
88define <16 x i8> @shl_const_v16i8(<16 x i8> %v) {
89 %a = shl <16 x i8> %v,
90 <i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5,
91 i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5>
92 ret <16 x i8> %a
93}
94
95; CHECK-LABEL: shr_s_v16i8:
96; NO-SIMD128-NOT: i8x16
97; SIMD128-NEXT: .param v128, i32{{$}}
98; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000099; SIMD128-NEXT: i8x16.shr_s $push[[R:[0-9]+]]=, $0, $1{{$}}
100; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000101define <16 x i8> @shr_s_v16i8(<16 x i8> %v, i8 %x) {
102 %t = insertelement <16 x i8> undef, i8 %x, i32 0
103 %s = shufflevector <16 x i8> %t, <16 x i8> undef,
104 <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0,
105 i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
106 %a = ashr <16 x i8> %v, %s
107 ret <16 x i8> %a
108}
109
110; CHECK-LABEL: shr_u_v16i8:
111; NO-SIMD128-NOT: i8x16
112; SIMD128-NEXT: .param v128, i32{{$}}
113; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000114; SIMD128-NEXT: i8x16.shr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
115; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000116define <16 x i8> @shr_u_v16i8(<16 x i8> %v, i8 %x) {
117 %t = insertelement <16 x i8> undef, i8 %x, i32 0
118 %s = shufflevector <16 x i8> %t, <16 x i8> undef,
119 <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0,
120 i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
121 %a = lshr <16 x i8> %v, %s
122 ret <16 x i8> %a
123}
124
Thomas Livelya3937b22018-09-14 21:21:42 +0000125; CHECK-LABEL: and_v16i8:
Thomas Livelyec71e012018-08-28 18:33:31 +0000126; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000127; SIMD128-NEXT: .param v128, v128{{$}}
128; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000129; SIMD128-NEXT: v128.and $push[[R:[0-9]+]]=, $0, $1{{$}}
130; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000131define <16 x i8> @and_v16i8(<16 x i8> %x, <16 x i8> %y) {
132 %a = and <16 x i8> %x, %y
133 ret <16 x i8> %a
134}
135
Thomas Livelya3937b22018-09-14 21:21:42 +0000136; CHECK-LABEL: or_v16i8:
Thomas Livelyec71e012018-08-28 18:33:31 +0000137; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000138; SIMD128-NEXT: .param v128, v128{{$}}
139; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000140; SIMD128-NEXT: v128.or $push[[R:[0-9]+]]=, $0, $1{{$}}
141; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000142define <16 x i8> @or_v16i8(<16 x i8> %x, <16 x i8> %y) {
143 %a = or <16 x i8> %x, %y
144 ret <16 x i8> %a
145}
146
Thomas Livelya3937b22018-09-14 21:21:42 +0000147; CHECK-LABEL: xor_v16i8:
Thomas Livelyec71e012018-08-28 18:33:31 +0000148; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000149; SIMD128-NEXT: .param v128, v128{{$}}
150; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000151; SIMD128-NEXT: v128.xor $push[[R:[0-9]+]]=, $0, $1{{$}}
152; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000153define <16 x i8> @xor_v16i8(<16 x i8> %x, <16 x i8> %y) {
154 %a = xor <16 x i8> %x, %y
155 ret <16 x i8> %a
156}
157
Thomas Livelya3937b22018-09-14 21:21:42 +0000158; CHECK-LABEL: not_v16i8:
Thomas Lively995ad612018-08-28 18:31:15 +0000159; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000160; SIMD128-NEXT: .param v128{{$}}
161; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000162; SIMD128-NEXT: v128.not $push[[R:[0-9]+]]=, $0{{$}}
163; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively995ad612018-08-28 18:31:15 +0000164define <16 x i8> @not_v16i8(<16 x i8> %x) {
165 %a = xor <16 x i8> %x, <i8 -1, i8 -1, i8 -1, i8 -1,
166 i8 -1, i8 -1, i8 -1, i8 -1,
167 i8 -1, i8 -1, i8 -1, i8 -1,
168 i8 -1, i8 -1, i8 -1, i8 -1>
169 ret <16 x i8> %a
170}
171
Thomas Lively5d461c92018-10-03 23:02:23 +0000172; CHECK-LABEL: bitselect_v16i8:
173; NO-SIMD128-NOT: v128
174; SIMD128-NEXT: .param v128, v128, v128{{$}}
175; SIMD128-NEXT: .result v128{{$}}
176; SIMD128-SLOW-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $0{{$}}
177; SIMD128-SLOW-NEXT: return $pop[[R]]{{$}}
178; SIMD128-FAST-NEXT: v128.and
179; SIMD128-FAST-NEXT: v128.not
180; SIMD128-FAST-NEXT: v128.and
181; SIMD128-FAST-NEXT: v128.or
182; SIMD128-FAST-NEXT: return
183define <16 x i8> @bitselect_v16i8(<16 x i8> %c, <16 x i8> %v1, <16 x i8> %v2) {
184 %masked_v1 = and <16 x i8> %c, %v1
185 %inv_mask = xor <16 x i8> %c,
186 <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
187 i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
188 %masked_v2 = and <16 x i8> %inv_mask, %v2
189 %a = or <16 x i8> %masked_v1, %masked_v2
190 ret <16 x i8> %a
191}
192
Derek Schuff39bf39f2016-08-02 23:16:09 +0000193; ==============================================================================
194; 8 x i16
195; ==============================================================================
Thomas Livelya3937b22018-09-14 21:21:42 +0000196; CHECK-LABEL: add_v8i16:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000197; NO-SIMD128-NOT: i16x8
Thomas Livelya3937b22018-09-14 21:21:42 +0000198; SIMD128-NEXT: .param v128, v128{{$}}
199; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000200; SIMD128-NEXT: i16x8.add $push[[R:[0-9]+]]=, $0, $1{{$}}
201; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000202define <8 x i16> @add_v8i16(<8 x i16> %x, <8 x i16> %y) {
203 %a = add <8 x i16> %x, %y
204 ret <8 x i16> %a
205}
206
Thomas Livelya3937b22018-09-14 21:21:42 +0000207; CHECK-LABEL: sub_v8i16:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000208; NO-SIMD128-NOT: i16x8
Thomas Livelya3937b22018-09-14 21:21:42 +0000209; SIMD128-NEXT: .param v128, v128{{$}}
210; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000211; SIMD128-NEXT: i16x8.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
212; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000213define <8 x i16> @sub_v8i16(<8 x i16> %x, <8 x i16> %y) {
214 %a = sub <8 x i16> %x, %y
215 ret <8 x i16> %a
216}
217
Thomas Livelya3937b22018-09-14 21:21:42 +0000218; CHECK-LABEL: mul_v8i16:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000219; NO-SIMD128-NOT: i16x8
Thomas Livelya3937b22018-09-14 21:21:42 +0000220; SIMD128-NEXT: .param v128, v128{{$}}
221; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000222; SIMD128-NEXT: i16x8.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
223; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000224define <8 x i16> @mul_v8i16(<8 x i16> %x, <8 x i16> %y) {
225 %a = mul <8 x i16> %x, %y
226 ret <8 x i16> %a
227}
228
Thomas Lively88b74432018-09-14 22:35:12 +0000229; CHECK-LABEL: neg_v8i16:
230; NO-SIMD128-NOT: i16x8
231; SIMD128-NEXT: .param v128{{$}}
232; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000233; SIMD128-NEXT: i16x8.neg $push[[R:[0-9]+]]=, $0{{$}}
234; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +0000235define <8 x i16> @neg_v8i16(<8 x i16> %x) {
236 %a = sub <8 x i16> <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>,
237 %x
238 ret <8 x i16> %a
239}
240
Thomas Livelyf2550e02018-09-15 00:45:31 +0000241; CHECK-LABEL: shl_v8i16:
242; NO-SIMD128-NOT: i16x8
243; SIMD128-NEXT: .param v128, i32{{$}}
244; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000245; SIMD128-NEXT: i16x8.shl $push[[R:[0-9]+]]=, $0, $1{{$}}
246; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000247define <8 x i16> @shl_v8i16(<8 x i16> %v, i16 %x) {
248 %t = insertelement <8 x i16> undef, i16 %x, i32 0
249 %s = shufflevector <8 x i16> %t, <8 x i16> undef,
250 <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
251 %a = shl <8 x i16> %v, %s
252 ret <8 x i16> %a
253}
254
255; CHECK-LABEL: shl_const_v8i16:
256; NO-SIMD128-NOT: i16x8
257; SIMD128-NEXT: .param v128{{$}}
258; SIMD128-NEXT: .result v128{{$}}
259; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 5
260; SIMD128-NEXT: i16x8.shl $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
261; SIMD128-NEXT: return $pop[[R]]{{$}}
262define <8 x i16> @shl_const_v8i16(<8 x i16> %v) {
263 %a = shl <8 x i16> %v,
264 <i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5>
265 ret <8 x i16> %a
266}
267
268; CHECK-LABEL: shr_s_v8i16:
269; NO-SIMD128-NOT: i16x8
270; SIMD128-NEXT: .param v128, i32{{$}}
271; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000272; SIMD128-NEXT: i16x8.shr_s $push[[R:[0-9]+]]=, $0, $1{{$}}
273; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000274define <8 x i16> @shr_s_v8i16(<8 x i16> %v, i16 %x) {
275 %t = insertelement <8 x i16> undef, i16 %x, i32 0
276 %s = shufflevector <8 x i16> %t, <8 x i16> undef,
277 <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
278 %a = ashr <8 x i16> %v, %s
279 ret <8 x i16> %a
280}
281
282; CHECK-LABEL: shr_u_v8i16:
283; NO-SIMD128-NOT: i16x8
284; SIMD128-NEXT: .param v128, i32{{$}}
285; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000286; SIMD128-NEXT: i16x8.shr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
287; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000288define <8 x i16> @shr_u_v8i16(<8 x i16> %v, i16 %x) {
289 %t = insertelement <8 x i16> undef, i16 %x, i32 0
290 %s = shufflevector <8 x i16> %t, <8 x i16> undef,
291 <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
292 %a = lshr <8 x i16> %v, %s
293 ret <8 x i16> %a
294}
295
Thomas Livelya3937b22018-09-14 21:21:42 +0000296; CHECK-LABEL: and_v8i16:
Thomas Livelyec71e012018-08-28 18:33:31 +0000297; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000298; SIMD128-NEXT: .param v128, v128{{$}}
299; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000300; SIMD128-NEXT: v128.and $push[[R:[0-9]+]]=, $0, $1{{$}}
301; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000302define <8 x i16> @and_v8i16(<8 x i16> %x, <8 x i16> %y) {
303 %a = and <8 x i16> %x, %y
304 ret <8 x i16> %a
305}
306
Thomas Livelya3937b22018-09-14 21:21:42 +0000307; CHECK-LABEL: or_v8i16:
Thomas Livelyec71e012018-08-28 18:33:31 +0000308; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000309; SIMD128-NEXT: .param v128, v128{{$}}
310; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000311; SIMD128-NEXT: v128.or $push[[R:[0-9]+]]=, $0, $1{{$}}
312; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000313define <8 x i16> @or_v8i16(<8 x i16> %x, <8 x i16> %y) {
314 %a = or <8 x i16> %x, %y
315 ret <8 x i16> %a
316}
317
Thomas Livelya3937b22018-09-14 21:21:42 +0000318; CHECK-LABEL: xor_v8i16:
Thomas Livelyec71e012018-08-28 18:33:31 +0000319; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000320; SIMD128-NEXT: .param v128, v128{{$}}
321; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000322; SIMD128-NEXT: v128.xor $push[[R:[0-9]+]]=, $0, $1{{$}}
323; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000324define <8 x i16> @xor_v8i16(<8 x i16> %x, <8 x i16> %y) {
325 %a = xor <8 x i16> %x, %y
326 ret <8 x i16> %a
327}
328
Thomas Livelya3937b22018-09-14 21:21:42 +0000329; CHECK-LABEL: not_v8i16:
Thomas Lively995ad612018-08-28 18:31:15 +0000330; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000331; SIMD128-NEXT: .param v128{{$}}
332; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000333; SIMD128-NEXT: v128.not $push[[R:[0-9]+]]=, $0{{$}}
334; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively995ad612018-08-28 18:31:15 +0000335define <8 x i16> @not_v8i16(<8 x i16> %x) {
336 %a = xor <8 x i16> %x, <i16 -1, i16 -1, i16 -1, i16 -1,
337 i16 -1, i16 -1, i16 -1, i16 -1>
338 ret <8 x i16> %a
339}
340
Thomas Lively5d461c92018-10-03 23:02:23 +0000341; CHECK-LABEL: bitselect_v8i16:
342; NO-SIMD128-NOT: v128
343; SIMD128-NEXT: .param v128, v128, v128{{$}}
344; SIMD128-NEXT: .result v128{{$}}
345; SIMD128-SLOW-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $0{{$}}
346; SIMD128-SLOW-NEXT: return $pop[[R]]{{$}}
347; SIMD128-FAST-NEXT: v128.and
348; SIMD128-FAST-NEXT: v128.not
349; SIMD128-FAST-NEXT: v128.and
350; SIMD128-FAST-NEXT: v128.or
351; SIMD128-FAST-NEXT: return
352define <8 x i16> @bitselect_v8i16(<8 x i16> %c, <8 x i16> %v1, <8 x i16> %v2) {
353 %masked_v1 = and <8 x i16> %v1, %c
354 %inv_mask = xor <8 x i16>
355 <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>,
356 %c
357 %masked_v2 = and <8 x i16> %v2, %inv_mask
358 %a = or <8 x i16> %masked_v1, %masked_v2
359 ret <8 x i16> %a
360}
361
Derek Schuff39bf39f2016-08-02 23:16:09 +0000362; ==============================================================================
363; 4 x i32
364; ==============================================================================
Thomas Livelya3937b22018-09-14 21:21:42 +0000365; CHECK-LABEL: add_v4i32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000366; NO-SIMD128-NOT: i32x4
Thomas Livelya3937b22018-09-14 21:21:42 +0000367; SIMD128-NEXT: .param v128, v128{{$}}
368; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000369; SIMD128-NEXT: i32x4.add $push[[R:[0-9]+]]=, $0, $1{{$}}
370; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000371define <4 x i32> @add_v4i32(<4 x i32> %x, <4 x i32> %y) {
372 %a = add <4 x i32> %x, %y
373 ret <4 x i32> %a
374}
375
Thomas Livelya3937b22018-09-14 21:21:42 +0000376; CHECK-LABEL: sub_v4i32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000377; NO-SIMD128-NOT: i32x4
Thomas Livelya3937b22018-09-14 21:21:42 +0000378; SIMD128-NEXT: .param v128, v128{{$}}
379; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000380; SIMD128-NEXT: i32x4.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
381; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000382define <4 x i32> @sub_v4i32(<4 x i32> %x, <4 x i32> %y) {
383 %a = sub <4 x i32> %x, %y
384 ret <4 x i32> %a
385}
386
Thomas Livelya3937b22018-09-14 21:21:42 +0000387; CHECK-LABEL: mul_v4i32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000388; NO-SIMD128-NOT: i32x4
Thomas Livelya3937b22018-09-14 21:21:42 +0000389; SIMD128-NEXT: .param v128, v128{{$}}
390; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000391; SIMD128-NEXT: i32x4.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
392; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000393define <4 x i32> @mul_v4i32(<4 x i32> %x, <4 x i32> %y) {
394 %a = mul <4 x i32> %x, %y
395 ret <4 x i32> %a
396}
397
Thomas Lively88b74432018-09-14 22:35:12 +0000398; CHECK-LABEL: neg_v4i32:
399; NO-SIMD128-NOT: i32x4
400; SIMD128-NEXT: .param v128{{$}}
401; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000402; SIMD128-NEXT: i32x4.neg $push[[R:[0-9]+]]=, $0{{$}}
403; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +0000404define <4 x i32> @neg_v4i32(<4 x i32> %x) {
405 %a = sub <4 x i32> <i32 0, i32 0, i32 0, i32 0>, %x
406 ret <4 x i32> %a
407}
408
Thomas Livelyf2550e02018-09-15 00:45:31 +0000409; CHECK-LABEL: shl_v4i32:
410; NO-SIMD128-NOT: i32x4
411; SIMD128-NEXT: .param v128, i32{{$}}
412; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000413; SIMD128-NEXT: i32x4.shl $push[[R:[0-9]+]]=, $0, $1{{$}}
414; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000415define <4 x i32> @shl_v4i32(<4 x i32> %v, i32 %x) {
416 %t = insertelement <4 x i32> undef, i32 %x, i32 0
417 %s = shufflevector <4 x i32> %t, <4 x i32> undef,
418 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
419 %a = shl <4 x i32> %v, %s
420 ret <4 x i32> %a
421}
422
423; CHECK-LABEL: shl_const_v4i32:
424; NO-SIMD128-NOT: i32x4
425; SIMD128-NEXT: .param v128{{$}}
426; SIMD128-NEXT: .result v128{{$}}
427; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 5
428; SIMD128-NEXT: i32x4.shl $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
429; SIMD128-NEXT: return $pop[[R]]{{$}}
430define <4 x i32> @shl_const_v4i32(<4 x i32> %v) {
431 %a = shl <4 x i32> %v, <i32 5, i32 5, i32 5, i32 5>
432 ret <4 x i32> %a
433}
434
435; CHECK-LABEL: shr_s_v4i32:
436; NO-SIMD128-NOT: i32x4
437; SIMD128-NEXT: .param v128, i32{{$}}
438; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000439; SIMD128-NEXT: i32x4.shr_s $push[[R:[0-9]+]]=, $0, $1{{$}}
440; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000441define <4 x i32> @shr_s_v4i32(<4 x i32> %v, i32 %x) {
442 %t = insertelement <4 x i32> undef, i32 %x, i32 0
443 %s = shufflevector <4 x i32> %t, <4 x i32> undef,
444 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
445 %a = ashr <4 x i32> %v, %s
446 ret <4 x i32> %a
447}
448
449; CHECK-LABEL: shr_u_v4i32:
450; NO-SIMD128-NOT: i32x4
451; SIMD128-NEXT: .param v128, i32{{$}}
452; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000453; SIMD128-NEXT: i32x4.shr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
454; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000455define <4 x i32> @shr_u_v4i32(<4 x i32> %v, i32 %x) {
456 %t = insertelement <4 x i32> undef, i32 %x, i32 0
457 %s = shufflevector <4 x i32> %t, <4 x i32> undef,
458 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
459 %a = lshr <4 x i32> %v, %s
460 ret <4 x i32> %a
461}
462
Thomas Livelya3937b22018-09-14 21:21:42 +0000463; CHECK-LABEL: and_v4i32:
Thomas Livelyec71e012018-08-28 18:33:31 +0000464; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000465; SIMD128-NEXT: .param v128, v128{{$}}
466; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000467; SIMD128-NEXT: v128.and $push[[R:[0-9]+]]=, $0, $1{{$}}
468; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000469define <4 x i32> @and_v4i32(<4 x i32> %x, <4 x i32> %y) {
470 %a = and <4 x i32> %x, %y
471 ret <4 x i32> %a
472}
473
Thomas Livelya3937b22018-09-14 21:21:42 +0000474; CHECK-LABEL: or_v4i32:
Thomas Livelyec71e012018-08-28 18:33:31 +0000475; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000476; SIMD128-NEXT: .param v128, v128{{$}}
477; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000478; SIMD128-NEXT: v128.or $push[[R:[0-9]+]]=, $0, $1{{$}}
479; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000480define <4 x i32> @or_v4i32(<4 x i32> %x, <4 x i32> %y) {
481 %a = or <4 x i32> %x, %y
482 ret <4 x i32> %a
483}
484
Thomas Livelya3937b22018-09-14 21:21:42 +0000485; CHECK-LABEL: xor_v4i32:
Thomas Livelyec71e012018-08-28 18:33:31 +0000486; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000487; SIMD128-NEXT: .param v128, v128{{$}}
488; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000489; SIMD128-NEXT: v128.xor $push[[R:[0-9]+]]=, $0, $1{{$}}
490; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000491define <4 x i32> @xor_v4i32(<4 x i32> %x, <4 x i32> %y) {
492 %a = xor <4 x i32> %x, %y
493 ret <4 x i32> %a
494}
495
Thomas Livelya3937b22018-09-14 21:21:42 +0000496; CHECK-LABEL: not_v4i32:
Thomas Lively995ad612018-08-28 18:31:15 +0000497; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000498; SIMD128-NEXT: .param v128{{$}}
499; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000500; SIMD128-NEXT: v128.not $push[[R:[0-9]+]]=, $0{{$}}
501; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively995ad612018-08-28 18:31:15 +0000502define <4 x i32> @not_v4i32(<4 x i32> %x) {
503 %a = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
504 ret <4 x i32> %a
505}
506
Thomas Lively5d461c92018-10-03 23:02:23 +0000507; CHECK-LABEL: bitselect_v4i32:
508; NO-SIMD128-NOT: v128
509; SIMD128-NEXT: .param v128, v128, v128{{$}}
510; SIMD128-NEXT: .result v128{{$}}
511; SIMD128-SLOW-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $0{{$}}
512; SIMD128-SLOW-NEXT: return $pop[[R]]{{$}}
513; SIMD128-FAST-NEXT: v128.not
514; SIMD128-FAST-NEXT: v128.and
515; SIMD128-FAST-NEXT: v128.and
516; SIMD128-FAST-NEXT: v128.or
517; SIMD128-FAST-NEXT: return
518define <4 x i32> @bitselect_v4i32(<4 x i32> %c, <4 x i32> %v1, <4 x i32> %v2) {
519 %masked_v1 = and <4 x i32> %c, %v1
520 %inv_mask = xor <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, %c
521 %masked_v2 = and <4 x i32> %inv_mask, %v2
522 %a = or <4 x i32> %masked_v2, %masked_v1
523 ret <4 x i32> %a
524}
525
Derek Schuff39bf39f2016-08-02 23:16:09 +0000526; ==============================================================================
Derek Schuff51ed1312018-08-07 21:24:01 +0000527; 2 x i64
528; ==============================================================================
Thomas Livelya3937b22018-09-14 21:21:42 +0000529; CHECK-LABEL: add_v2i64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000530; NO-SIMD128-NOT: i64x2
Heejin Ahn5831e9c2018-08-09 23:58:51 +0000531; SIMD128-VM-NOT: i64x2
Thomas Livelya3937b22018-09-14 21:21:42 +0000532; SIMD128-NEXT: .param v128, v128{{$}}
533; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000534; SIMD128-NEXT: i64x2.add $push[[R:[0-9]+]]=, $0, $1{{$}}
535; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000536define <2 x i64> @add_v2i64(<2 x i64> %x, <2 x i64> %y) {
537 %a = add <2 x i64> %x, %y
538 ret <2 x i64> %a
539}
540
Thomas Livelya3937b22018-09-14 21:21:42 +0000541; CHECK-LABEL: sub_v2i64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000542; NO-SIMD128-NOT: i64x2
Heejin Ahn5831e9c2018-08-09 23:58:51 +0000543; SIMD128-VM-NOT: i64x2
Thomas Livelya3937b22018-09-14 21:21:42 +0000544; SIMD128-NEXT: .param v128, v128{{$}}
545; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000546; SIMD128-NEXT: i64x2.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
547; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000548define <2 x i64> @sub_v2i64(<2 x i64> %x, <2 x i64> %y) {
549 %a = sub <2 x i64> %x, %y
550 ret <2 x i64> %a
551}
552
Thomas Lively2ee686d2018-08-22 23:06:27 +0000553; v2i64.mul is not in spec
Thomas Livelya3937b22018-09-14 21:21:42 +0000554; CHECK-LABEL: mul_v2i64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000555; NO-SIMD128-NOT: i64x2
Heejin Ahn5831e9c2018-08-09 23:58:51 +0000556; SIMD128-VM-NOT: i64x2
Thomas Lively2ee686d2018-08-22 23:06:27 +0000557; SIMD128-NOT: i64x2.mul
558; SIMD128: i64x2.extract_lane
559; SIMD128: i64.mul
Derek Schuff51ed1312018-08-07 21:24:01 +0000560define <2 x i64> @mul_v2i64(<2 x i64> %x, <2 x i64> %y) {
561 %a = mul <2 x i64> %x, %y
562 ret <2 x i64> %a
563}
564
Thomas Lively88b74432018-09-14 22:35:12 +0000565; CHECK-LABEL: neg_v2i64:
566; NO-SIMD128-NOT: i64x2
567; SIMD128-NEXT: .param v128{{$}}
568; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000569; SIMD128-NEXT: i64x2.neg $push[[R:[0-9]+]]=, $0{{$}}
570; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +0000571define <2 x i64> @neg_v2i64(<2 x i64> %x) {
572 %a = sub <2 x i64> <i64 0, i64 0>, %x
573 ret <2 x i64> %a
574}
575
Thomas Livelyf2550e02018-09-15 00:45:31 +0000576; CHECK-LABEL: shl_v2i64:
577; NO-SIMD128-NOT: i64x2
578; SIMD128-NEXT: .param v128, i32{{$}}
579; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000580; SIMD128-NEXT: i64x2.shl $push[[R:[0-9]+]]=, $0, $1{{$}}
581; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000582define <2 x i64> @shl_v2i64(<2 x i64> %v, i32 %x) {
583 %x2 = zext i32 %x to i64
584 %t = insertelement <2 x i64> undef, i64 %x2, i32 0
585 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
586 %a = shl <2 x i64> %v, %s
587 ret <2 x i64> %a
588}
589
590; CHECK-LABEL: shl_nozext_v2i64:
591; NO-SIMD128-NOT: i64x2
592; SIMD128-NEXT: .param v128, i64{{$}}
593; SIMD128-NEXT: .result v128{{$}}
594; SIMD128-NEXT: i32.wrap/i64 $push[[L0:[0-9]+]]=, $1{{$}}
595; SIMD128-NEXT: i64x2.shl $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
596; SIMD128-NEXT: return $pop[[R]]{{$}}
597define <2 x i64> @shl_nozext_v2i64(<2 x i64> %v, i64 %x) {
598 %t = insertelement <2 x i64> undef, i64 %x, i32 0
599 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
600 %a = shl <2 x i64> %v, %s
601 ret <2 x i64> %a
602}
603
604; CHECK-LABEL: shl_const_v2i64:
605; NO-SIMD128-NOT: i64x2
606; SIMD128-NEXT: .param v128{{$}}
607; SIMD128-NEXT: .result v128{{$}}
608; SIMD128-NEXT: i64.const $push[[L0:[0-9]+]]=, 5{{$}}
609; SIMD128-NEXT: i32.wrap/i64 $push[[L1:[0-9]+]]=, $pop[[L0]]{{$}}
610; SIMD128-NEXT: i64x2.shl $push[[R:[0-9]+]]=, $0, $pop[[L1]]{{$}}
611; SIMD128-NEXT: return $pop[[R]]{{$}}
612define <2 x i64> @shl_const_v2i64(<2 x i64> %v) {
613 %a = shl <2 x i64> %v, <i64 5, i64 5>
614 ret <2 x i64> %a
615}
616
617; CHECK-LABEL: shr_s_v2i64:
618; NO-SIMD128-NOT: i64x2
619; SIMD128-NEXT: .param v128, i32{{$}}
620; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000621; SIMD128-NEXT: i64x2.shr_s $push[[R:[0-9]+]]=, $0, $1{{$}}
622; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000623define <2 x i64> @shr_s_v2i64(<2 x i64> %v, i32 %x) {
624 %x2 = zext i32 %x to i64
625 %t = insertelement <2 x i64> undef, i64 %x2, i32 0
626 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
627 %a = ashr <2 x i64> %v, %s
628 ret <2 x i64> %a
629}
630
631; CHECK-LABEL: shr_s_nozext_v2i64:
632; NO-SIMD128-NOT: i64x2
633; SIMD128-NEXT: .param v128, i64{{$}}
634; SIMD128-NEXT: .result v128{{$}}
635; SIMD128-NEXT: i32.wrap/i64 $push[[L0:[0-9]+]]=, $1{{$}}
636; SIMD128-NEXT: i64x2.shr_s $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
637; SIMD128-NEXT: return $pop[[R]]{{$}}
638define <2 x i64> @shr_s_nozext_v2i64(<2 x i64> %v, i64 %x) {
639 %t = insertelement <2 x i64> undef, i64 %x, i32 0
640 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
641 %a = ashr <2 x i64> %v, %s
642 ret <2 x i64> %a
643}
644
645; CHECK-LABEL: shr_u_v2i64:
646; NO-SIMD128-NOT: i64x2
647; SIMD128-NEXT: .param v128, i32{{$}}
648; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000649; SIMD128-NEXT: i64x2.shr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
650; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000651define <2 x i64> @shr_u_v2i64(<2 x i64> %v, i32 %x) {
652 %x2 = zext i32 %x to i64
653 %t = insertelement <2 x i64> undef, i64 %x2, i32 0
654 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
655 %a = lshr <2 x i64> %v, %s
656 ret <2 x i64> %a
657}
658
659; CHECK-LABEL: shr_u_nozext_v2i64:
660; NO-SIMD128-NOT: i64x2
661; SIMD128-NEXT: .param v128, i64{{$}}
662; SIMD128-NEXT: .result v128{{$}}
663; SIMD128-NEXT: i32.wrap/i64 $push[[L0:[0-9]+]]=, $1{{$}}
664; SIMD128-NEXT: i64x2.shr_u $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
665; SIMD128-NEXT: return $pop[[R]]{{$}}
666define <2 x i64> @shr_u_nozext_v2i64(<2 x i64> %v, i64 %x) {
667 %t = insertelement <2 x i64> undef, i64 %x, i32 0
668 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
669 %a = lshr <2 x i64> %v, %s
670 ret <2 x i64> %a
671}
672
Thomas Livelya3937b22018-09-14 21:21:42 +0000673; CHECK-LABEL: and_v2i64:
Thomas Livelyec71e012018-08-28 18:33:31 +0000674; NO-SIMD128-NOT: v128
675; SIMD128-VM-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000676; SIMD128-NEXT: .param v128, v128{{$}}
677; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000678; SIMD128-NEXT: v128.and $push[[R:[0-9]+]]=, $0, $1{{$}}
679; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000680define <2 x i64> @and_v2i64(<2 x i64> %x, <2 x i64> %y) {
681 %a = and <2 x i64> %x, %y
682 ret <2 x i64> %a
683}
684
Thomas Livelya3937b22018-09-14 21:21:42 +0000685; CHECK-LABEL: or_v2i64:
Thomas Livelyec71e012018-08-28 18:33:31 +0000686; NO-SIMD128-NOT: v128
687; SIMD128-VM-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000688; SIMD128-NEXT: .param v128, v128{{$}}
689; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000690; SIMD128-NEXT: v128.or $push[[R:[0-9]+]]=, $0, $1{{$}}
691; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000692define <2 x i64> @or_v2i64(<2 x i64> %x, <2 x i64> %y) {
693 %a = or <2 x i64> %x, %y
694 ret <2 x i64> %a
695}
696
Thomas Livelya3937b22018-09-14 21:21:42 +0000697; CHECK-LABEL: xor_v2i64:
Thomas Livelyec71e012018-08-28 18:33:31 +0000698; NO-SIMD128-NOT: v128
699; SIMD128-VM-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000700; SIMD128-NEXT: .param v128, v128{{$}}
701; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000702; SIMD128-NEXT: v128.xor $push[[R:[0-9]+]]=, $0, $1{{$}}
703; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000704define <2 x i64> @xor_v2i64(<2 x i64> %x, <2 x i64> %y) {
705 %a = xor <2 x i64> %x, %y
706 ret <2 x i64> %a
707}
708
Thomas Livelya3937b22018-09-14 21:21:42 +0000709; CHECK-LABEL: not_v2i64:
Thomas Lively995ad612018-08-28 18:31:15 +0000710; NO-SIMD128-NOT: v128
711; SIMD128-VM-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000712; SIMD128-NEXT: .param v128{{$}}
713; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000714; SIMD128-NEXT: v128.not $push[[R:[0-9]+]]=, $0{{$}}
715; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively995ad612018-08-28 18:31:15 +0000716define <2 x i64> @not_v2i64(<2 x i64> %x) {
717 %a = xor <2 x i64> %x, <i64 -1, i64 -1>
718 ret <2 x i64> %a
719}
720
Thomas Lively5d461c92018-10-03 23:02:23 +0000721; CHECK-LABEL: bitselect_v2i64:
722; NO-SIMD128-NOT: v128
723; SIMD128-VM-NOT: v128
724; SIMD128-NEXT: .param v128, v128, v128{{$}}
725; SIMD128-NEXT: .result v128{{$}}
726; SIMD128-SLOW-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $0{{$}}
727; SIMD128-SLOW-NEXT: return $pop[[R]]{{$}}
728; SIMD128-FAST-NEXT: v128.not
729; SIMD128-FAST-NEXT: v128.and
730; SIMD128-FAST-NEXT: v128.and
731; SIMD128-FAST-NEXT: v128.or
732; SIMD128-FAST-NEXT: return
733define <2 x i64> @bitselect_v2i64(<2 x i64> %c, <2 x i64> %v1, <2 x i64> %v2) {
734 %masked_v1 = and <2 x i64> %v1, %c
735 %inv_mask = xor <2 x i64> <i64 -1, i64 -1>, %c
736 %masked_v2 = and <2 x i64> %v2, %inv_mask
737 %a = or <2 x i64> %masked_v2, %masked_v1
738 ret <2 x i64> %a
739}
740
Derek Schuff51ed1312018-08-07 21:24:01 +0000741; ==============================================================================
Derek Schuff39bf39f2016-08-02 23:16:09 +0000742; 4 x float
743; ==============================================================================
Thomas Lively88b74432018-09-14 22:35:12 +0000744; CHECK-LABEL: neg_v4f32:
745; NO-SIMD128-NOT: f32x4
746; SIMD128-NEXT: .param v128{{$}}
747; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000748; SIMD128-NEXT: f32x4.neg $push[[R:[0-9]+]]=, $0{{$}}
749; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +0000750define <4 x float> @neg_v4f32(<4 x float> %x) {
Thomas Lively108e98e2018-10-10 01:09:09 +0000751 ; nsz makes this semantically equivalent to flipping sign bit
752 %a = fsub nsz <4 x float> <float 0.0, float 0.0, float 0.0, float 0.0>, %x
Thomas Lively88b74432018-09-14 22:35:12 +0000753 ret <4 x float> %a
754}
755
Thomas Livelyaaf4e2c2018-09-18 21:45:12 +0000756; CHECK-LABEL: abs_v4f32:
757; NO-SIMD128-NOT: f32x4
758; SIMD128-NEXT: .param v128{{$}}
759; SIMD128-NEXT: .result v128{{$}}
Thomas Lively58615362018-09-24 23:42:07 +0000760; SIMD128-NEXT: f32x4.abs $push[[R:[0-9]+]]=, $0{{$}}
761; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyaaf4e2c2018-09-18 21:45:12 +0000762declare <4 x float> @llvm.fabs.v4f32(<4 x float>) nounwind readnone
763define <4 x float> @abs_v4f32(<4 x float> %x) {
764 %a = call <4 x float> @llvm.fabs.v4f32(<4 x float> %x)
765 ret <4 x float> %a
766}
767
Thomas Livelya3937b22018-09-14 21:21:42 +0000768; CHECK-LABEL: add_v4f32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000769; NO-SIMD128-NOT: f32x4
Thomas Livelya3937b22018-09-14 21:21:42 +0000770; SIMD128-NEXT: .param v128, v128{{$}}
771; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000772; SIMD128-NEXT: f32x4.add $push[[R:[0-9]+]]=, $0, $1{{$}}
773; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000774define <4 x float> @add_v4f32(<4 x float> %x, <4 x float> %y) {
775 %a = fadd <4 x float> %x, %y
776 ret <4 x float> %a
777}
778
Thomas Livelya3937b22018-09-14 21:21:42 +0000779; CHECK-LABEL: sub_v4f32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000780; NO-SIMD128-NOT: f32x4
Thomas Livelya3937b22018-09-14 21:21:42 +0000781; SIMD128-NEXT: .param v128, v128{{$}}
782; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000783; SIMD128-NEXT: f32x4.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
784; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000785define <4 x float> @sub_v4f32(<4 x float> %x, <4 x float> %y) {
786 %a = fsub <4 x float> %x, %y
787 ret <4 x float> %a
788}
789
Thomas Livelya3937b22018-09-14 21:21:42 +0000790; CHECK-LABEL: div_v4f32:
Derek Schuff51ed1312018-08-07 21:24:01 +0000791; NO-SIMD128-NOT: f32x4
Thomas Livelya3937b22018-09-14 21:21:42 +0000792; SIMD128-NEXT: .param v128, v128{{$}}
793; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000794; SIMD128-NEXT: f32x4.div $push[[R:[0-9]+]]=, $0, $1{{$}}
795; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000796define <4 x float> @div_v4f32(<4 x float> %x, <4 x float> %y) {
797 %a = fdiv <4 x float> %x, %y
798 ret <4 x float> %a
799}
800
Thomas Livelya3937b22018-09-14 21:21:42 +0000801; CHECK-LABEL: mul_v4f32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000802; NO-SIMD128-NOT: f32x4
Thomas Livelya3937b22018-09-14 21:21:42 +0000803; SIMD128-NEXT: .param v128, v128{{$}}
804; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000805; SIMD128-NEXT: f32x4.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
806; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000807define <4 x float> @mul_v4f32(<4 x float> %x, <4 x float> %y) {
808 %a = fmul <4 x float> %x, %y
809 ret <4 x float> %a
810}
811
Thomas Lively12da0f92018-09-25 03:39:28 +0000812; CHECK-LABEL: sqrt_v4f32:
813; NO-SIMD128-NOT: f32x4
814; SIMD128-NEXT: .param v128{{$}}
815; SIMD128-NEXT: .result v128{{$}}
816; SIMD128-NEXT: f32x4.sqrt $push[[R:[0-9]+]]=, $0{{$}}
817; SIMD128-NEXT: return $pop[[R]]{{$}}
818declare <4 x float> @llvm.sqrt.v4f32(<4 x float> %x)
819define <4 x float> @sqrt_v4f32(<4 x float> %x) {
820 %a = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %x)
821 ret <4 x float> %a
822}
823
Derek Schuff51ed1312018-08-07 21:24:01 +0000824; ==============================================================================
825; 2 x double
826; ==============================================================================
Thomas Lively88b74432018-09-14 22:35:12 +0000827; CHECK-LABEL: neg_v2f64:
828; NO-SIMD128-NOT: f64x2
829; SIMD128-NEXT: .param v128{{$}}
830; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000831; SIMD128-NEXT: f64x2.neg $push[[R:[0-9]+]]=, $0{{$}}
832; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +0000833define <2 x double> @neg_v2f64(<2 x double> %x) {
Thomas Lively108e98e2018-10-10 01:09:09 +0000834 ; nsz makes this semantically equivalent to flipping sign bit
835 %a = fsub nsz <2 x double> <double 0., double 0.>, %x
Thomas Lively88b74432018-09-14 22:35:12 +0000836 ret <2 x double> %a
837}
838
Thomas Livelyaaf4e2c2018-09-18 21:45:12 +0000839; CHECK-LABEL: abs_v2f64:
840; NO-SIMD128-NOT: f64x2
841; SIMD128-NEXT: .param v128{{$}}
842; SIMD128-NEXT: .result v128{{$}}
Thomas Lively58615362018-09-24 23:42:07 +0000843; SIMD128-NEXT: f64x2.abs $push[[R:[0-9]+]]=, $0{{$}}
844; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyaaf4e2c2018-09-18 21:45:12 +0000845declare <2 x double> @llvm.fabs.v2f64(<2 x double>) nounwind readnone
846define <2 x double> @abs_v2f64(<2 x double> %x) {
847 %a = call <2 x double> @llvm.fabs.v2f64(<2 x double> %x)
848 ret <2 x double> %a
849}
850
Thomas Livelya3937b22018-09-14 21:21:42 +0000851; CHECK-LABEL: add_v2f64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000852; NO-SIMD128-NOT: f64x2
Thomas Livelya3937b22018-09-14 21:21:42 +0000853; SIMD128-VM-NOT: f62x2
854; SIMD128-NEXT: .param v128, v128{{$}}
855; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000856; SIMD128-NEXT: f64x2.add $push[[R:[0-9]+]]=, $0, $1{{$}}
857; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000858define <2 x double> @add_v2f64(<2 x double> %x, <2 x double> %y) {
859 %a = fadd <2 x double> %x, %y
860 ret <2 x double> %a
861}
862
Thomas Livelya3937b22018-09-14 21:21:42 +0000863; CHECK-LABEL: sub_v2f64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000864; NO-SIMD128-NOT: f64x2
Thomas Livelya3937b22018-09-14 21:21:42 +0000865; SIMD128-VM-NOT: f62x2
866; SIMD128-NEXT: .param v128, v128{{$}}
867; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000868; SIMD128-NEXT: f64x2.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
869; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000870define <2 x double> @sub_v2f64(<2 x double> %x, <2 x double> %y) {
871 %a = fsub <2 x double> %x, %y
872 ret <2 x double> %a
873}
874
Thomas Livelya3937b22018-09-14 21:21:42 +0000875; CHECK-LABEL: div_v2f64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000876; NO-SIMD128-NOT: f64x2
Thomas Livelya3937b22018-09-14 21:21:42 +0000877; SIMD128-VM-NOT: f62x2
878; SIMD128-NEXT: .param v128, v128{{$}}
879; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000880; SIMD128-NEXT: f64x2.div $push[[R:[0-9]+]]=, $0, $1{{$}}
881; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000882define <2 x double> @div_v2f64(<2 x double> %x, <2 x double> %y) {
883 %a = fdiv <2 x double> %x, %y
884 ret <2 x double> %a
885}
886
Thomas Livelya3937b22018-09-14 21:21:42 +0000887; CHECK-LABEL: mul_v2f64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000888; NO-SIMD128-NOT: f64x2
Thomas Livelya3937b22018-09-14 21:21:42 +0000889; SIMD128-VM-NOT: f62x2
890; SIMD128-NEXT: .param v128, v128{{$}}
891; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000892; SIMD128-NEXT: f64x2.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
893; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000894define <2 x double> @mul_v2f64(<2 x double> %x, <2 x double> %y) {
895 %a = fmul <2 x double> %x, %y
896 ret <2 x double> %a
897}
Thomas Lively12da0f92018-09-25 03:39:28 +0000898
899; CHECK-LABEL: sqrt_v2f64:
900; NO-SIMD128-NOT: f64x2
901; SIMD128-NEXT: .param v128{{$}}
902; SIMD128-NEXT: .result v128{{$}}
903; SIMD128-NEXT: f64x2.sqrt $push[[R:[0-9]+]]=, $0{{$}}
904; SIMD128-NEXT: return $pop[[R]]{{$}}
905declare <2 x double> @llvm.sqrt.v2f64(<2 x double> %x)
906define <2 x double> @sqrt_v2f64(<2 x double> %x) {
907 %a = call <2 x double> @llvm.sqrt.v2f64(<2 x double> %x)
908 ret <2 x double> %a
909}