blob: 9b4962265985a55e13c3182216a724f0fac0eb11 [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
8; Test that basic SIMD128 arithmetic operations assemble as expected.
9
10target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
Sam Clegga5908002018-05-10 17:49:11 +000011target triple = "wasm32-unknown-unknown"
Derek Schuff39bf39f2016-08-02 23:16:09 +000012
Derek Schuff39bf39f2016-08-02 23:16:09 +000013; ==============================================================================
14; 16 x i8
15; ==============================================================================
Thomas Livelya3937b22018-09-14 21:21:42 +000016; CHECK-LABEL: add_v16i8:
Derek Schuff39bf39f2016-08-02 23:16:09 +000017; NO-SIMD128-NOT: i8x16
Thomas Livelya3937b22018-09-14 21:21:42 +000018; SIMD128-NEXT: .param v128, v128{{$}}
19; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000020; SIMD128-NEXT: i8x16.add $push[[R:[0-9]+]]=, $0, $1{{$}}
21; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +000022define <16 x i8> @add_v16i8(<16 x i8> %x, <16 x i8> %y) {
23 %a = add <16 x i8> %x, %y
24 ret <16 x i8> %a
25}
26
Thomas Livelya3937b22018-09-14 21:21:42 +000027; CHECK-LABEL: sub_v16i8:
Derek Schuff39bf39f2016-08-02 23:16:09 +000028; NO-SIMD128-NOT: i8x16
Thomas Livelya3937b22018-09-14 21:21:42 +000029; SIMD128-NEXT: .param v128, v128{{$}}
30; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000031; SIMD128-NEXT: i8x16.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
32; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +000033define <16 x i8> @sub_v16i8(<16 x i8> %x, <16 x i8> %y) {
34 %a = sub <16 x i8> %x, %y
35 ret <16 x i8> %a
36}
37
Thomas Livelya3937b22018-09-14 21:21:42 +000038; CHECK-LABEL: mul_v16i8:
Derek Schuff39bf39f2016-08-02 23:16:09 +000039; NO-SIMD128-NOT: i8x16
Thomas Livelya3937b22018-09-14 21:21:42 +000040; SIMD128-NEXT: .param v128, v128{{$}}
41; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000042; SIMD128-NEXT: i8x16.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
43; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +000044define <16 x i8> @mul_v16i8(<16 x i8> %x, <16 x i8> %y) {
45 %a = mul <16 x i8> %x, %y
46 ret <16 x i8> %a
47}
48
Thomas Lively88b74432018-09-14 22:35:12 +000049; CHECK-LABEL: neg_v16i8:
50; NO-SIMD128-NOT: i8x16
51; SIMD128-NEXT: .param v128{{$}}
52; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000053; SIMD128-NEXT: i8x16.neg $push[[R:[0-9]+]]=, $0{{$}}
54; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +000055define <16 x i8> @neg_v16i8(<16 x i8> %x) {
56 %a = sub <16 x i8> <i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0,
57 i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0>,
58 %x
59 ret <16 x i8> %a
60}
61
Thomas Livelyf2550e02018-09-15 00:45:31 +000062; CHECK-LABEL: shl_v16i8:
63; NO-SIMD128-NOT: i8x16
64; SIMD128-NEXT: .param v128, i32{{$}}
65; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000066; SIMD128-NEXT: i8x16.shl $push[[R:[0-9]+]]=, $0, $1{{$}}
67; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +000068define <16 x i8> @shl_v16i8(<16 x i8> %v, i8 %x) {
69 %t = insertelement <16 x i8> undef, i8 %x, i32 0
70 %s = shufflevector <16 x i8> %t, <16 x i8> undef,
71 <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0,
72 i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
73 %a = shl <16 x i8> %v, %s
74 ret <16 x i8> %a
75}
76
77; CHECK-LABEL: shl_const_v16i8:
78; NO-SIMD128-NOT: i8x16
79; SIMD128-NEXT: .param v128{{$}}
80; SIMD128-NEXT: .result v128{{$}}
81; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 5
82; SIMD128-NEXT: i8x16.shl $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
83; SIMD128-NEXT: return $pop[[R]]{{$}}
84define <16 x i8> @shl_const_v16i8(<16 x i8> %v) {
85 %a = shl <16 x i8> %v,
86 <i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5,
87 i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5>
88 ret <16 x i8> %a
89}
90
91; CHECK-LABEL: shr_s_v16i8:
92; NO-SIMD128-NOT: i8x16
93; SIMD128-NEXT: .param v128, i32{{$}}
94; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000095; SIMD128-NEXT: i8x16.shr_s $push[[R:[0-9]+]]=, $0, $1{{$}}
96; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +000097define <16 x i8> @shr_s_v16i8(<16 x i8> %v, i8 %x) {
98 %t = insertelement <16 x i8> undef, i8 %x, i32 0
99 %s = shufflevector <16 x i8> %t, <16 x i8> undef,
100 <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0,
101 i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
102 %a = ashr <16 x i8> %v, %s
103 ret <16 x i8> %a
104}
105
106; CHECK-LABEL: shr_u_v16i8:
107; NO-SIMD128-NOT: i8x16
108; SIMD128-NEXT: .param v128, i32{{$}}
109; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000110; SIMD128-NEXT: i8x16.shr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
111; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000112define <16 x i8> @shr_u_v16i8(<16 x i8> %v, i8 %x) {
113 %t = insertelement <16 x i8> undef, i8 %x, i32 0
114 %s = shufflevector <16 x i8> %t, <16 x i8> undef,
115 <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0,
116 i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
117 %a = lshr <16 x i8> %v, %s
118 ret <16 x i8> %a
119}
120
Thomas Livelya3937b22018-09-14 21:21:42 +0000121; CHECK-LABEL: and_v16i8:
Thomas Livelyec71e012018-08-28 18:33:31 +0000122; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000123; SIMD128-NEXT: .param v128, v128{{$}}
124; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000125; SIMD128-NEXT: v128.and $push[[R:[0-9]+]]=, $0, $1{{$}}
126; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000127define <16 x i8> @and_v16i8(<16 x i8> %x, <16 x i8> %y) {
128 %a = and <16 x i8> %x, %y
129 ret <16 x i8> %a
130}
131
Thomas Livelya3937b22018-09-14 21:21:42 +0000132; CHECK-LABEL: or_v16i8:
Thomas Livelyec71e012018-08-28 18:33:31 +0000133; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000134; SIMD128-NEXT: .param v128, v128{{$}}
135; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000136; SIMD128-NEXT: v128.or $push[[R:[0-9]+]]=, $0, $1{{$}}
137; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000138define <16 x i8> @or_v16i8(<16 x i8> %x, <16 x i8> %y) {
139 %a = or <16 x i8> %x, %y
140 ret <16 x i8> %a
141}
142
Thomas Livelya3937b22018-09-14 21:21:42 +0000143; CHECK-LABEL: xor_v16i8:
Thomas Livelyec71e012018-08-28 18:33:31 +0000144; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000145; SIMD128-NEXT: .param v128, v128{{$}}
146; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000147; SIMD128-NEXT: v128.xor $push[[R:[0-9]+]]=, $0, $1{{$}}
148; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000149define <16 x i8> @xor_v16i8(<16 x i8> %x, <16 x i8> %y) {
150 %a = xor <16 x i8> %x, %y
151 ret <16 x i8> %a
152}
153
Thomas Livelya3937b22018-09-14 21:21:42 +0000154; CHECK-LABEL: not_v16i8:
Thomas Lively995ad612018-08-28 18:31:15 +0000155; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000156; SIMD128-NEXT: .param v128{{$}}
157; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000158; SIMD128-NEXT: v128.not $push[[R:[0-9]+]]=, $0{{$}}
159; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively995ad612018-08-28 18:31:15 +0000160define <16 x i8> @not_v16i8(<16 x i8> %x) {
161 %a = xor <16 x i8> %x, <i8 -1, i8 -1, i8 -1, i8 -1,
162 i8 -1, i8 -1, i8 -1, i8 -1,
163 i8 -1, i8 -1, i8 -1, i8 -1,
164 i8 -1, i8 -1, i8 -1, i8 -1>
165 ret <16 x i8> %a
166}
167
Thomas Lively5d461c92018-10-03 23:02:23 +0000168; CHECK-LABEL: bitselect_v16i8:
169; NO-SIMD128-NOT: v128
170; SIMD128-NEXT: .param v128, v128, v128{{$}}
171; SIMD128-NEXT: .result v128{{$}}
172; SIMD128-SLOW-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $0{{$}}
173; SIMD128-SLOW-NEXT: return $pop[[R]]{{$}}
174; SIMD128-FAST-NEXT: v128.and
175; SIMD128-FAST-NEXT: v128.not
176; SIMD128-FAST-NEXT: v128.and
177; SIMD128-FAST-NEXT: v128.or
178; SIMD128-FAST-NEXT: return
179define <16 x i8> @bitselect_v16i8(<16 x i8> %c, <16 x i8> %v1, <16 x i8> %v2) {
180 %masked_v1 = and <16 x i8> %c, %v1
181 %inv_mask = xor <16 x i8> %c,
182 <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
183 i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
184 %masked_v2 = and <16 x i8> %inv_mask, %v2
185 %a = or <16 x i8> %masked_v1, %masked_v2
186 ret <16 x i8> %a
187}
188
Derek Schuff39bf39f2016-08-02 23:16:09 +0000189; ==============================================================================
190; 8 x i16
191; ==============================================================================
Thomas Livelya3937b22018-09-14 21:21:42 +0000192; CHECK-LABEL: add_v8i16:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000193; NO-SIMD128-NOT: i16x8
Thomas Livelya3937b22018-09-14 21:21:42 +0000194; SIMD128-NEXT: .param v128, v128{{$}}
195; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000196; SIMD128-NEXT: i16x8.add $push[[R:[0-9]+]]=, $0, $1{{$}}
197; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000198define <8 x i16> @add_v8i16(<8 x i16> %x, <8 x i16> %y) {
199 %a = add <8 x i16> %x, %y
200 ret <8 x i16> %a
201}
202
Thomas Livelya3937b22018-09-14 21:21:42 +0000203; CHECK-LABEL: sub_v8i16:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000204; NO-SIMD128-NOT: i16x8
Thomas Livelya3937b22018-09-14 21:21:42 +0000205; SIMD128-NEXT: .param v128, v128{{$}}
206; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000207; SIMD128-NEXT: i16x8.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
208; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000209define <8 x i16> @sub_v8i16(<8 x i16> %x, <8 x i16> %y) {
210 %a = sub <8 x i16> %x, %y
211 ret <8 x i16> %a
212}
213
Thomas Livelya3937b22018-09-14 21:21:42 +0000214; CHECK-LABEL: mul_v8i16:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000215; NO-SIMD128-NOT: i16x8
Thomas Livelya3937b22018-09-14 21:21:42 +0000216; SIMD128-NEXT: .param v128, v128{{$}}
217; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000218; SIMD128-NEXT: i16x8.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
219; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000220define <8 x i16> @mul_v8i16(<8 x i16> %x, <8 x i16> %y) {
221 %a = mul <8 x i16> %x, %y
222 ret <8 x i16> %a
223}
224
Thomas Lively88b74432018-09-14 22:35:12 +0000225; CHECK-LABEL: neg_v8i16:
226; NO-SIMD128-NOT: i16x8
227; SIMD128-NEXT: .param v128{{$}}
228; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000229; SIMD128-NEXT: i16x8.neg $push[[R:[0-9]+]]=, $0{{$}}
230; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +0000231define <8 x i16> @neg_v8i16(<8 x i16> %x) {
232 %a = sub <8 x i16> <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>,
233 %x
234 ret <8 x i16> %a
235}
236
Thomas Livelyf2550e02018-09-15 00:45:31 +0000237; CHECK-LABEL: shl_v8i16:
238; NO-SIMD128-NOT: i16x8
239; SIMD128-NEXT: .param v128, i32{{$}}
240; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000241; SIMD128-NEXT: i16x8.shl $push[[R:[0-9]+]]=, $0, $1{{$}}
242; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000243define <8 x i16> @shl_v8i16(<8 x i16> %v, i16 %x) {
244 %t = insertelement <8 x i16> undef, i16 %x, i32 0
245 %s = shufflevector <8 x i16> %t, <8 x i16> undef,
246 <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
247 %a = shl <8 x i16> %v, %s
248 ret <8 x i16> %a
249}
250
251; CHECK-LABEL: shl_const_v8i16:
252; NO-SIMD128-NOT: i16x8
253; SIMD128-NEXT: .param v128{{$}}
254; SIMD128-NEXT: .result v128{{$}}
255; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 5
256; SIMD128-NEXT: i16x8.shl $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
257; SIMD128-NEXT: return $pop[[R]]{{$}}
258define <8 x i16> @shl_const_v8i16(<8 x i16> %v) {
259 %a = shl <8 x i16> %v,
260 <i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5>
261 ret <8 x i16> %a
262}
263
264; CHECK-LABEL: shr_s_v8i16:
265; NO-SIMD128-NOT: i16x8
266; SIMD128-NEXT: .param v128, i32{{$}}
267; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000268; SIMD128-NEXT: i16x8.shr_s $push[[R:[0-9]+]]=, $0, $1{{$}}
269; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000270define <8 x i16> @shr_s_v8i16(<8 x i16> %v, i16 %x) {
271 %t = insertelement <8 x i16> undef, i16 %x, i32 0
272 %s = shufflevector <8 x i16> %t, <8 x i16> undef,
273 <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
274 %a = ashr <8 x i16> %v, %s
275 ret <8 x i16> %a
276}
277
278; CHECK-LABEL: shr_u_v8i16:
279; NO-SIMD128-NOT: i16x8
280; SIMD128-NEXT: .param v128, i32{{$}}
281; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000282; SIMD128-NEXT: i16x8.shr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
283; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000284define <8 x i16> @shr_u_v8i16(<8 x i16> %v, i16 %x) {
285 %t = insertelement <8 x i16> undef, i16 %x, i32 0
286 %s = shufflevector <8 x i16> %t, <8 x i16> undef,
287 <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
288 %a = lshr <8 x i16> %v, %s
289 ret <8 x i16> %a
290}
291
Thomas Livelya3937b22018-09-14 21:21:42 +0000292; CHECK-LABEL: and_v8i16:
Thomas Livelyec71e012018-08-28 18:33:31 +0000293; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000294; SIMD128-NEXT: .param v128, v128{{$}}
295; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000296; SIMD128-NEXT: v128.and $push[[R:[0-9]+]]=, $0, $1{{$}}
297; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000298define <8 x i16> @and_v8i16(<8 x i16> %x, <8 x i16> %y) {
299 %a = and <8 x i16> %x, %y
300 ret <8 x i16> %a
301}
302
Thomas Livelya3937b22018-09-14 21:21:42 +0000303; CHECK-LABEL: or_v8i16:
Thomas Livelyec71e012018-08-28 18:33:31 +0000304; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000305; SIMD128-NEXT: .param v128, v128{{$}}
306; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000307; SIMD128-NEXT: v128.or $push[[R:[0-9]+]]=, $0, $1{{$}}
308; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000309define <8 x i16> @or_v8i16(<8 x i16> %x, <8 x i16> %y) {
310 %a = or <8 x i16> %x, %y
311 ret <8 x i16> %a
312}
313
Thomas Livelya3937b22018-09-14 21:21:42 +0000314; CHECK-LABEL: xor_v8i16:
Thomas Livelyec71e012018-08-28 18:33:31 +0000315; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000316; SIMD128-NEXT: .param v128, v128{{$}}
317; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000318; SIMD128-NEXT: v128.xor $push[[R:[0-9]+]]=, $0, $1{{$}}
319; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000320define <8 x i16> @xor_v8i16(<8 x i16> %x, <8 x i16> %y) {
321 %a = xor <8 x i16> %x, %y
322 ret <8 x i16> %a
323}
324
Thomas Livelya3937b22018-09-14 21:21:42 +0000325; CHECK-LABEL: not_v8i16:
Thomas Lively995ad612018-08-28 18:31:15 +0000326; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000327; SIMD128-NEXT: .param v128{{$}}
328; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000329; SIMD128-NEXT: v128.not $push[[R:[0-9]+]]=, $0{{$}}
330; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively995ad612018-08-28 18:31:15 +0000331define <8 x i16> @not_v8i16(<8 x i16> %x) {
332 %a = xor <8 x i16> %x, <i16 -1, i16 -1, i16 -1, i16 -1,
333 i16 -1, i16 -1, i16 -1, i16 -1>
334 ret <8 x i16> %a
335}
336
Thomas Lively5d461c92018-10-03 23:02:23 +0000337; CHECK-LABEL: bitselect_v8i16:
338; NO-SIMD128-NOT: v128
339; SIMD128-NEXT: .param v128, v128, v128{{$}}
340; SIMD128-NEXT: .result v128{{$}}
341; SIMD128-SLOW-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $0{{$}}
342; SIMD128-SLOW-NEXT: return $pop[[R]]{{$}}
343; SIMD128-FAST-NEXT: v128.and
344; SIMD128-FAST-NEXT: v128.not
345; SIMD128-FAST-NEXT: v128.and
346; SIMD128-FAST-NEXT: v128.or
347; SIMD128-FAST-NEXT: return
348define <8 x i16> @bitselect_v8i16(<8 x i16> %c, <8 x i16> %v1, <8 x i16> %v2) {
349 %masked_v1 = and <8 x i16> %v1, %c
350 %inv_mask = xor <8 x i16>
351 <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>,
352 %c
353 %masked_v2 = and <8 x i16> %v2, %inv_mask
354 %a = or <8 x i16> %masked_v1, %masked_v2
355 ret <8 x i16> %a
356}
357
Derek Schuff39bf39f2016-08-02 23:16:09 +0000358; ==============================================================================
359; 4 x i32
360; ==============================================================================
Thomas Livelya3937b22018-09-14 21:21:42 +0000361; CHECK-LABEL: add_v4i32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000362; NO-SIMD128-NOT: i32x4
Thomas Livelya3937b22018-09-14 21:21:42 +0000363; SIMD128-NEXT: .param v128, v128{{$}}
364; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000365; SIMD128-NEXT: i32x4.add $push[[R:[0-9]+]]=, $0, $1{{$}}
366; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000367define <4 x i32> @add_v4i32(<4 x i32> %x, <4 x i32> %y) {
368 %a = add <4 x i32> %x, %y
369 ret <4 x i32> %a
370}
371
Thomas Livelya3937b22018-09-14 21:21:42 +0000372; CHECK-LABEL: sub_v4i32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000373; NO-SIMD128-NOT: i32x4
Thomas Livelya3937b22018-09-14 21:21:42 +0000374; SIMD128-NEXT: .param v128, v128{{$}}
375; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000376; SIMD128-NEXT: i32x4.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
377; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000378define <4 x i32> @sub_v4i32(<4 x i32> %x, <4 x i32> %y) {
379 %a = sub <4 x i32> %x, %y
380 ret <4 x i32> %a
381}
382
Thomas Livelya3937b22018-09-14 21:21:42 +0000383; CHECK-LABEL: mul_v4i32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000384; NO-SIMD128-NOT: i32x4
Thomas Livelya3937b22018-09-14 21:21:42 +0000385; SIMD128-NEXT: .param v128, v128{{$}}
386; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000387; SIMD128-NEXT: i32x4.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
388; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000389define <4 x i32> @mul_v4i32(<4 x i32> %x, <4 x i32> %y) {
390 %a = mul <4 x i32> %x, %y
391 ret <4 x i32> %a
392}
393
Thomas Lively88b74432018-09-14 22:35:12 +0000394; CHECK-LABEL: neg_v4i32:
395; NO-SIMD128-NOT: i32x4
396; SIMD128-NEXT: .param v128{{$}}
397; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000398; SIMD128-NEXT: i32x4.neg $push[[R:[0-9]+]]=, $0{{$}}
399; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +0000400define <4 x i32> @neg_v4i32(<4 x i32> %x) {
401 %a = sub <4 x i32> <i32 0, i32 0, i32 0, i32 0>, %x
402 ret <4 x i32> %a
403}
404
Thomas Livelyf2550e02018-09-15 00:45:31 +0000405; CHECK-LABEL: shl_v4i32:
406; NO-SIMD128-NOT: i32x4
407; SIMD128-NEXT: .param v128, i32{{$}}
408; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000409; SIMD128-NEXT: i32x4.shl $push[[R:[0-9]+]]=, $0, $1{{$}}
410; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000411define <4 x i32> @shl_v4i32(<4 x i32> %v, i32 %x) {
412 %t = insertelement <4 x i32> undef, i32 %x, i32 0
413 %s = shufflevector <4 x i32> %t, <4 x i32> undef,
414 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
415 %a = shl <4 x i32> %v, %s
416 ret <4 x i32> %a
417}
418
419; CHECK-LABEL: shl_const_v4i32:
420; NO-SIMD128-NOT: i32x4
421; SIMD128-NEXT: .param v128{{$}}
422; SIMD128-NEXT: .result v128{{$}}
423; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 5
424; SIMD128-NEXT: i32x4.shl $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
425; SIMD128-NEXT: return $pop[[R]]{{$}}
426define <4 x i32> @shl_const_v4i32(<4 x i32> %v) {
427 %a = shl <4 x i32> %v, <i32 5, i32 5, i32 5, i32 5>
428 ret <4 x i32> %a
429}
430
431; CHECK-LABEL: shr_s_v4i32:
432; NO-SIMD128-NOT: i32x4
433; SIMD128-NEXT: .param v128, i32{{$}}
434; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000435; SIMD128-NEXT: i32x4.shr_s $push[[R:[0-9]+]]=, $0, $1{{$}}
436; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000437define <4 x i32> @shr_s_v4i32(<4 x i32> %v, i32 %x) {
438 %t = insertelement <4 x i32> undef, i32 %x, i32 0
439 %s = shufflevector <4 x i32> %t, <4 x i32> undef,
440 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
441 %a = ashr <4 x i32> %v, %s
442 ret <4 x i32> %a
443}
444
445; CHECK-LABEL: shr_u_v4i32:
446; NO-SIMD128-NOT: i32x4
447; SIMD128-NEXT: .param v128, i32{{$}}
448; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000449; SIMD128-NEXT: i32x4.shr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
450; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000451define <4 x i32> @shr_u_v4i32(<4 x i32> %v, i32 %x) {
452 %t = insertelement <4 x i32> undef, i32 %x, i32 0
453 %s = shufflevector <4 x i32> %t, <4 x i32> undef,
454 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
455 %a = lshr <4 x i32> %v, %s
456 ret <4 x i32> %a
457}
458
Thomas Livelya3937b22018-09-14 21:21:42 +0000459; CHECK-LABEL: and_v4i32:
Thomas Livelyec71e012018-08-28 18:33:31 +0000460; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000461; SIMD128-NEXT: .param v128, v128{{$}}
462; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000463; SIMD128-NEXT: v128.and $push[[R:[0-9]+]]=, $0, $1{{$}}
464; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000465define <4 x i32> @and_v4i32(<4 x i32> %x, <4 x i32> %y) {
466 %a = and <4 x i32> %x, %y
467 ret <4 x i32> %a
468}
469
Thomas Livelya3937b22018-09-14 21:21:42 +0000470; CHECK-LABEL: or_v4i32:
Thomas Livelyec71e012018-08-28 18:33:31 +0000471; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000472; SIMD128-NEXT: .param v128, v128{{$}}
473; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000474; SIMD128-NEXT: v128.or $push[[R:[0-9]+]]=, $0, $1{{$}}
475; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000476define <4 x i32> @or_v4i32(<4 x i32> %x, <4 x i32> %y) {
477 %a = or <4 x i32> %x, %y
478 ret <4 x i32> %a
479}
480
Thomas Livelya3937b22018-09-14 21:21:42 +0000481; CHECK-LABEL: xor_v4i32:
Thomas Livelyec71e012018-08-28 18:33:31 +0000482; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000483; SIMD128-NEXT: .param v128, v128{{$}}
484; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000485; SIMD128-NEXT: v128.xor $push[[R:[0-9]+]]=, $0, $1{{$}}
486; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000487define <4 x i32> @xor_v4i32(<4 x i32> %x, <4 x i32> %y) {
488 %a = xor <4 x i32> %x, %y
489 ret <4 x i32> %a
490}
491
Thomas Livelya3937b22018-09-14 21:21:42 +0000492; CHECK-LABEL: not_v4i32:
Thomas Lively995ad612018-08-28 18:31:15 +0000493; NO-SIMD128-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000494; SIMD128-NEXT: .param v128{{$}}
495; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000496; SIMD128-NEXT: v128.not $push[[R:[0-9]+]]=, $0{{$}}
497; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively995ad612018-08-28 18:31:15 +0000498define <4 x i32> @not_v4i32(<4 x i32> %x) {
499 %a = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
500 ret <4 x i32> %a
501}
502
Thomas Lively5d461c92018-10-03 23:02:23 +0000503; CHECK-LABEL: bitselect_v4i32:
504; NO-SIMD128-NOT: v128
505; SIMD128-NEXT: .param v128, v128, v128{{$}}
506; SIMD128-NEXT: .result v128{{$}}
507; SIMD128-SLOW-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $0{{$}}
508; SIMD128-SLOW-NEXT: return $pop[[R]]{{$}}
509; SIMD128-FAST-NEXT: v128.not
510; SIMD128-FAST-NEXT: v128.and
511; SIMD128-FAST-NEXT: v128.and
512; SIMD128-FAST-NEXT: v128.or
513; SIMD128-FAST-NEXT: return
514define <4 x i32> @bitselect_v4i32(<4 x i32> %c, <4 x i32> %v1, <4 x i32> %v2) {
515 %masked_v1 = and <4 x i32> %c, %v1
516 %inv_mask = xor <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, %c
517 %masked_v2 = and <4 x i32> %inv_mask, %v2
518 %a = or <4 x i32> %masked_v2, %masked_v1
519 ret <4 x i32> %a
520}
521
Derek Schuff39bf39f2016-08-02 23:16:09 +0000522; ==============================================================================
Derek Schuff51ed1312018-08-07 21:24:01 +0000523; 2 x i64
524; ==============================================================================
Thomas Livelya3937b22018-09-14 21:21:42 +0000525; CHECK-LABEL: add_v2i64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000526; NO-SIMD128-NOT: i64x2
Heejin Ahn5831e9c2018-08-09 23:58:51 +0000527; SIMD128-VM-NOT: i64x2
Thomas Livelya3937b22018-09-14 21:21:42 +0000528; SIMD128-NEXT: .param v128, v128{{$}}
529; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000530; SIMD128-NEXT: i64x2.add $push[[R:[0-9]+]]=, $0, $1{{$}}
531; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000532define <2 x i64> @add_v2i64(<2 x i64> %x, <2 x i64> %y) {
533 %a = add <2 x i64> %x, %y
534 ret <2 x i64> %a
535}
536
Thomas Livelya3937b22018-09-14 21:21:42 +0000537; CHECK-LABEL: sub_v2i64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000538; NO-SIMD128-NOT: i64x2
Heejin Ahn5831e9c2018-08-09 23:58:51 +0000539; SIMD128-VM-NOT: i64x2
Thomas Livelya3937b22018-09-14 21:21:42 +0000540; SIMD128-NEXT: .param v128, v128{{$}}
541; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000542; SIMD128-NEXT: i64x2.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
543; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000544define <2 x i64> @sub_v2i64(<2 x i64> %x, <2 x i64> %y) {
545 %a = sub <2 x i64> %x, %y
546 ret <2 x i64> %a
547}
548
Thomas Lively2ee686d2018-08-22 23:06:27 +0000549; v2i64.mul is not in spec
Thomas Livelya3937b22018-09-14 21:21:42 +0000550; CHECK-LABEL: mul_v2i64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000551; NO-SIMD128-NOT: i64x2
Heejin Ahn5831e9c2018-08-09 23:58:51 +0000552; SIMD128-VM-NOT: i64x2
Thomas Lively2ee686d2018-08-22 23:06:27 +0000553; SIMD128-NOT: i64x2.mul
554; SIMD128: i64x2.extract_lane
555; SIMD128: i64.mul
Derek Schuff51ed1312018-08-07 21:24:01 +0000556define <2 x i64> @mul_v2i64(<2 x i64> %x, <2 x i64> %y) {
557 %a = mul <2 x i64> %x, %y
558 ret <2 x i64> %a
559}
560
Thomas Lively88b74432018-09-14 22:35:12 +0000561; CHECK-LABEL: neg_v2i64:
562; NO-SIMD128-NOT: i64x2
563; SIMD128-NEXT: .param v128{{$}}
564; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000565; SIMD128-NEXT: i64x2.neg $push[[R:[0-9]+]]=, $0{{$}}
566; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +0000567define <2 x i64> @neg_v2i64(<2 x i64> %x) {
568 %a = sub <2 x i64> <i64 0, i64 0>, %x
569 ret <2 x i64> %a
570}
571
Thomas Livelyf2550e02018-09-15 00:45:31 +0000572; CHECK-LABEL: shl_v2i64:
573; NO-SIMD128-NOT: i64x2
574; SIMD128-NEXT: .param v128, i32{{$}}
575; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000576; SIMD128-NEXT: i64x2.shl $push[[R:[0-9]+]]=, $0, $1{{$}}
577; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000578define <2 x i64> @shl_v2i64(<2 x i64> %v, i32 %x) {
579 %x2 = zext i32 %x to i64
580 %t = insertelement <2 x i64> undef, i64 %x2, i32 0
581 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
582 %a = shl <2 x i64> %v, %s
583 ret <2 x i64> %a
584}
585
586; CHECK-LABEL: shl_nozext_v2i64:
587; NO-SIMD128-NOT: i64x2
588; SIMD128-NEXT: .param v128, i64{{$}}
589; SIMD128-NEXT: .result v128{{$}}
590; SIMD128-NEXT: i32.wrap/i64 $push[[L0:[0-9]+]]=, $1{{$}}
591; SIMD128-NEXT: i64x2.shl $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
592; SIMD128-NEXT: return $pop[[R]]{{$}}
593define <2 x i64> @shl_nozext_v2i64(<2 x i64> %v, i64 %x) {
594 %t = insertelement <2 x i64> undef, i64 %x, i32 0
595 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
596 %a = shl <2 x i64> %v, %s
597 ret <2 x i64> %a
598}
599
600; CHECK-LABEL: shl_const_v2i64:
601; NO-SIMD128-NOT: i64x2
602; SIMD128-NEXT: .param v128{{$}}
603; SIMD128-NEXT: .result v128{{$}}
604; SIMD128-NEXT: i64.const $push[[L0:[0-9]+]]=, 5{{$}}
605; SIMD128-NEXT: i32.wrap/i64 $push[[L1:[0-9]+]]=, $pop[[L0]]{{$}}
606; SIMD128-NEXT: i64x2.shl $push[[R:[0-9]+]]=, $0, $pop[[L1]]{{$}}
607; SIMD128-NEXT: return $pop[[R]]{{$}}
608define <2 x i64> @shl_const_v2i64(<2 x i64> %v) {
609 %a = shl <2 x i64> %v, <i64 5, i64 5>
610 ret <2 x i64> %a
611}
612
613; CHECK-LABEL: shr_s_v2i64:
614; NO-SIMD128-NOT: i64x2
615; SIMD128-NEXT: .param v128, i32{{$}}
616; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000617; SIMD128-NEXT: i64x2.shr_s $push[[R:[0-9]+]]=, $0, $1{{$}}
618; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000619define <2 x i64> @shr_s_v2i64(<2 x i64> %v, i32 %x) {
620 %x2 = zext i32 %x to i64
621 %t = insertelement <2 x i64> undef, i64 %x2, i32 0
622 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
623 %a = ashr <2 x i64> %v, %s
624 ret <2 x i64> %a
625}
626
627; CHECK-LABEL: shr_s_nozext_v2i64:
628; NO-SIMD128-NOT: i64x2
629; SIMD128-NEXT: .param v128, i64{{$}}
630; SIMD128-NEXT: .result v128{{$}}
631; SIMD128-NEXT: i32.wrap/i64 $push[[L0:[0-9]+]]=, $1{{$}}
632; SIMD128-NEXT: i64x2.shr_s $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
633; SIMD128-NEXT: return $pop[[R]]{{$}}
634define <2 x i64> @shr_s_nozext_v2i64(<2 x i64> %v, i64 %x) {
635 %t = insertelement <2 x i64> undef, i64 %x, i32 0
636 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
637 %a = ashr <2 x i64> %v, %s
638 ret <2 x i64> %a
639}
640
641; CHECK-LABEL: shr_u_v2i64:
642; NO-SIMD128-NOT: i64x2
643; SIMD128-NEXT: .param v128, i32{{$}}
644; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000645; SIMD128-NEXT: i64x2.shr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
646; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000647define <2 x i64> @shr_u_v2i64(<2 x i64> %v, i32 %x) {
648 %x2 = zext i32 %x to i64
649 %t = insertelement <2 x i64> undef, i64 %x2, i32 0
650 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
651 %a = lshr <2 x i64> %v, %s
652 ret <2 x i64> %a
653}
654
655; CHECK-LABEL: shr_u_nozext_v2i64:
656; NO-SIMD128-NOT: i64x2
657; SIMD128-NEXT: .param v128, i64{{$}}
658; SIMD128-NEXT: .result v128{{$}}
659; SIMD128-NEXT: i32.wrap/i64 $push[[L0:[0-9]+]]=, $1{{$}}
660; SIMD128-NEXT: i64x2.shr_u $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
661; SIMD128-NEXT: return $pop[[R]]{{$}}
662define <2 x i64> @shr_u_nozext_v2i64(<2 x i64> %v, i64 %x) {
663 %t = insertelement <2 x i64> undef, i64 %x, i32 0
664 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
665 %a = lshr <2 x i64> %v, %s
666 ret <2 x i64> %a
667}
668
Thomas Livelya3937b22018-09-14 21:21:42 +0000669; CHECK-LABEL: and_v2i64:
Thomas Livelyec71e012018-08-28 18:33:31 +0000670; NO-SIMD128-NOT: v128
671; SIMD128-VM-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000672; SIMD128-NEXT: .param v128, v128{{$}}
673; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000674; SIMD128-NEXT: v128.and $push[[R:[0-9]+]]=, $0, $1{{$}}
675; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000676define <2 x i64> @and_v2i64(<2 x i64> %x, <2 x i64> %y) {
677 %a = and <2 x i64> %x, %y
678 ret <2 x i64> %a
679}
680
Thomas Livelya3937b22018-09-14 21:21:42 +0000681; CHECK-LABEL: or_v2i64:
Thomas Livelyec71e012018-08-28 18:33:31 +0000682; NO-SIMD128-NOT: v128
683; SIMD128-VM-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000684; SIMD128-NEXT: .param v128, v128{{$}}
685; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000686; SIMD128-NEXT: v128.or $push[[R:[0-9]+]]=, $0, $1{{$}}
687; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000688define <2 x i64> @or_v2i64(<2 x i64> %x, <2 x i64> %y) {
689 %a = or <2 x i64> %x, %y
690 ret <2 x i64> %a
691}
692
Thomas Livelya3937b22018-09-14 21:21:42 +0000693; CHECK-LABEL: xor_v2i64:
Thomas Livelyec71e012018-08-28 18:33:31 +0000694; NO-SIMD128-NOT: v128
695; SIMD128-VM-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000696; SIMD128-NEXT: .param v128, v128{{$}}
697; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000698; SIMD128-NEXT: v128.xor $push[[R:[0-9]+]]=, $0, $1{{$}}
699; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000700define <2 x i64> @xor_v2i64(<2 x i64> %x, <2 x i64> %y) {
701 %a = xor <2 x i64> %x, %y
702 ret <2 x i64> %a
703}
704
Thomas Livelya3937b22018-09-14 21:21:42 +0000705; CHECK-LABEL: not_v2i64:
Thomas Lively995ad612018-08-28 18:31:15 +0000706; NO-SIMD128-NOT: v128
707; SIMD128-VM-NOT: v128
Thomas Livelya3937b22018-09-14 21:21:42 +0000708; SIMD128-NEXT: .param v128{{$}}
709; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000710; SIMD128-NEXT: v128.not $push[[R:[0-9]+]]=, $0{{$}}
711; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively995ad612018-08-28 18:31:15 +0000712define <2 x i64> @not_v2i64(<2 x i64> %x) {
713 %a = xor <2 x i64> %x, <i64 -1, i64 -1>
714 ret <2 x i64> %a
715}
716
Thomas Lively5d461c92018-10-03 23:02:23 +0000717; CHECK-LABEL: bitselect_v2i64:
718; NO-SIMD128-NOT: v128
719; SIMD128-VM-NOT: v128
720; SIMD128-NEXT: .param v128, v128, v128{{$}}
721; SIMD128-NEXT: .result v128{{$}}
722; SIMD128-SLOW-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $0{{$}}
723; SIMD128-SLOW-NEXT: return $pop[[R]]{{$}}
724; SIMD128-FAST-NEXT: v128.not
725; SIMD128-FAST-NEXT: v128.and
726; SIMD128-FAST-NEXT: v128.and
727; SIMD128-FAST-NEXT: v128.or
728; SIMD128-FAST-NEXT: return
729define <2 x i64> @bitselect_v2i64(<2 x i64> %c, <2 x i64> %v1, <2 x i64> %v2) {
730 %masked_v1 = and <2 x i64> %v1, %c
731 %inv_mask = xor <2 x i64> <i64 -1, i64 -1>, %c
732 %masked_v2 = and <2 x i64> %v2, %inv_mask
733 %a = or <2 x i64> %masked_v2, %masked_v1
734 ret <2 x i64> %a
735}
736
Derek Schuff51ed1312018-08-07 21:24:01 +0000737; ==============================================================================
Derek Schuff39bf39f2016-08-02 23:16:09 +0000738; 4 x float
739; ==============================================================================
Thomas Lively88b74432018-09-14 22:35:12 +0000740; CHECK-LABEL: neg_v4f32:
741; NO-SIMD128-NOT: f32x4
742; SIMD128-NEXT: .param v128{{$}}
743; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000744; SIMD128-NEXT: f32x4.neg $push[[R:[0-9]+]]=, $0{{$}}
745; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +0000746define <4 x float> @neg_v4f32(<4 x float> %x) {
747 %a = fsub <4 x float> <float 0., float 0., float 0., float 0.>, %x
748 ret <4 x float> %a
749}
750
Thomas Livelyaaf4e2c2018-09-18 21:45:12 +0000751; CHECK-LABEL: abs_v4f32:
752; NO-SIMD128-NOT: f32x4
753; SIMD128-NEXT: .param v128{{$}}
754; SIMD128-NEXT: .result v128{{$}}
Thomas Lively58615362018-09-24 23:42:07 +0000755; SIMD128-NEXT: f32x4.abs $push[[R:[0-9]+]]=, $0{{$}}
756; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyaaf4e2c2018-09-18 21:45:12 +0000757declare <4 x float> @llvm.fabs.v4f32(<4 x float>) nounwind readnone
758define <4 x float> @abs_v4f32(<4 x float> %x) {
759 %a = call <4 x float> @llvm.fabs.v4f32(<4 x float> %x)
760 ret <4 x float> %a
761}
762
Thomas Livelya3937b22018-09-14 21:21:42 +0000763; CHECK-LABEL: add_v4f32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000764; NO-SIMD128-NOT: f32x4
Thomas Livelya3937b22018-09-14 21:21:42 +0000765; SIMD128-NEXT: .param v128, v128{{$}}
766; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000767; SIMD128-NEXT: f32x4.add $push[[R:[0-9]+]]=, $0, $1{{$}}
768; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000769define <4 x float> @add_v4f32(<4 x float> %x, <4 x float> %y) {
770 %a = fadd <4 x float> %x, %y
771 ret <4 x float> %a
772}
773
Thomas Livelya3937b22018-09-14 21:21:42 +0000774; CHECK-LABEL: sub_v4f32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000775; NO-SIMD128-NOT: f32x4
Thomas Livelya3937b22018-09-14 21:21:42 +0000776; SIMD128-NEXT: .param v128, v128{{$}}
777; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000778; SIMD128-NEXT: f32x4.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
779; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000780define <4 x float> @sub_v4f32(<4 x float> %x, <4 x float> %y) {
781 %a = fsub <4 x float> %x, %y
782 ret <4 x float> %a
783}
784
Thomas Livelya3937b22018-09-14 21:21:42 +0000785; CHECK-LABEL: div_v4f32:
Derek Schuff51ed1312018-08-07 21:24:01 +0000786; NO-SIMD128-NOT: f32x4
Thomas Livelya3937b22018-09-14 21:21:42 +0000787; SIMD128-NEXT: .param v128, v128{{$}}
788; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000789; SIMD128-NEXT: f32x4.div $push[[R:[0-9]+]]=, $0, $1{{$}}
790; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000791define <4 x float> @div_v4f32(<4 x float> %x, <4 x float> %y) {
792 %a = fdiv <4 x float> %x, %y
793 ret <4 x float> %a
794}
795
Thomas Livelya3937b22018-09-14 21:21:42 +0000796; CHECK-LABEL: mul_v4f32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000797; NO-SIMD128-NOT: f32x4
Thomas Livelya3937b22018-09-14 21:21:42 +0000798; SIMD128-NEXT: .param v128, v128{{$}}
799; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000800; SIMD128-NEXT: f32x4.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
801; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000802define <4 x float> @mul_v4f32(<4 x float> %x, <4 x float> %y) {
803 %a = fmul <4 x float> %x, %y
804 ret <4 x float> %a
805}
806
Thomas Lively12da0f92018-09-25 03:39:28 +0000807; CHECK-LABEL: sqrt_v4f32:
808; NO-SIMD128-NOT: f32x4
809; SIMD128-NEXT: .param v128{{$}}
810; SIMD128-NEXT: .result v128{{$}}
811; SIMD128-NEXT: f32x4.sqrt $push[[R:[0-9]+]]=, $0{{$}}
812; SIMD128-NEXT: return $pop[[R]]{{$}}
813declare <4 x float> @llvm.sqrt.v4f32(<4 x float> %x)
814define <4 x float> @sqrt_v4f32(<4 x float> %x) {
815 %a = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %x)
816 ret <4 x float> %a
817}
818
Derek Schuff51ed1312018-08-07 21:24:01 +0000819; ==============================================================================
820; 2 x double
821; ==============================================================================
Thomas Lively88b74432018-09-14 22:35:12 +0000822; CHECK-LABEL: neg_v2f64:
823; NO-SIMD128-NOT: f64x2
824; SIMD128-NEXT: .param v128{{$}}
825; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000826; SIMD128-NEXT: f64x2.neg $push[[R:[0-9]+]]=, $0{{$}}
827; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +0000828define <2 x double> @neg_v2f64(<2 x double> %x) {
829 %a = fsub <2 x double> <double 0., double 0.>, %x
830 ret <2 x double> %a
831}
832
Thomas Livelyaaf4e2c2018-09-18 21:45:12 +0000833; CHECK-LABEL: abs_v2f64:
834; NO-SIMD128-NOT: f64x2
835; SIMD128-NEXT: .param v128{{$}}
836; SIMD128-NEXT: .result v128{{$}}
Thomas Lively58615362018-09-24 23:42:07 +0000837; SIMD128-NEXT: f64x2.abs $push[[R:[0-9]+]]=, $0{{$}}
838; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyaaf4e2c2018-09-18 21:45:12 +0000839declare <2 x double> @llvm.fabs.v2f64(<2 x double>) nounwind readnone
840define <2 x double> @abs_v2f64(<2 x double> %x) {
841 %a = call <2 x double> @llvm.fabs.v2f64(<2 x double> %x)
842 ret <2 x double> %a
843}
844
Thomas Livelya3937b22018-09-14 21:21:42 +0000845; CHECK-LABEL: add_v2f64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000846; NO-SIMD128-NOT: f64x2
Thomas Livelya3937b22018-09-14 21:21:42 +0000847; SIMD128-VM-NOT: f62x2
848; SIMD128-NEXT: .param v128, v128{{$}}
849; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000850; SIMD128-NEXT: f64x2.add $push[[R:[0-9]+]]=, $0, $1{{$}}
851; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000852define <2 x double> @add_v2f64(<2 x double> %x, <2 x double> %y) {
853 %a = fadd <2 x double> %x, %y
854 ret <2 x double> %a
855}
856
Thomas Livelya3937b22018-09-14 21:21:42 +0000857; CHECK-LABEL: sub_v2f64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000858; NO-SIMD128-NOT: f64x2
Thomas Livelya3937b22018-09-14 21:21:42 +0000859; SIMD128-VM-NOT: f62x2
860; SIMD128-NEXT: .param v128, v128{{$}}
861; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000862; SIMD128-NEXT: f64x2.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
863; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000864define <2 x double> @sub_v2f64(<2 x double> %x, <2 x double> %y) {
865 %a = fsub <2 x double> %x, %y
866 ret <2 x double> %a
867}
868
Thomas Livelya3937b22018-09-14 21:21:42 +0000869; CHECK-LABEL: div_v2f64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000870; NO-SIMD128-NOT: f64x2
Thomas Livelya3937b22018-09-14 21:21:42 +0000871; SIMD128-VM-NOT: f62x2
872; SIMD128-NEXT: .param v128, v128{{$}}
873; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000874; SIMD128-NEXT: f64x2.div $push[[R:[0-9]+]]=, $0, $1{{$}}
875; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000876define <2 x double> @div_v2f64(<2 x double> %x, <2 x double> %y) {
877 %a = fdiv <2 x double> %x, %y
878 ret <2 x double> %a
879}
880
Thomas Livelya3937b22018-09-14 21:21:42 +0000881; CHECK-LABEL: mul_v2f64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000882; NO-SIMD128-NOT: f64x2
Thomas Livelya3937b22018-09-14 21:21:42 +0000883; SIMD128-VM-NOT: f62x2
884; SIMD128-NEXT: .param v128, v128{{$}}
885; SIMD128-NEXT: .result v128{{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000886; SIMD128-NEXT: f64x2.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
887; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000888define <2 x double> @mul_v2f64(<2 x double> %x, <2 x double> %y) {
889 %a = fmul <2 x double> %x, %y
890 ret <2 x double> %a
891}
Thomas Lively12da0f92018-09-25 03:39:28 +0000892
893; CHECK-LABEL: sqrt_v2f64:
894; NO-SIMD128-NOT: f64x2
895; SIMD128-NEXT: .param v128{{$}}
896; SIMD128-NEXT: .result v128{{$}}
897; SIMD128-NEXT: f64x2.sqrt $push[[R:[0-9]+]]=, $0{{$}}
898; SIMD128-NEXT: return $pop[[R]]{{$}}
899declare <2 x double> @llvm.sqrt.v2f64(<2 x double> %x)
900define <2 x double> @sqrt_v2f64(<2 x double> %x) {
901 %a = call <2 x double> @llvm.sqrt.v2f64(<2 x double> %x)
902 ret <2 x double> %a
903}