blob: 96d4e6573f1c1cf29442861e9c6d185bd5df17f5 [file] [log] [blame]
Thomas Livelyb6dac892018-12-21 06:58:15 +00001; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -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 -verify-machineinstrs -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
3; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -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 -verify-machineinstrs -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 -verify-machineinstrs -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 -verify-machineinstrs -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
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000022; SIMD128-NEXT: .functype add_v16i8 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000023; SIMD128-NEXT: i8x16.add $push[[R:[0-9]+]]=, $0, $1{{$}}
24; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +000025define <16 x i8> @add_v16i8(<16 x i8> %x, <16 x i8> %y) {
26 %a = add <16 x i8> %x, %y
27 ret <16 x i8> %a
28}
29
Thomas Livelya3937b22018-09-14 21:21:42 +000030; CHECK-LABEL: sub_v16i8:
Derek Schuff39bf39f2016-08-02 23:16:09 +000031; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000032; SIMD128-NEXT: .functype sub_v16i8 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000033; SIMD128-NEXT: i8x16.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
34; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +000035define <16 x i8> @sub_v16i8(<16 x i8> %x, <16 x i8> %y) {
36 %a = sub <16 x i8> %x, %y
37 ret <16 x i8> %a
38}
39
Thomas Livelya3937b22018-09-14 21:21:42 +000040; CHECK-LABEL: mul_v16i8:
Derek Schuff39bf39f2016-08-02 23:16:09 +000041; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000042; SIMD128-NEXT: .functype mul_v16i8 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000043; SIMD128-NEXT: i8x16.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
44; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +000045define <16 x i8> @mul_v16i8(<16 x i8> %x, <16 x i8> %y) {
46 %a = mul <16 x i8> %x, %y
47 ret <16 x i8> %a
48}
49
Thomas Lively88b74432018-09-14 22:35:12 +000050; CHECK-LABEL: neg_v16i8:
51; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000052; SIMD128-NEXT: .functype neg_v16i8 (v128) -> (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
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000064; SIMD128-NEXT: .functype shl_v16i8 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +000065; SIMD128-NEXT: i8x16.shl $push[[R:[0-9]+]]=, $0, $1{{$}}
66; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +000067define <16 x i8> @shl_v16i8(<16 x i8> %v, i8 %x) {
68 %t = insertelement <16 x i8> undef, i8 %x, i32 0
69 %s = shufflevector <16 x i8> %t, <16 x i8> undef,
70 <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0,
71 i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
72 %a = shl <16 x i8> %v, %s
73 ret <16 x i8> %a
74}
75
76; CHECK-LABEL: shl_const_v16i8:
77; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000078; SIMD128-NEXT: .functype shl_const_v16i8 (v128) -> (v128){{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +000079; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 5
80; SIMD128-NEXT: i8x16.shl $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
81; SIMD128-NEXT: return $pop[[R]]{{$}}
82define <16 x i8> @shl_const_v16i8(<16 x i8> %v) {
83 %a = shl <16 x i8> %v,
84 <i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5,
85 i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5>
86 ret <16 x i8> %a
87}
88
Thomas Livelyb2382c82018-11-02 00:39:57 +000089; CHECK-LABEL: shl_vec_v16i8:
90; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +000091; SIMD128-NEXT: .functype shl_vec_v16i8 (v128, v128) -> (v128){{$}}
Thomas Lively8dbf29af2018-12-20 02:10:22 +000092; SIMD128-NEXT: i8x16.extract_lane_s $push[[L0:[0-9]+]]=, $0, 0{{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +000093; SIMD128-NEXT: i8x16.extract_lane_u $push[[L1:[0-9]+]]=, $1, 0{{$}}
94; SIMD128-NEXT: i32.shl $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
95; SIMD128-NEXT: i8x16.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
96; Skip 14 lanes
Thomas Lively8dbf29af2018-12-20 02:10:22 +000097; SIMD128: i8x16.extract_lane_s $push[[L4:[0-9]+]]=, $0, 15{{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +000098; SIMD128-NEXT: i8x16.extract_lane_u $push[[L5:[0-9]+]]=, $1, 15{{$}}
99; SIMD128-NEXT: i32.shl $push[[L6:[0-9]+]]=, $pop[[L4]], $pop[[L5]]{{$}}
100; SIMD128-NEXT: i8x16.replace_lane $push[[R:[0-9]+]]=, $pop[[L7:[0-9]+]], 15, $pop[[L6]]{{$}}
101; SIMD128-NEXT: return $pop[[R]]{{$}}
102define <16 x i8> @shl_vec_v16i8(<16 x i8> %v, <16 x i8> %x) {
103 %a = shl <16 x i8> %v, %x
104 ret <16 x i8> %a
105}
106
Thomas Livelyf2550e02018-09-15 00:45:31 +0000107; CHECK-LABEL: shr_s_v16i8:
108; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000109; SIMD128-NEXT: .functype shr_s_v16i8 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000110; SIMD128-NEXT: i8x16.shr_s $push[[R:[0-9]+]]=, $0, $1{{$}}
111; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000112define <16 x i8> @shr_s_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 = ashr <16 x i8> %v, %s
118 ret <16 x i8> %a
119}
120
Thomas Livelyb2382c82018-11-02 00:39:57 +0000121; CHECK-LABEL: shr_s_vec_v16i8:
122; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000123; SIMD128-NEXT: .functype shr_s_vec_v16i8 (v128, v128) -> (v128){{$}}
Thomas Lively8dbf29af2018-12-20 02:10:22 +0000124; SIMD128-NEXT: i8x16.extract_lane_s $push[[L0:[0-9]+]]=, $0, 0{{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +0000125; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 24{{$}}
126; SIMD128-NEXT: i32.shl $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
127; SIMD128-NEXT: i32.const $push[[L3:[0-9]+]]=, 24{{$}}
128; SIMD128-NEXT: i32.shr_s $push[[L4:[0-9]+]]=, $pop[[L2]], $pop[[L3]]{{$}}
129; SIMD128-NEXT: i8x16.extract_lane_u $push[[L5:[0-9]+]]=, $1, 0{{$}}
130; SIMD128-NEXT: i32.shr_s $push[[L6:[0-9]+]]=, $pop[[L4]], $pop[[L5]]{{$}}
131; SIMD128-NEXT: i8x16.splat $push[[L7:[0-9]+]]=, $pop[[L6]]{{$}}
132; Skip 14 lanes
Thomas Lively8dbf29af2018-12-20 02:10:22 +0000133; SIMD128: i8x16.extract_lane_s $push[[L7:[0-9]+]]=, $0, 15{{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +0000134; SIMD128-NEXT: i32.const $push[[L8:[0-9]+]]=, 24{{$}}
135; SIMD128-NEXT: i32.shl $push[[L9:[0-9]+]]=, $pop[[L7]], $pop[[L8]]{{$}}
136; SIMD128-NEXT: i32.const $push[[L10:[0-9]+]]=, 24{{$}}
137; SIMD128-NEXT: i32.shr_s $push[[L11:[0-9]+]]=, $pop[[L9]], $pop[[L10]]{{$}}
138; SIMD128-NEXT: i8x16.extract_lane_u $push[[L12:[0-9]+]]=, $1, 15{{$}}
139; SIMD128-NEXT: i32.shr_s $push[[L13:[0-9]+]]=, $pop[[L11]], $pop[[L12]]{{$}}
140; SIMD128-NEXT: i8x16.replace_lane $push[[R:[0-9]+]]=, $pop[[L14:[0-9]+]], 15, $pop[[L13]]{{$}}
141; SIMD128-NEXT: return $pop[[R]]{{$}}
142define <16 x i8> @shr_s_vec_v16i8(<16 x i8> %v, <16 x i8> %x) {
143 %a = ashr <16 x i8> %v, %x
144 ret <16 x i8> %a
145}
146
Thomas Livelyf2550e02018-09-15 00:45:31 +0000147; CHECK-LABEL: shr_u_v16i8:
148; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000149; SIMD128-NEXT: .functype shr_u_v16i8 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000150; SIMD128-NEXT: i8x16.shr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
151; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000152define <16 x i8> @shr_u_v16i8(<16 x i8> %v, i8 %x) {
153 %t = insertelement <16 x i8> undef, i8 %x, i32 0
154 %s = shufflevector <16 x i8> %t, <16 x i8> undef,
155 <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0,
156 i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
157 %a = lshr <16 x i8> %v, %s
158 ret <16 x i8> %a
159}
160
Thomas Livelyb2382c82018-11-02 00:39:57 +0000161; CHECK-LABEL: shr_u_vec_v16i8:
162; NO-SIMD128-NOT: i8x16
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000163; SIMD128-NEXT: .functype shr_u_vec_v16i8 (v128, v128) -> (v128){{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +0000164; SIMD128-NEXT: i8x16.extract_lane_u $push[[L0:[0-9]+]]=, $0, 0{{$}}
165; SIMD128-NEXT: i8x16.extract_lane_u $push[[L1:[0-9]+]]=, $1, 0{{$}}
166; SIMD128-NEXT: i32.shr_u $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
167; SIMD128-NEXT: i8x16.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
168; Skip 14 lanes
169; SIMD128: i8x16.extract_lane_u $push[[L4:[0-9]+]]=, $0, 15{{$}}
170; SIMD128-NEXT: i8x16.extract_lane_u $push[[L5:[0-9]+]]=, $1, 15{{$}}
171; SIMD128-NEXT: i32.shr_u $push[[L6:[0-9]+]]=, $pop[[L4]], $pop[[L5]]{{$}}
172; SIMD128-NEXT: i8x16.replace_lane $push[[R:[0-9]+]]=, $pop[[L7:[0-9]+]], 15, $pop[[L6]]{{$}}
173; SIMD128-NEXT: return $pop[[R]]{{$}}
174define <16 x i8> @shr_u_vec_v16i8(<16 x i8> %v, <16 x i8> %x) {
175 %a = lshr <16 x i8> %v, %x
176 ret <16 x i8> %a
177}
178
Thomas Livelya3937b22018-09-14 21:21:42 +0000179; CHECK-LABEL: and_v16i8:
Thomas Livelyec71e012018-08-28 18:33:31 +0000180; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000181; SIMD128-NEXT: .functype and_v16i8 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000182; SIMD128-NEXT: v128.and $push[[R:[0-9]+]]=, $0, $1{{$}}
183; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000184define <16 x i8> @and_v16i8(<16 x i8> %x, <16 x i8> %y) {
185 %a = and <16 x i8> %x, %y
186 ret <16 x i8> %a
187}
188
Thomas Livelya3937b22018-09-14 21:21:42 +0000189; CHECK-LABEL: or_v16i8:
Thomas Livelyec71e012018-08-28 18:33:31 +0000190; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000191; SIMD128-NEXT: .functype or_v16i8 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000192; SIMD128-NEXT: v128.or $push[[R:[0-9]+]]=, $0, $1{{$}}
193; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000194define <16 x i8> @or_v16i8(<16 x i8> %x, <16 x i8> %y) {
195 %a = or <16 x i8> %x, %y
196 ret <16 x i8> %a
197}
198
Thomas Livelya3937b22018-09-14 21:21:42 +0000199; CHECK-LABEL: xor_v16i8:
Thomas Livelyec71e012018-08-28 18:33:31 +0000200; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000201; SIMD128-NEXT: .functype xor_v16i8 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000202; SIMD128-NEXT: v128.xor $push[[R:[0-9]+]]=, $0, $1{{$}}
203; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000204define <16 x i8> @xor_v16i8(<16 x i8> %x, <16 x i8> %y) {
205 %a = xor <16 x i8> %x, %y
206 ret <16 x i8> %a
207}
208
Thomas Livelya3937b22018-09-14 21:21:42 +0000209; CHECK-LABEL: not_v16i8:
Thomas Lively995ad612018-08-28 18:31:15 +0000210; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000211; SIMD128-NEXT: .functype not_v16i8 (v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000212; SIMD128-NEXT: v128.not $push[[R:[0-9]+]]=, $0{{$}}
213; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively995ad612018-08-28 18:31:15 +0000214define <16 x i8> @not_v16i8(<16 x i8> %x) {
215 %a = xor <16 x i8> %x, <i8 -1, i8 -1, i8 -1, i8 -1,
216 i8 -1, i8 -1, i8 -1, i8 -1,
217 i8 -1, i8 -1, i8 -1, i8 -1,
218 i8 -1, i8 -1, i8 -1, i8 -1>
219 ret <16 x i8> %a
220}
221
Thomas Lively5d461c92018-10-03 23:02:23 +0000222; CHECK-LABEL: bitselect_v16i8:
223; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000224; SIMD128-NEXT: .functype bitselect_v16i8 (v128, v128, v128) -> (v128){{$}}
Thomas Lively5d461c92018-10-03 23:02:23 +0000225; SIMD128-SLOW-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $0{{$}}
226; SIMD128-SLOW-NEXT: return $pop[[R]]{{$}}
227; SIMD128-FAST-NEXT: v128.and
228; SIMD128-FAST-NEXT: v128.not
229; SIMD128-FAST-NEXT: v128.and
230; SIMD128-FAST-NEXT: v128.or
231; SIMD128-FAST-NEXT: return
232define <16 x i8> @bitselect_v16i8(<16 x i8> %c, <16 x i8> %v1, <16 x i8> %v2) {
233 %masked_v1 = and <16 x i8> %c, %v1
234 %inv_mask = xor <16 x i8> %c,
235 <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1,
236 i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
237 %masked_v2 = and <16 x i8> %inv_mask, %v2
238 %a = or <16 x i8> %masked_v1, %masked_v2
239 ret <16 x i8> %a
240}
241
Derek Schuff39bf39f2016-08-02 23:16:09 +0000242; ==============================================================================
243; 8 x i16
244; ==============================================================================
Thomas Livelya3937b22018-09-14 21:21:42 +0000245; CHECK-LABEL: add_v8i16:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000246; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000247; SIMD128-NEXT: .functype add_v8i16 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000248; SIMD128-NEXT: i16x8.add $push[[R:[0-9]+]]=, $0, $1{{$}}
249; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000250define <8 x i16> @add_v8i16(<8 x i16> %x, <8 x i16> %y) {
251 %a = add <8 x i16> %x, %y
252 ret <8 x i16> %a
253}
254
Thomas Livelya3937b22018-09-14 21:21:42 +0000255; CHECK-LABEL: sub_v8i16:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000256; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000257; SIMD128-NEXT: .functype sub_v8i16 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000258; SIMD128-NEXT: i16x8.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
259; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000260define <8 x i16> @sub_v8i16(<8 x i16> %x, <8 x i16> %y) {
261 %a = sub <8 x i16> %x, %y
262 ret <8 x i16> %a
263}
264
Thomas Livelya3937b22018-09-14 21:21:42 +0000265; CHECK-LABEL: mul_v8i16:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000266; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000267; SIMD128-NEXT: .functype mul_v8i16 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000268; SIMD128-NEXT: i16x8.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
269; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000270define <8 x i16> @mul_v8i16(<8 x i16> %x, <8 x i16> %y) {
271 %a = mul <8 x i16> %x, %y
272 ret <8 x i16> %a
273}
274
Thomas Lively88b74432018-09-14 22:35:12 +0000275; CHECK-LABEL: neg_v8i16:
276; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000277; SIMD128-NEXT: .functype neg_v8i16 (v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000278; SIMD128-NEXT: i16x8.neg $push[[R:[0-9]+]]=, $0{{$}}
279; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +0000280define <8 x i16> @neg_v8i16(<8 x i16> %x) {
281 %a = sub <8 x i16> <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>,
282 %x
283 ret <8 x i16> %a
284}
285
Thomas Livelyf2550e02018-09-15 00:45:31 +0000286; CHECK-LABEL: shl_v8i16:
287; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000288; SIMD128-NEXT: .functype shl_v8i16 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000289; SIMD128-NEXT: i16x8.shl $push[[R:[0-9]+]]=, $0, $1{{$}}
290; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000291define <8 x i16> @shl_v8i16(<8 x i16> %v, i16 %x) {
292 %t = insertelement <8 x i16> undef, i16 %x, i32 0
293 %s = shufflevector <8 x i16> %t, <8 x i16> undef,
294 <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
295 %a = shl <8 x i16> %v, %s
296 ret <8 x i16> %a
297}
298
299; CHECK-LABEL: shl_const_v8i16:
300; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000301; SIMD128-NEXT: .functype shl_const_v8i16 (v128) -> (v128){{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000302; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 5
303; SIMD128-NEXT: i16x8.shl $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
304; SIMD128-NEXT: return $pop[[R]]{{$}}
305define <8 x i16> @shl_const_v8i16(<8 x i16> %v) {
306 %a = shl <8 x i16> %v,
307 <i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5>
308 ret <8 x i16> %a
309}
310
Thomas Livelyb2382c82018-11-02 00:39:57 +0000311; CHECK-LABEL: shl_vec_v8i16:
312; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000313; SIMD128-NEXT: .functype shl_vec_v8i16 (v128, v128) -> (v128){{$}}
Thomas Lively8dbf29af2018-12-20 02:10:22 +0000314; SIMD128-NEXT: i16x8.extract_lane_s $push[[L0:[0-9]+]]=, $0, 0{{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +0000315; SIMD128-NEXT: i16x8.extract_lane_u $push[[L1:[0-9]+]]=, $1, 0{{$}}
316; SIMD128-NEXT: i32.shl $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
317; SIMD128-NEXT: i16x8.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
318; Skip 6 lanes
Thomas Lively8dbf29af2018-12-20 02:10:22 +0000319; SIMD128: i16x8.extract_lane_s $push[[L4:[0-9]+]]=, $0, 7{{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +0000320; SIMD128-NEXT: i16x8.extract_lane_u $push[[L5:[0-9]+]]=, $1, 7{{$}}
321; SIMD128-NEXT: i32.shl $push[[L6:[0-9]+]]=, $pop[[L4]], $pop[[L5]]{{$}}
322; SIMD128-NEXT: i16x8.replace_lane $push[[R:[0-9]+]]=, $pop[[L7:[0-9]+]], 7, $pop[[L6]]{{$}}
323; SIMD128-NEXT: return $pop[[R]]{{$}}
324define <8 x i16> @shl_vec_v8i16(<8 x i16> %v, <8 x i16> %x) {
325 %a = shl <8 x i16> %v, %x
326 ret <8 x i16> %a
327}
328
Thomas Livelyf2550e02018-09-15 00:45:31 +0000329; CHECK-LABEL: shr_s_v8i16:
330; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000331; SIMD128-NEXT: .functype shr_s_v8i16 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000332; SIMD128-NEXT: i16x8.shr_s $push[[R:[0-9]+]]=, $0, $1{{$}}
333; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000334define <8 x i16> @shr_s_v8i16(<8 x i16> %v, i16 %x) {
335 %t = insertelement <8 x i16> undef, i16 %x, i32 0
336 %s = shufflevector <8 x i16> %t, <8 x i16> undef,
337 <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
338 %a = ashr <8 x i16> %v, %s
339 ret <8 x i16> %a
340}
341
Thomas Livelyb2382c82018-11-02 00:39:57 +0000342; CHECK-LABEL: shr_s_vec_v8i16:
343; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000344; SIMD128-NEXT: .functype shr_s_vec_v8i16 (v128, v128) -> (v128){{$}}
Thomas Lively8dbf29af2018-12-20 02:10:22 +0000345; SIMD128-NEXT: i16x8.extract_lane_s $push[[L0:[0-9]+]]=, $0, 0{{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +0000346; SIMD128-NEXT: i32.const $push[[L1:[0-9]+]]=, 16{{$}}
347; SIMD128-NEXT: i32.shl $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
348; SIMD128-NEXT: i32.const $push[[L3:[0-9]+]]=, 16{{$}}
349; SIMD128-NEXT: i32.shr_s $push[[L4:[0-9]+]]=, $pop[[L2]], $pop[[L3]]{{$}}
350; SIMD128-NEXT: i16x8.extract_lane_u $push[[L5:[0-9]+]]=, $1, 0{{$}}
351; SIMD128-NEXT: i32.shr_s $push[[L6:[0-9]+]]=, $pop[[L4]], $pop[[L5]]{{$}}
352; SIMD128-NEXT: i16x8.splat $push[[L7:[0-9]+]]=, $pop[[L6]]{{$}}
353; Skip 6 lanes
Thomas Lively8dbf29af2018-12-20 02:10:22 +0000354; SIMD128: i16x8.extract_lane_s $push[[L7:[0-9]+]]=, $0, 7{{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +0000355; SIMD128-NEXT: i32.const $push[[L8:[0-9]+]]=, 16{{$}}
356; SIMD128-NEXT: i32.shl $push[[L9:[0-9]+]]=, $pop[[L7]], $pop[[L8]]{{$}}
357; SIMD128-NEXT: i32.const $push[[L10:[0-9]+]]=, 16{{$}}
358; SIMD128-NEXT: i32.shr_s $push[[L11:[0-9]+]]=, $pop[[L9]], $pop[[L10]]{{$}}
359; SIMD128-NEXT: i16x8.extract_lane_u $push[[L12:[0-9]+]]=, $1, 7{{$}}
360; SIMD128-NEXT: i32.shr_s $push[[L13:[0-9]+]]=, $pop[[L11]], $pop[[L12]]{{$}}
361; SIMD128-NEXT: i16x8.replace_lane $push[[R:[0-9]+]]=, $pop[[L14:[0-9]+]], 7, $pop[[L13]]{{$}}
362; SIMD128-NEXT: return $pop[[R]]{{$}}
363define <8 x i16> @shr_s_vec_v8i16(<8 x i16> %v, <8 x i16> %x) {
364 %a = ashr <8 x i16> %v, %x
365 ret <8 x i16> %a
366}
367
Thomas Livelyf2550e02018-09-15 00:45:31 +0000368; CHECK-LABEL: shr_u_v8i16:
369; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000370; SIMD128-NEXT: .functype shr_u_v8i16 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000371; SIMD128-NEXT: i16x8.shr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
372; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000373define <8 x i16> @shr_u_v8i16(<8 x i16> %v, i16 %x) {
374 %t = insertelement <8 x i16> undef, i16 %x, i32 0
375 %s = shufflevector <8 x i16> %t, <8 x i16> undef,
376 <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
377 %a = lshr <8 x i16> %v, %s
378 ret <8 x i16> %a
379}
380
Thomas Livelyb2382c82018-11-02 00:39:57 +0000381; CHECK-LABEL: shr_u_vec_v8i16:
382; NO-SIMD128-NOT: i16x8
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000383; SIMD128-NEXT: .functype shr_u_vec_v8i16 (v128, v128) -> (v128){{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +0000384; SIMD128-NEXT: i16x8.extract_lane_u $push[[L0:[0-9]+]]=, $0, 0{{$}}
385; SIMD128-NEXT: i16x8.extract_lane_u $push[[L1:[0-9]+]]=, $1, 0{{$}}
386; SIMD128-NEXT: i32.shr_u $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
387; SIMD128-NEXT: i16x8.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
388; Skip 6 lanes
389; SIMD128: i16x8.extract_lane_u $push[[L4:[0-9]+]]=, $0, 7{{$}}
390; SIMD128-NEXT: i16x8.extract_lane_u $push[[L5:[0-9]+]]=, $1, 7{{$}}
391; SIMD128-NEXT: i32.shr_u $push[[L6:[0-9]+]]=, $pop[[L4]], $pop[[L5]]{{$}}
392; SIMD128-NEXT: i16x8.replace_lane $push[[R:[0-9]+]]=, $pop[[L7:[0-9]+]], 7, $pop[[L6]]{{$}}
393; SIMD128-NEXT: return $pop[[R]]{{$}}
394define <8 x i16> @shr_u_vec_v8i16(<8 x i16> %v, <8 x i16> %x) {
395 %a = lshr <8 x i16> %v, %x
396 ret <8 x i16> %a
397}
398
Thomas Livelya3937b22018-09-14 21:21:42 +0000399; CHECK-LABEL: and_v8i16:
Thomas Livelyec71e012018-08-28 18:33:31 +0000400; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000401; SIMD128-NEXT: .functype and_v8i16 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000402; SIMD128-NEXT: v128.and $push[[R:[0-9]+]]=, $0, $1{{$}}
403; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000404define <8 x i16> @and_v8i16(<8 x i16> %x, <8 x i16> %y) {
405 %a = and <8 x i16> %x, %y
406 ret <8 x i16> %a
407}
408
Thomas Livelya3937b22018-09-14 21:21:42 +0000409; CHECK-LABEL: or_v8i16:
Thomas Livelyec71e012018-08-28 18:33:31 +0000410; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000411; SIMD128-NEXT: .functype or_v8i16 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000412; SIMD128-NEXT: v128.or $push[[R:[0-9]+]]=, $0, $1{{$}}
413; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000414define <8 x i16> @or_v8i16(<8 x i16> %x, <8 x i16> %y) {
415 %a = or <8 x i16> %x, %y
416 ret <8 x i16> %a
417}
418
Thomas Livelya3937b22018-09-14 21:21:42 +0000419; CHECK-LABEL: xor_v8i16:
Thomas Livelyec71e012018-08-28 18:33:31 +0000420; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000421; SIMD128-NEXT: .functype xor_v8i16 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000422; SIMD128-NEXT: v128.xor $push[[R:[0-9]+]]=, $0, $1{{$}}
423; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000424define <8 x i16> @xor_v8i16(<8 x i16> %x, <8 x i16> %y) {
425 %a = xor <8 x i16> %x, %y
426 ret <8 x i16> %a
427}
428
Thomas Livelya3937b22018-09-14 21:21:42 +0000429; CHECK-LABEL: not_v8i16:
Thomas Lively995ad612018-08-28 18:31:15 +0000430; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000431; SIMD128-NEXT: .functype not_v8i16 (v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000432; SIMD128-NEXT: v128.not $push[[R:[0-9]+]]=, $0{{$}}
433; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively995ad612018-08-28 18:31:15 +0000434define <8 x i16> @not_v8i16(<8 x i16> %x) {
435 %a = xor <8 x i16> %x, <i16 -1, i16 -1, i16 -1, i16 -1,
436 i16 -1, i16 -1, i16 -1, i16 -1>
437 ret <8 x i16> %a
438}
439
Thomas Lively5d461c92018-10-03 23:02:23 +0000440; CHECK-LABEL: bitselect_v8i16:
441; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000442; SIMD128-NEXT: .functype bitselect_v8i16 (v128, v128, v128) -> (v128){{$}}
Thomas Lively5d461c92018-10-03 23:02:23 +0000443; SIMD128-SLOW-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $0{{$}}
444; SIMD128-SLOW-NEXT: return $pop[[R]]{{$}}
445; SIMD128-FAST-NEXT: v128.and
446; SIMD128-FAST-NEXT: v128.not
447; SIMD128-FAST-NEXT: v128.and
448; SIMD128-FAST-NEXT: v128.or
449; SIMD128-FAST-NEXT: return
450define <8 x i16> @bitselect_v8i16(<8 x i16> %c, <8 x i16> %v1, <8 x i16> %v2) {
451 %masked_v1 = and <8 x i16> %v1, %c
452 %inv_mask = xor <8 x i16>
453 <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>,
454 %c
455 %masked_v2 = and <8 x i16> %v2, %inv_mask
456 %a = or <8 x i16> %masked_v1, %masked_v2
457 ret <8 x i16> %a
458}
459
Derek Schuff39bf39f2016-08-02 23:16:09 +0000460; ==============================================================================
461; 4 x i32
462; ==============================================================================
Thomas Livelya3937b22018-09-14 21:21:42 +0000463; CHECK-LABEL: add_v4i32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000464; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000465; SIMD128-NEXT: .functype add_v4i32 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000466; SIMD128-NEXT: i32x4.add $push[[R:[0-9]+]]=, $0, $1{{$}}
467; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000468define <4 x i32> @add_v4i32(<4 x i32> %x, <4 x i32> %y) {
469 %a = add <4 x i32> %x, %y
470 ret <4 x i32> %a
471}
472
Thomas Livelya3937b22018-09-14 21:21:42 +0000473; CHECK-LABEL: sub_v4i32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000474; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000475; SIMD128-NEXT: .functype sub_v4i32 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000476; SIMD128-NEXT: i32x4.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
477; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000478define <4 x i32> @sub_v4i32(<4 x i32> %x, <4 x i32> %y) {
479 %a = sub <4 x i32> %x, %y
480 ret <4 x i32> %a
481}
482
Thomas Livelya3937b22018-09-14 21:21:42 +0000483; CHECK-LABEL: mul_v4i32:
Derek Schuff39bf39f2016-08-02 23:16:09 +0000484; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000485; SIMD128-NEXT: .functype mul_v4i32 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000486; SIMD128-NEXT: i32x4.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
487; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +0000488define <4 x i32> @mul_v4i32(<4 x i32> %x, <4 x i32> %y) {
489 %a = mul <4 x i32> %x, %y
490 ret <4 x i32> %a
491}
492
Thomas Lively88b74432018-09-14 22:35:12 +0000493; CHECK-LABEL: neg_v4i32:
494; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000495; SIMD128-NEXT: .functype neg_v4i32 (v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000496; SIMD128-NEXT: i32x4.neg $push[[R:[0-9]+]]=, $0{{$}}
497; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +0000498define <4 x i32> @neg_v4i32(<4 x i32> %x) {
499 %a = sub <4 x i32> <i32 0, i32 0, i32 0, i32 0>, %x
500 ret <4 x i32> %a
501}
502
Thomas Livelyf2550e02018-09-15 00:45:31 +0000503; CHECK-LABEL: shl_v4i32:
504; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000505; SIMD128-NEXT: .functype shl_v4i32 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000506; SIMD128-NEXT: i32x4.shl $push[[R:[0-9]+]]=, $0, $1{{$}}
507; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000508define <4 x i32> @shl_v4i32(<4 x i32> %v, i32 %x) {
509 %t = insertelement <4 x i32> undef, i32 %x, i32 0
510 %s = shufflevector <4 x i32> %t, <4 x i32> undef,
511 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
512 %a = shl <4 x i32> %v, %s
513 ret <4 x i32> %a
514}
515
516; CHECK-LABEL: shl_const_v4i32:
517; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000518; SIMD128-NEXT: .functype shl_const_v4i32 (v128) -> (v128){{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000519; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 5
520; SIMD128-NEXT: i32x4.shl $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
521; SIMD128-NEXT: return $pop[[R]]{{$}}
522define <4 x i32> @shl_const_v4i32(<4 x i32> %v) {
523 %a = shl <4 x i32> %v, <i32 5, i32 5, i32 5, i32 5>
524 ret <4 x i32> %a
525}
526
Thomas Livelyb2382c82018-11-02 00:39:57 +0000527; CHECK-LABEL: shl_vec_v4i32:
528; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000529; SIMD128-NEXT: .functype shl_vec_v4i32 (v128, v128) -> (v128){{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +0000530; SIMD128-NEXT: i32x4.extract_lane $push[[L0:[0-9]+]]=, $0, 0{{$}}
531; SIMD128-NEXT: i32x4.extract_lane $push[[L1:[0-9]+]]=, $1, 0{{$}}
532; SIMD128-NEXT: i32.shl $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
533; SIMD128-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
534; Skip 2 lanes
535; SIMD128: i32x4.extract_lane $push[[L4:[0-9]+]]=, $0, 3{{$}}
536; SIMD128-NEXT: i32x4.extract_lane $push[[L5:[0-9]+]]=, $1, 3{{$}}
537; SIMD128-NEXT: i32.shl $push[[L6:[0-9]+]]=, $pop[[L4]], $pop[[L5]]{{$}}
538; SIMD128-NEXT: i32x4.replace_lane $push[[R:[0-9]+]]=, $pop[[L7:[0-9]+]], 3, $pop[[L6]]{{$}}
539; SIMD128-NEXT: return $pop[[R]]{{$}}
540define <4 x i32> @shl_vec_v4i32(<4 x i32> %v, <4 x i32> %x) {
541 %a = shl <4 x i32> %v, %x
542 ret <4 x i32> %a
543}
544
Thomas Livelyf2550e02018-09-15 00:45:31 +0000545; CHECK-LABEL: shr_s_v4i32:
546; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000547; SIMD128-NEXT: .functype shr_s_v4i32 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000548; SIMD128-NEXT: i32x4.shr_s $push[[R:[0-9]+]]=, $0, $1{{$}}
549; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000550define <4 x i32> @shr_s_v4i32(<4 x i32> %v, i32 %x) {
551 %t = insertelement <4 x i32> undef, i32 %x, i32 0
552 %s = shufflevector <4 x i32> %t, <4 x i32> undef,
553 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
554 %a = ashr <4 x i32> %v, %s
555 ret <4 x i32> %a
556}
557
Thomas Livelyb2382c82018-11-02 00:39:57 +0000558; CHECK-LABEL: shr_s_vec_v4i32:
559; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000560; SIMD128-NEXT: .functype shr_s_vec_v4i32 (v128, v128) -> (v128){{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +0000561; SIMD128-NEXT: i32x4.extract_lane $push[[L0:[0-9]+]]=, $0, 0{{$}}
562; SIMD128-NEXT: i32x4.extract_lane $push[[L1:[0-9]+]]=, $1, 0{{$}}
563; SIMD128-NEXT: i32.shr_s $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
564; SIMD128-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
565; Skip 2 lanes
566; SIMD128: i32x4.extract_lane $push[[L4:[0-9]+]]=, $0, 3{{$}}
567; SIMD128-NEXT: i32x4.extract_lane $push[[L5:[0-9]+]]=, $1, 3{{$}}
568; SIMD128-NEXT: i32.shr_s $push[[L6:[0-9]+]]=, $pop[[L4]], $pop[[L5]]{{$}}
569; SIMD128-NEXT: i32x4.replace_lane $push[[R:[0-9]+]]=, $pop[[L7:[0-9]+]], 3, $pop[[L6]]{{$}}
570; SIMD128-NEXT: return $pop[[R]]{{$}}
571define <4 x i32> @shr_s_vec_v4i32(<4 x i32> %v, <4 x i32> %x) {
572 %a = ashr <4 x i32> %v, %x
573 ret <4 x i32> %a
574}
575
Thomas Livelyf2550e02018-09-15 00:45:31 +0000576; CHECK-LABEL: shr_u_v4i32:
577; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000578; SIMD128-NEXT: .functype shr_u_v4i32 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000579; SIMD128-NEXT: i32x4.shr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
580; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000581define <4 x i32> @shr_u_v4i32(<4 x i32> %v, i32 %x) {
582 %t = insertelement <4 x i32> undef, i32 %x, i32 0
583 %s = shufflevector <4 x i32> %t, <4 x i32> undef,
584 <4 x i32> <i32 0, i32 0, i32 0, i32 0>
585 %a = lshr <4 x i32> %v, %s
586 ret <4 x i32> %a
587}
588
Thomas Livelyb2382c82018-11-02 00:39:57 +0000589; CHECK-LABEL: shr_u_vec_v4i32:
590; NO-SIMD128-NOT: i32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000591; SIMD128-NEXT: .functype shr_u_vec_v4i32 (v128, v128) -> (v128){{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +0000592; SIMD128-NEXT: i32x4.extract_lane $push[[L0:[0-9]+]]=, $0, 0{{$}}
593; SIMD128-NEXT: i32x4.extract_lane $push[[L1:[0-9]+]]=, $1, 0{{$}}
594; SIMD128-NEXT: i32.shr_u $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
595; SIMD128-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
596; Skip 2 lanes
597; SIMD128: i32x4.extract_lane $push[[L4:[0-9]+]]=, $0, 3{{$}}
598; SIMD128-NEXT: i32x4.extract_lane $push[[L5:[0-9]+]]=, $1, 3{{$}}
599; SIMD128-NEXT: i32.shr_u $push[[L6:[0-9]+]]=, $pop[[L4]], $pop[[L5]]{{$}}
600; SIMD128-NEXT: i32x4.replace_lane $push[[R:[0-9]+]]=, $pop[[L7:[0-9]+]], 3, $pop[[L6]]{{$}}
601; SIMD128-NEXT: return $pop[[R]]{{$}}
602define <4 x i32> @shr_u_vec_v4i32(<4 x i32> %v, <4 x i32> %x) {
603 %a = lshr <4 x i32> %v, %x
604 ret <4 x i32> %a
605}
606
Thomas Livelya3937b22018-09-14 21:21:42 +0000607; CHECK-LABEL: and_v4i32:
Thomas Livelyec71e012018-08-28 18:33:31 +0000608; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000609; SIMD128-NEXT: .functype and_v4i32 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000610; SIMD128-NEXT: v128.and $push[[R:[0-9]+]]=, $0, $1{{$}}
611; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000612define <4 x i32> @and_v4i32(<4 x i32> %x, <4 x i32> %y) {
613 %a = and <4 x i32> %x, %y
614 ret <4 x i32> %a
615}
616
Thomas Livelya3937b22018-09-14 21:21:42 +0000617; CHECK-LABEL: or_v4i32:
Thomas Livelyec71e012018-08-28 18:33:31 +0000618; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000619; SIMD128-NEXT: .functype or_v4i32 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000620; SIMD128-NEXT: v128.or $push[[R:[0-9]+]]=, $0, $1{{$}}
621; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000622define <4 x i32> @or_v4i32(<4 x i32> %x, <4 x i32> %y) {
623 %a = or <4 x i32> %x, %y
624 ret <4 x i32> %a
625}
626
Thomas Livelya3937b22018-09-14 21:21:42 +0000627; CHECK-LABEL: xor_v4i32:
Thomas Livelyec71e012018-08-28 18:33:31 +0000628; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000629; SIMD128-NEXT: .functype xor_v4i32 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000630; SIMD128-NEXT: v128.xor $push[[R:[0-9]+]]=, $0, $1{{$}}
631; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000632define <4 x i32> @xor_v4i32(<4 x i32> %x, <4 x i32> %y) {
633 %a = xor <4 x i32> %x, %y
634 ret <4 x i32> %a
635}
636
Thomas Livelya3937b22018-09-14 21:21:42 +0000637; CHECK-LABEL: not_v4i32:
Thomas Lively995ad612018-08-28 18:31:15 +0000638; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000639; SIMD128-NEXT: .functype not_v4i32 (v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000640; SIMD128-NEXT: v128.not $push[[R:[0-9]+]]=, $0{{$}}
641; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively995ad612018-08-28 18:31:15 +0000642define <4 x i32> @not_v4i32(<4 x i32> %x) {
643 %a = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
644 ret <4 x i32> %a
645}
646
Thomas Lively5d461c92018-10-03 23:02:23 +0000647; CHECK-LABEL: bitselect_v4i32:
648; NO-SIMD128-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000649; SIMD128-NEXT: .functype bitselect_v4i32 (v128, v128, v128) -> (v128){{$}}
Thomas Lively5d461c92018-10-03 23:02:23 +0000650; SIMD128-SLOW-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $0{{$}}
651; SIMD128-SLOW-NEXT: return $pop[[R]]{{$}}
652; SIMD128-FAST-NEXT: v128.not
653; SIMD128-FAST-NEXT: v128.and
654; SIMD128-FAST-NEXT: v128.and
655; SIMD128-FAST-NEXT: v128.or
656; SIMD128-FAST-NEXT: return
657define <4 x i32> @bitselect_v4i32(<4 x i32> %c, <4 x i32> %v1, <4 x i32> %v2) {
658 %masked_v1 = and <4 x i32> %c, %v1
659 %inv_mask = xor <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, %c
660 %masked_v2 = and <4 x i32> %inv_mask, %v2
661 %a = or <4 x i32> %masked_v2, %masked_v1
662 ret <4 x i32> %a
663}
664
Derek Schuff39bf39f2016-08-02 23:16:09 +0000665; ==============================================================================
Derek Schuff51ed1312018-08-07 21:24:01 +0000666; 2 x i64
667; ==============================================================================
Thomas Livelya3937b22018-09-14 21:21:42 +0000668; CHECK-LABEL: add_v2i64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000669; NO-SIMD128-NOT: i64x2
Heejin Ahn5831e9c2018-08-09 23:58:51 +0000670; SIMD128-VM-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000671; SIMD128-NEXT: .functype add_v2i64 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000672; SIMD128-NEXT: i64x2.add $push[[R:[0-9]+]]=, $0, $1{{$}}
673; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000674define <2 x i64> @add_v2i64(<2 x i64> %x, <2 x i64> %y) {
675 %a = add <2 x i64> %x, %y
676 ret <2 x i64> %a
677}
678
Thomas Livelya3937b22018-09-14 21:21:42 +0000679; CHECK-LABEL: sub_v2i64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000680; NO-SIMD128-NOT: i64x2
Heejin Ahn5831e9c2018-08-09 23:58:51 +0000681; SIMD128-VM-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000682; SIMD128-NEXT: .functype sub_v2i64 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000683; SIMD128-NEXT: i64x2.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
684; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +0000685define <2 x i64> @sub_v2i64(<2 x i64> %x, <2 x i64> %y) {
686 %a = sub <2 x i64> %x, %y
687 ret <2 x i64> %a
688}
689
Thomas Lively2ee686d2018-08-22 23:06:27 +0000690; v2i64.mul is not in spec
Thomas Livelya3937b22018-09-14 21:21:42 +0000691; CHECK-LABEL: mul_v2i64:
Derek Schuff51ed1312018-08-07 21:24:01 +0000692; NO-SIMD128-NOT: i64x2
Heejin Ahn5831e9c2018-08-09 23:58:51 +0000693; SIMD128-VM-NOT: i64x2
Thomas Lively2ee686d2018-08-22 23:06:27 +0000694; SIMD128-NOT: i64x2.mul
695; SIMD128: i64x2.extract_lane
696; SIMD128: i64.mul
Derek Schuff51ed1312018-08-07 21:24:01 +0000697define <2 x i64> @mul_v2i64(<2 x i64> %x, <2 x i64> %y) {
698 %a = mul <2 x i64> %x, %y
699 ret <2 x i64> %a
700}
701
Thomas Lively88b74432018-09-14 22:35:12 +0000702; CHECK-LABEL: neg_v2i64:
703; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000704; SIMD128-NEXT: .functype neg_v2i64 (v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000705; SIMD128-NEXT: i64x2.neg $push[[R:[0-9]+]]=, $0{{$}}
706; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +0000707define <2 x i64> @neg_v2i64(<2 x i64> %x) {
708 %a = sub <2 x i64> <i64 0, i64 0>, %x
709 ret <2 x i64> %a
710}
711
Thomas Livelyf2550e02018-09-15 00:45:31 +0000712; CHECK-LABEL: shl_v2i64:
713; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000714; SIMD128-NEXT: .functype shl_v2i64 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000715; SIMD128-NEXT: i64x2.shl $push[[R:[0-9]+]]=, $0, $1{{$}}
716; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000717define <2 x i64> @shl_v2i64(<2 x i64> %v, i32 %x) {
718 %x2 = zext i32 %x to i64
719 %t = insertelement <2 x i64> undef, i64 %x2, i32 0
720 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
721 %a = shl <2 x i64> %v, %s
722 ret <2 x i64> %a
723}
724
725; CHECK-LABEL: shl_nozext_v2i64:
726; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000727; SIMD128-NEXT: .functype shl_nozext_v2i64 (v128, i64) -> (v128){{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000728; SIMD128-NEXT: i32.wrap/i64 $push[[L0:[0-9]+]]=, $1{{$}}
729; SIMD128-NEXT: i64x2.shl $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
730; SIMD128-NEXT: return $pop[[R]]{{$}}
731define <2 x i64> @shl_nozext_v2i64(<2 x i64> %v, i64 %x) {
732 %t = insertelement <2 x i64> undef, i64 %x, i32 0
733 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
734 %a = shl <2 x i64> %v, %s
735 ret <2 x i64> %a
736}
737
738; CHECK-LABEL: shl_const_v2i64:
739; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000740; SIMD128-NEXT: .functype shl_const_v2i64 (v128) -> (v128){{$}}
Thomas Lively55735d52018-10-20 01:31:18 +0000741; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 5{{$}}
742; SIMD128-NEXT: i64x2.shl $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000743; SIMD128-NEXT: return $pop[[R]]{{$}}
744define <2 x i64> @shl_const_v2i64(<2 x i64> %v) {
745 %a = shl <2 x i64> %v, <i64 5, i64 5>
746 ret <2 x i64> %a
747}
748
Thomas Livelyb2382c82018-11-02 00:39:57 +0000749; CHECK-LABEL: shl_vec_v2i64:
750; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000751; SIMD128-NEXT: .functype shl_vec_v2i64 (v128, v128) -> (v128){{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +0000752; SIMD128-NEXT: i64x2.extract_lane $push[[L0:[0-9]+]]=, $0, 0{{$}}
753; SIMD128-NEXT: i64x2.extract_lane $push[[L1:[0-9]+]]=, $1, 0{{$}}
754; SIMD128-NEXT: i64.shl $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
755; SIMD128-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
756; SIMD128-NEXT: i64x2.extract_lane $push[[L4:[0-9]+]]=, $0, 1{{$}}
757; SIMD128-NEXT: i64x2.extract_lane $push[[L5:[0-9]+]]=, $1, 1{{$}}
758; SIMD128-NEXT: i64.shl $push[[L6:[0-9]+]]=, $pop[[L4]], $pop[[L5]]{{$}}
759; SIMD128-NEXT: i64x2.replace_lane $push[[R:[0-9]+]]=, $pop[[L3]], 1, $pop[[L6]]{{$}}
760; SIMD128-NEXT: return $pop[[R]]{{$}}
761define <2 x i64> @shl_vec_v2i64(<2 x i64> %v, <2 x i64> %x) {
762 %a = shl <2 x i64> %v, %x
763 ret <2 x i64> %a
764}
765
Thomas Livelyf2550e02018-09-15 00:45:31 +0000766; CHECK-LABEL: shr_s_v2i64:
767; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000768; SIMD128-NEXT: .functype shr_s_v2i64 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000769; SIMD128-NEXT: i64x2.shr_s $push[[R:[0-9]+]]=, $0, $1{{$}}
770; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000771define <2 x i64> @shr_s_v2i64(<2 x i64> %v, i32 %x) {
772 %x2 = zext i32 %x to i64
773 %t = insertelement <2 x i64> undef, i64 %x2, i32 0
774 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
775 %a = ashr <2 x i64> %v, %s
776 ret <2 x i64> %a
777}
778
779; CHECK-LABEL: shr_s_nozext_v2i64:
780; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000781; SIMD128-NEXT: .functype shr_s_nozext_v2i64 (v128, i64) -> (v128){{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000782; SIMD128-NEXT: i32.wrap/i64 $push[[L0:[0-9]+]]=, $1{{$}}
783; SIMD128-NEXT: i64x2.shr_s $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
784; SIMD128-NEXT: return $pop[[R]]{{$}}
785define <2 x i64> @shr_s_nozext_v2i64(<2 x i64> %v, i64 %x) {
786 %t = insertelement <2 x i64> undef, i64 %x, i32 0
787 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
788 %a = ashr <2 x i64> %v, %s
789 ret <2 x i64> %a
790}
791
Thomas Lively55735d52018-10-20 01:31:18 +0000792; CHECK-LABEL: shr_s_const_v2i64:
793; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000794; SIMD128-NEXT: .functype shr_s_const_v2i64 (v128) -> (v128){{$}}
Thomas Lively55735d52018-10-20 01:31:18 +0000795; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 5{{$}}
796; SIMD128-NEXT: i64x2.shr_s $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
797; SIMD128-NEXT: return $pop[[R]]{{$}}
798define <2 x i64> @shr_s_const_v2i64(<2 x i64> %v) {
799 %a = ashr <2 x i64> %v, <i64 5, i64 5>
800 ret <2 x i64> %a
801}
802
Thomas Livelyb2382c82018-11-02 00:39:57 +0000803; CHECK-LABEL: shr_s_vec_v2i64:
804; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000805; SIMD128-NEXT: .functype shr_s_vec_v2i64 (v128, v128) -> (v128){{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +0000806; SIMD128-NEXT: i64x2.extract_lane $push[[L0:[0-9]+]]=, $0, 0{{$}}
807; SIMD128-NEXT: i64x2.extract_lane $push[[L1:[0-9]+]]=, $1, 0{{$}}
808; SIMD128-NEXT: i64.shr_s $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
809; SIMD128-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
810; SIMD128-NEXT: i64x2.extract_lane $push[[L4:[0-9]+]]=, $0, 1{{$}}
811; SIMD128-NEXT: i64x2.extract_lane $push[[L5:[0-9]+]]=, $1, 1{{$}}
812; SIMD128-NEXT: i64.shr_s $push[[L6:[0-9]+]]=, $pop[[L4]], $pop[[L5]]{{$}}
813; SIMD128-NEXT: i64x2.replace_lane $push[[R:[0-9]+]]=, $pop[[L3]], 1, $pop[[L6]]{{$}}
814; SIMD128-NEXT: return $pop[[R]]{{$}}
815define <2 x i64> @shr_s_vec_v2i64(<2 x i64> %v, <2 x i64> %x) {
816 %a = ashr <2 x i64> %v, %x
817 ret <2 x i64> %a
818}
819
Thomas Livelyf2550e02018-09-15 00:45:31 +0000820; CHECK-LABEL: shr_u_v2i64:
821; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000822; SIMD128-NEXT: .functype shr_u_v2i64 (v128, i32) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000823; SIMD128-NEXT: i64x2.shr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
824; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000825define <2 x i64> @shr_u_v2i64(<2 x i64> %v, i32 %x) {
826 %x2 = zext i32 %x to i64
827 %t = insertelement <2 x i64> undef, i64 %x2, i32 0
828 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
829 %a = lshr <2 x i64> %v, %s
830 ret <2 x i64> %a
831}
832
833; CHECK-LABEL: shr_u_nozext_v2i64:
834; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000835; SIMD128-NEXT: .functype shr_u_nozext_v2i64 (v128, i64) -> (v128){{$}}
Thomas Livelyf2550e02018-09-15 00:45:31 +0000836; SIMD128-NEXT: i32.wrap/i64 $push[[L0:[0-9]+]]=, $1{{$}}
837; SIMD128-NEXT: i64x2.shr_u $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
838; SIMD128-NEXT: return $pop[[R]]{{$}}
839define <2 x i64> @shr_u_nozext_v2i64(<2 x i64> %v, i64 %x) {
840 %t = insertelement <2 x i64> undef, i64 %x, i32 0
841 %s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
842 %a = lshr <2 x i64> %v, %s
843 ret <2 x i64> %a
844}
845
Thomas Lively55735d52018-10-20 01:31:18 +0000846; CHECK-LABEL: shr_u_const_v2i64:
847; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000848; SIMD128-NEXT: .functype shr_u_const_v2i64 (v128) -> (v128){{$}}
Thomas Lively55735d52018-10-20 01:31:18 +0000849; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 5{{$}}
850; SIMD128-NEXT: i64x2.shr_u $push[[R:[0-9]+]]=, $0, $pop[[L0]]{{$}}
851; SIMD128-NEXT: return $pop[[R]]{{$}}
852define <2 x i64> @shr_u_const_v2i64(<2 x i64> %v) {
853 %a = lshr <2 x i64> %v, <i64 5, i64 5>
854 ret <2 x i64> %a
855}
856
Thomas Livelyb2382c82018-11-02 00:39:57 +0000857; CHECK-LABEL: shr_u_vec_v2i64:
858; NO-SIMD128-NOT: i64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000859; SIMD128-NEXT: .functype shr_u_vec_v2i64 (v128, v128) -> (v128){{$}}
Thomas Livelyb2382c82018-11-02 00:39:57 +0000860; SIMD128-NEXT: i64x2.extract_lane $push[[L0:[0-9]+]]=, $0, 0{{$}}
861; SIMD128-NEXT: i64x2.extract_lane $push[[L1:[0-9]+]]=, $1, 0{{$}}
862; SIMD128-NEXT: i64.shr_u $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
863; SIMD128-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
864; SIMD128-NEXT: i64x2.extract_lane $push[[L4:[0-9]+]]=, $0, 1{{$}}
865; SIMD128-NEXT: i64x2.extract_lane $push[[L5:[0-9]+]]=, $1, 1{{$}}
866; SIMD128-NEXT: i64.shr_u $push[[L6:[0-9]+]]=, $pop[[L4]], $pop[[L5]]{{$}}
867; SIMD128-NEXT: i64x2.replace_lane $push[[R:[0-9]+]]=, $pop[[L3]], 1, $pop[[L6]]{{$}}
868; SIMD128-NEXT: return $pop[[R]]{{$}}
869define <2 x i64> @shr_u_vec_v2i64(<2 x i64> %v, <2 x i64> %x) {
870 %a = lshr <2 x i64> %v, %x
871 ret <2 x i64> %a
872}
873
Thomas Livelya3937b22018-09-14 21:21:42 +0000874; CHECK-LABEL: and_v2i64:
Thomas Livelyec71e012018-08-28 18:33:31 +0000875; NO-SIMD128-NOT: v128
876; SIMD128-VM-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000877; SIMD128-NEXT: .functype and_v2i64 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000878; SIMD128-NEXT: v128.and $push[[R:[0-9]+]]=, $0, $1{{$}}
879; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000880define <2 x i64> @and_v2i64(<2 x i64> %x, <2 x i64> %y) {
881 %a = and <2 x i64> %x, %y
882 ret <2 x i64> %a
883}
884
Thomas Livelya3937b22018-09-14 21:21:42 +0000885; CHECK-LABEL: or_v2i64:
Thomas Livelyec71e012018-08-28 18:33:31 +0000886; NO-SIMD128-NOT: v128
887; SIMD128-VM-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000888; SIMD128-NEXT: .functype or_v2i64 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000889; SIMD128-NEXT: v128.or $push[[R:[0-9]+]]=, $0, $1{{$}}
890; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000891define <2 x i64> @or_v2i64(<2 x i64> %x, <2 x i64> %y) {
892 %a = or <2 x i64> %x, %y
893 ret <2 x i64> %a
894}
895
Thomas Livelya3937b22018-09-14 21:21:42 +0000896; CHECK-LABEL: xor_v2i64:
Thomas Livelyec71e012018-08-28 18:33:31 +0000897; NO-SIMD128-NOT: v128
898; SIMD128-VM-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000899; SIMD128-NEXT: .functype xor_v2i64 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000900; SIMD128-NEXT: v128.xor $push[[R:[0-9]+]]=, $0, $1{{$}}
901; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyc1742572018-08-23 00:48:37 +0000902define <2 x i64> @xor_v2i64(<2 x i64> %x, <2 x i64> %y) {
903 %a = xor <2 x i64> %x, %y
904 ret <2 x i64> %a
905}
906
Thomas Livelya3937b22018-09-14 21:21:42 +0000907; CHECK-LABEL: not_v2i64:
Thomas Lively995ad612018-08-28 18:31:15 +0000908; NO-SIMD128-NOT: v128
909; SIMD128-VM-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000910; SIMD128-NEXT: .functype not_v2i64 (v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000911; SIMD128-NEXT: v128.not $push[[R:[0-9]+]]=, $0{{$}}
912; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively995ad612018-08-28 18:31:15 +0000913define <2 x i64> @not_v2i64(<2 x i64> %x) {
914 %a = xor <2 x i64> %x, <i64 -1, i64 -1>
915 ret <2 x i64> %a
916}
917
Thomas Lively5d461c92018-10-03 23:02:23 +0000918; CHECK-LABEL: bitselect_v2i64:
919; NO-SIMD128-NOT: v128
920; SIMD128-VM-NOT: v128
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000921; SIMD128-NEXT: .functype bitselect_v2i64 (v128, v128, v128) -> (v128){{$}}
Thomas Lively5d461c92018-10-03 23:02:23 +0000922; SIMD128-SLOW-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $0{{$}}
923; SIMD128-SLOW-NEXT: return $pop[[R]]{{$}}
924; SIMD128-FAST-NEXT: v128.not
925; SIMD128-FAST-NEXT: v128.and
926; SIMD128-FAST-NEXT: v128.and
927; SIMD128-FAST-NEXT: v128.or
928; SIMD128-FAST-NEXT: return
929define <2 x i64> @bitselect_v2i64(<2 x i64> %c, <2 x i64> %v1, <2 x i64> %v2) {
930 %masked_v1 = and <2 x i64> %v1, %c
931 %inv_mask = xor <2 x i64> <i64 -1, i64 -1>, %c
932 %masked_v2 = and <2 x i64> %v2, %inv_mask
933 %a = or <2 x i64> %masked_v2, %masked_v1
934 ret <2 x i64> %a
935}
936
Derek Schuff51ed1312018-08-07 21:24:01 +0000937; ==============================================================================
Derek Schuff39bf39f2016-08-02 23:16:09 +0000938; 4 x float
939; ==============================================================================
Thomas Lively88b74432018-09-14 22:35:12 +0000940; CHECK-LABEL: neg_v4f32:
941; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000942; SIMD128-NEXT: .functype neg_v4f32 (v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +0000943; SIMD128-NEXT: f32x4.neg $push[[R:[0-9]+]]=, $0{{$}}
944; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +0000945define <4 x float> @neg_v4f32(<4 x float> %x) {
Thomas Lively108e98e2018-10-10 01:09:09 +0000946 ; nsz makes this semantically equivalent to flipping sign bit
947 %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 +0000948 ret <4 x float> %a
949}
950
Thomas Livelyaaf4e2c2018-09-18 21:45:12 +0000951; CHECK-LABEL: abs_v4f32:
952; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000953; SIMD128-NEXT: .functype abs_v4f32 (v128) -> (v128){{$}}
Thomas Lively58615362018-09-24 23:42:07 +0000954; SIMD128-NEXT: f32x4.abs $push[[R:[0-9]+]]=, $0{{$}}
955; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyaaf4e2c2018-09-18 21:45:12 +0000956declare <4 x float> @llvm.fabs.v4f32(<4 x float>) nounwind readnone
957define <4 x float> @abs_v4f32(<4 x float> %x) {
958 %a = call <4 x float> @llvm.fabs.v4f32(<4 x float> %x)
959 ret <4 x float> %a
960}
961
Thomas Lively3afc3462018-10-13 07:26:10 +0000962; CHECK-LABEL: min_unordered_v4f32:
963; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000964; SIMD128-NEXT: .functype min_unordered_v4f32 (v128) -> (v128){{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +0000965; SIMD128-NEXT: f32.const $push[[L0:[0-9]+]]=, 0x1.4p2
966; SIMD128-NEXT: f32x4.splat $push[[L1:[0-9]+]]=, $pop[[L0]]
967; SIMD128-NEXT: f32x4.min $push[[R:[0-9]+]]=, $0, $pop[[L1]]{{$}}
968; SIMD128-NEXT: return $pop[[R]]{{$}}
969define <4 x float> @min_unordered_v4f32(<4 x float> %x) {
970 %cmps = fcmp ule <4 x float> %x, <float 5., float 5., float 5., float 5.>
971 %a = select <4 x i1> %cmps, <4 x float> %x,
972 <4 x float> <float 5., float 5., float 5., float 5.>
973 ret <4 x float> %a
974}
975
976; CHECK-LABEL: max_unordered_v4f32:
977; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000978; SIMD128-NEXT: .functype max_unordered_v4f32 (v128) -> (v128){{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +0000979; SIMD128-NEXT: f32.const $push[[L0:[0-9]+]]=, 0x1.4p2
980; SIMD128-NEXT: f32x4.splat $push[[L1:[0-9]+]]=, $pop[[L0]]
981; SIMD128-NEXT: f32x4.max $push[[R:[0-9]+]]=, $0, $pop[[L1]]{{$}}
982; SIMD128-NEXT: return $pop[[R]]{{$}}
983define <4 x float> @max_unordered_v4f32(<4 x float> %x) {
984 %cmps = fcmp uge <4 x float> %x, <float 5., float 5., float 5., float 5.>
985 %a = select <4 x i1> %cmps, <4 x float> %x,
986 <4 x float> <float 5., float 5., float 5., float 5.>
987 ret <4 x float> %a
988}
989
990; CHECK-LABEL: min_ordered_v4f32:
991; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +0000992; SIMD128-NEXT: .functype min_ordered_v4f32 (v128) -> (v128){{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +0000993; SIMD128-NEXT: f32.const $push[[L0:[0-9]+]]=, 0x1.4p2
994; SIMD128-NEXT: f32x4.splat $push[[L1:[0-9]+]]=, $pop[[L0]]
Thomas Lively43bc4622018-10-24 22:18:54 +0000995; SIMD128-NEXT: f32x4.min $push[[R:[0-9]+]]=, $0, $pop[[L1]]{{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +0000996; SIMD128-NEXT: return $pop[[R]]{{$}}
997define <4 x float> @min_ordered_v4f32(<4 x float> %x) {
998 %cmps = fcmp ole <4 x float> <float 5., float 5., float 5., float 5.>, %x
999 %a = select <4 x i1> %cmps,
1000 <4 x float> <float 5., float 5., float 5., float 5.>, <4 x float> %x
1001 ret <4 x float> %a
1002}
1003
1004; CHECK-LABEL: max_ordered_v4f32:
1005; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001006; SIMD128-NEXT: .functype max_ordered_v4f32 (v128) -> (v128){{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +00001007; SIMD128-NEXT: f32.const $push[[L0:[0-9]+]]=, 0x1.4p2
1008; SIMD128-NEXT: f32x4.splat $push[[L1:[0-9]+]]=, $pop[[L0]]
Thomas Lively43bc4622018-10-24 22:18:54 +00001009; SIMD128-NEXT: f32x4.max $push[[R:[0-9]+]]=, $0, $pop[[L1]]{{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +00001010; SIMD128-NEXT: return $pop[[R]]{{$}}
1011define <4 x float> @max_ordered_v4f32(<4 x float> %x) {
1012 %cmps = fcmp oge <4 x float> <float 5., float 5., float 5., float 5.>, %x
1013 %a = select <4 x i1> %cmps,
1014 <4 x float> <float 5., float 5., float 5., float 5.>, <4 x float> %x
1015 ret <4 x float> %a
1016}
1017
1018; CHECK-LABEL: min_intrinsic_v4f32:
1019; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001020; SIMD128-NEXT: .functype min_intrinsic_v4f32 (v128, v128) -> (v128){{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +00001021; SIMD128-NEXT: f32x4.min $push[[R:[0-9]+]]=, $0, $1{{$}}
1022; SIMD128-NEXT: return $pop[[R]]{{$}}
1023declare <4 x float> @llvm.minimum.v4f32(<4 x float>, <4 x float>)
1024define <4 x float> @min_intrinsic_v4f32(<4 x float> %x, <4 x float> %y) {
1025 %a = call <4 x float> @llvm.minimum.v4f32(<4 x float> %x, <4 x float> %y)
1026 ret <4 x float> %a
1027}
1028
1029; CHECK-LABEL: max_intrinsic_v4f32:
1030; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001031; SIMD128-NEXT: .functype max_intrinsic_v4f32 (v128, v128) -> (v128){{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +00001032; SIMD128-NEXT: f32x4.max $push[[R:[0-9]+]]=, $0, $1{{$}}
1033; SIMD128-NEXT: return $pop[[R]]{{$}}
1034declare <4 x float> @llvm.maximum.v4f32(<4 x float>, <4 x float>)
1035define <4 x float> @max_intrinsic_v4f32(<4 x float> %x, <4 x float> %y) {
1036 %a = call <4 x float> @llvm.maximum.v4f32(<4 x float> %x, <4 x float> %y)
1037 ret <4 x float> %a
1038}
1039
Thomas Lively43bc4622018-10-24 22:18:54 +00001040; CHECK-LABEL: min_const_intrinsic_v4f32:
1041; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001042; SIMD128-NEXT: .functype min_const_intrinsic_v4f32 () -> (v128){{$}}
Thomas Lively43bc4622018-10-24 22:18:54 +00001043; SIMD128-NEXT: f32.const $push[[L:[0-9]+]]=, 0x1.4p2{{$}}
1044; SIMD128-NEXT: f32x4.splat $push[[R:[0-9]+]]=, $pop[[L]]{{$}}
1045; SIMD128-NEXT: return $pop[[R]]{{$}}
1046define <4 x float> @min_const_intrinsic_v4f32() {
1047 %a = call <4 x float> @llvm.minimum.v4f32(
1048 <4 x float> <float 42., float 42., float 42., float 42.>,
1049 <4 x float> <float 5., float 5., float 5., float 5.>
1050 )
1051 ret <4 x float> %a
1052}
1053
1054; CHECK-LABEL: max_const_intrinsic_v4f32:
1055; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001056; SIMD128-NEXT: .functype max_const_intrinsic_v4f32 () -> (v128){{$}}
Thomas Lively43bc4622018-10-24 22:18:54 +00001057; SIMD128-NEXT: f32.const $push[[L:[0-9]+]]=, 0x1.5p5{{$}}
1058; SIMD128-NEXT: f32x4.splat $push[[R:[0-9]+]]=, $pop[[L]]{{$}}
1059; SIMD128-NEXT: return $pop[[R]]{{$}}
1060define <4 x float> @max_const_intrinsic_v4f32() {
1061 %a = call <4 x float> @llvm.maximum.v4f32(
1062 <4 x float> <float 42., float 42., float 42., float 42.>,
1063 <4 x float> <float 5., float 5., float 5., float 5.>
1064 )
1065 ret <4 x float> %a
1066}
1067
Thomas Livelya3937b22018-09-14 21:21:42 +00001068; CHECK-LABEL: add_v4f32:
Derek Schuff39bf39f2016-08-02 23:16:09 +00001069; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001070; SIMD128-NEXT: .functype add_v4f32 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001071; SIMD128-NEXT: f32x4.add $push[[R:[0-9]+]]=, $0, $1{{$}}
1072; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +00001073define <4 x float> @add_v4f32(<4 x float> %x, <4 x float> %y) {
1074 %a = fadd <4 x float> %x, %y
1075 ret <4 x float> %a
1076}
1077
Thomas Livelya3937b22018-09-14 21:21:42 +00001078; CHECK-LABEL: sub_v4f32:
Derek Schuff39bf39f2016-08-02 23:16:09 +00001079; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001080; SIMD128-NEXT: .functype sub_v4f32 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001081; SIMD128-NEXT: f32x4.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
1082; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +00001083define <4 x float> @sub_v4f32(<4 x float> %x, <4 x float> %y) {
1084 %a = fsub <4 x float> %x, %y
1085 ret <4 x float> %a
1086}
1087
Thomas Livelya3937b22018-09-14 21:21:42 +00001088; CHECK-LABEL: div_v4f32:
Derek Schuff51ed1312018-08-07 21:24:01 +00001089; NO-SIMD128-NOT: f32x4
Thomas Lively8dbf29af2018-12-20 02:10:22 +00001090; SIMD128-VM-NOT: f32x4.div
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001091; SIMD128-NEXT: .functype div_v4f32 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001092; SIMD128-NEXT: f32x4.div $push[[R:[0-9]+]]=, $0, $1{{$}}
1093; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +00001094define <4 x float> @div_v4f32(<4 x float> %x, <4 x float> %y) {
1095 %a = fdiv <4 x float> %x, %y
1096 ret <4 x float> %a
1097}
1098
Thomas Livelya3937b22018-09-14 21:21:42 +00001099; CHECK-LABEL: mul_v4f32:
Derek Schuff39bf39f2016-08-02 23:16:09 +00001100; NO-SIMD128-NOT: f32x4
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001101; SIMD128-NEXT: .functype mul_v4f32 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001102; SIMD128-NEXT: f32x4.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
1103; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff39bf39f2016-08-02 23:16:09 +00001104define <4 x float> @mul_v4f32(<4 x float> %x, <4 x float> %y) {
1105 %a = fmul <4 x float> %x, %y
1106 ret <4 x float> %a
1107}
1108
Thomas Lively12da0f92018-09-25 03:39:28 +00001109; CHECK-LABEL: sqrt_v4f32:
1110; NO-SIMD128-NOT: f32x4
Thomas Lively8dbf29af2018-12-20 02:10:22 +00001111; SIMD128-VM-NOT: f32x4.sqrt
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001112; SIMD128-NEXT: .functype sqrt_v4f32 (v128) -> (v128){{$}}
Thomas Lively12da0f92018-09-25 03:39:28 +00001113; SIMD128-NEXT: f32x4.sqrt $push[[R:[0-9]+]]=, $0{{$}}
1114; SIMD128-NEXT: return $pop[[R]]{{$}}
1115declare <4 x float> @llvm.sqrt.v4f32(<4 x float> %x)
1116define <4 x float> @sqrt_v4f32(<4 x float> %x) {
1117 %a = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %x)
1118 ret <4 x float> %a
1119}
1120
Derek Schuff51ed1312018-08-07 21:24:01 +00001121; ==============================================================================
1122; 2 x double
1123; ==============================================================================
Thomas Lively88b74432018-09-14 22:35:12 +00001124; CHECK-LABEL: neg_v2f64:
1125; NO-SIMD128-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001126; SIMD128-NEXT: .functype neg_v2f64 (v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001127; SIMD128-NEXT: f64x2.neg $push[[R:[0-9]+]]=, $0{{$}}
1128; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Lively88b74432018-09-14 22:35:12 +00001129define <2 x double> @neg_v2f64(<2 x double> %x) {
Thomas Lively108e98e2018-10-10 01:09:09 +00001130 ; nsz makes this semantically equivalent to flipping sign bit
1131 %a = fsub nsz <2 x double> <double 0., double 0.>, %x
Thomas Lively88b74432018-09-14 22:35:12 +00001132 ret <2 x double> %a
1133}
1134
Thomas Livelyaaf4e2c2018-09-18 21:45:12 +00001135; CHECK-LABEL: abs_v2f64:
1136; NO-SIMD128-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001137; SIMD128-NEXT: .functype abs_v2f64 (v128) -> (v128){{$}}
Thomas Lively58615362018-09-24 23:42:07 +00001138; SIMD128-NEXT: f64x2.abs $push[[R:[0-9]+]]=, $0{{$}}
1139; SIMD128-NEXT: return $pop[[R]]{{$}}
Thomas Livelyaaf4e2c2018-09-18 21:45:12 +00001140declare <2 x double> @llvm.fabs.v2f64(<2 x double>) nounwind readnone
1141define <2 x double> @abs_v2f64(<2 x double> %x) {
1142 %a = call <2 x double> @llvm.fabs.v2f64(<2 x double> %x)
1143 ret <2 x double> %a
1144}
1145
Thomas Lively3afc3462018-10-13 07:26:10 +00001146; CHECK-LABEL: min_unordered_v2f64:
1147; NO-SIMD128-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001148; SIMD128-NEXT: .functype min_unordered_v2f64 (v128) -> (v128){{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +00001149; SIMD128-NEXT: f64.const $push[[L0:[0-9]+]]=, 0x1.4p2
1150; SIMD128-NEXT: f64x2.splat $push[[L1:[0-9]+]]=, $pop[[L0]]
1151; SIMD128-NEXT: f64x2.min $push[[R:[0-9]+]]=, $0, $pop[[L1]]{{$}}
1152; SIMD128-NEXT: return $pop[[R]]{{$}}
1153define <2 x double> @min_unordered_v2f64(<2 x double> %x) {
1154 %cmps = fcmp ule <2 x double> %x, <double 5., double 5.>
1155 %a = select <2 x i1> %cmps, <2 x double> %x,
1156 <2 x double> <double 5., double 5.>
1157 ret <2 x double> %a
1158}
1159
1160; CHECK-LABEL: max_unordered_v2f64:
1161; NO-SIMD128-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001162; SIMD128-NEXT: .functype max_unordered_v2f64 (v128) -> (v128){{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +00001163; SIMD128-NEXT: f64.const $push[[L0:[0-9]+]]=, 0x1.4p2
1164; SIMD128-NEXT: f64x2.splat $push[[L1:[0-9]+]]=, $pop[[L0]]
1165; SIMD128-NEXT: f64x2.max $push[[R:[0-9]+]]=, $0, $pop[[L1]]{{$}}
1166; SIMD128-NEXT: return $pop[[R]]{{$}}
1167define <2 x double> @max_unordered_v2f64(<2 x double> %x) {
1168 %cmps = fcmp uge <2 x double> %x, <double 5., double 5.>
1169 %a = select <2 x i1> %cmps, <2 x double> %x,
1170 <2 x double> <double 5., double 5.>
1171 ret <2 x double> %a
1172}
1173
1174; CHECK-LABEL: min_ordered_v2f64:
1175; NO-SIMD128-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001176; SIMD128-NEXT: .functype min_ordered_v2f64 (v128) -> (v128){{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +00001177; SIMD128-NEXT: f64.const $push[[L0:[0-9]+]]=, 0x1.4p2
1178; SIMD128-NEXT: f64x2.splat $push[[L1:[0-9]+]]=, $pop[[L0]]
Thomas Lively43bc4622018-10-24 22:18:54 +00001179; SIMD128-NEXT: f64x2.min $push[[R:[0-9]+]]=, $0, $pop[[L1]]{{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +00001180; SIMD128-NEXT: return $pop[[R]]{{$}}
1181define <2 x double> @min_ordered_v2f64(<2 x double> %x) {
1182 %cmps = fcmp ole <2 x double> <double 5., double 5.>, %x
1183 %a = select <2 x i1> %cmps, <2 x double> <double 5., double 5.>,
1184 <2 x double> %x
1185 ret <2 x double> %a
1186}
1187
1188; CHECK-LABEL: max_ordered_v2f64:
1189; NO-SIMD128-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001190; SIMD128-NEXT: .functype max_ordered_v2f64 (v128) -> (v128){{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +00001191; SIMD128-NEXT: f64.const $push[[L0:[0-9]+]]=, 0x1.4p2
1192; SIMD128-NEXT: f64x2.splat $push[[L1:[0-9]+]]=, $pop[[L0]]
Thomas Lively43bc4622018-10-24 22:18:54 +00001193; SIMD128-NEXT: f64x2.max $push[[R:[0-9]+]]=, $0, $pop[[L1]]{{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +00001194; SIMD128-NEXT: return $pop[[R]]{{$}}
1195define <2 x double> @max_ordered_v2f64(<2 x double> %x) {
1196 %cmps = fcmp oge <2 x double> <double 5., double 5.>, %x
1197 %a = select <2 x i1> %cmps, <2 x double> <double 5., double 5.>,
1198 <2 x double> %x
1199 ret <2 x double> %a
1200}
1201
1202; CHECK-LABEL: min_intrinsic_v2f64:
1203; NO-SIMD128-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001204; SIMD128-NEXT: .functype min_intrinsic_v2f64 (v128, v128) -> (v128){{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +00001205; SIMD128-NEXT: f64x2.min $push[[R:[0-9]+]]=, $0, $1{{$}}
1206; SIMD128-NEXT: return $pop[[R]]{{$}}
1207declare <2 x double> @llvm.minimum.v2f64(<2 x double>, <2 x double>)
1208define <2 x double> @min_intrinsic_v2f64(<2 x double> %x, <2 x double> %y) {
1209 %a = call <2 x double> @llvm.minimum.v2f64(<2 x double> %x, <2 x double> %y)
1210 ret <2 x double> %a
1211}
1212
1213; CHECK-LABEL: max_intrinsic_v2f64:
1214; NO-SIMD128-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001215; SIMD128-NEXT: .functype max_intrinsic_v2f64 (v128, v128) -> (v128){{$}}
Thomas Lively3afc3462018-10-13 07:26:10 +00001216; SIMD128-NEXT: f64x2.max $push[[R:[0-9]+]]=, $0, $1{{$}}
1217; SIMD128-NEXT: return $pop[[R]]{{$}}
1218declare <2 x double> @llvm.maximum.v2f64(<2 x double>, <2 x double>)
1219define <2 x double> @max_intrinsic_v2f64(<2 x double> %x, <2 x double> %y) {
1220 %a = call <2 x double> @llvm.maximum.v2f64(<2 x double> %x, <2 x double> %y)
1221 ret <2 x double> %a
1222}
1223
Thomas Lively43bc4622018-10-24 22:18:54 +00001224; CHECK-LABEL: min_const_intrinsic_v2f64:
1225; NO-SIMD128-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001226; SIMD128-NEXT: .functype min_const_intrinsic_v2f64 () -> (v128){{$}}
Thomas Lively43bc4622018-10-24 22:18:54 +00001227; SIMD128-NEXT: f64.const $push[[L:[0-9]+]]=, 0x1.4p2{{$}}
1228; SIMD128-NEXT: f64x2.splat $push[[R:[0-9]+]]=, $pop[[L]]{{$}}
1229; SIMD128-NEXT: return $pop[[R]]{{$}}
1230define <2 x double> @min_const_intrinsic_v2f64() {
1231 %a = call <2 x double> @llvm.minimum.v2f64(
1232 <2 x double> <double 42., double 42.>,
1233 <2 x double> <double 5., double 5.>
1234 )
1235 ret <2 x double> %a
1236}
1237
1238; CHECK-LABEL: max_const_intrinsic_v2f64:
1239; NO-SIMD128-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001240; SIMD128-NEXT: .functype max_const_intrinsic_v2f64 () -> (v128){{$}}
Thomas Lively43bc4622018-10-24 22:18:54 +00001241; SIMD128-NEXT: f64.const $push[[L:[0-9]+]]=, 0x1.5p5{{$}}
1242; SIMD128-NEXT: f64x2.splat $push[[R:[0-9]+]]=, $pop[[L]]{{$}}
1243; SIMD128-NEXT: return $pop[[R]]{{$}}
1244define <2 x double> @max_const_intrinsic_v2f64() {
1245 %a = call <2 x double> @llvm.maximum.v2f64(
1246 <2 x double> <double 42., double 42.>,
1247 <2 x double> <double 5., double 5.>
1248 )
1249 ret <2 x double> %a
1250}
1251
Thomas Livelya3937b22018-09-14 21:21:42 +00001252; CHECK-LABEL: add_v2f64:
Derek Schuff51ed1312018-08-07 21:24:01 +00001253; NO-SIMD128-NOT: f64x2
Thomas Livelya3937b22018-09-14 21:21:42 +00001254; SIMD128-VM-NOT: f62x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001255; SIMD128-NEXT: .functype add_v2f64 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001256; SIMD128-NEXT: f64x2.add $push[[R:[0-9]+]]=, $0, $1{{$}}
1257; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +00001258define <2 x double> @add_v2f64(<2 x double> %x, <2 x double> %y) {
1259 %a = fadd <2 x double> %x, %y
1260 ret <2 x double> %a
1261}
1262
Thomas Livelya3937b22018-09-14 21:21:42 +00001263; CHECK-LABEL: sub_v2f64:
Derek Schuff51ed1312018-08-07 21:24:01 +00001264; NO-SIMD128-NOT: f64x2
Thomas Livelya3937b22018-09-14 21:21:42 +00001265; SIMD128-VM-NOT: f62x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001266; SIMD128-NEXT: .functype sub_v2f64 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001267; SIMD128-NEXT: f64x2.sub $push[[R:[0-9]+]]=, $0, $1{{$}}
1268; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +00001269define <2 x double> @sub_v2f64(<2 x double> %x, <2 x double> %y) {
1270 %a = fsub <2 x double> %x, %y
1271 ret <2 x double> %a
1272}
1273
Thomas Livelya3937b22018-09-14 21:21:42 +00001274; CHECK-LABEL: div_v2f64:
Derek Schuff51ed1312018-08-07 21:24:01 +00001275; NO-SIMD128-NOT: f64x2
Thomas Livelya3937b22018-09-14 21:21:42 +00001276; SIMD128-VM-NOT: f62x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001277; SIMD128-NEXT: .functype div_v2f64 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001278; SIMD128-NEXT: f64x2.div $push[[R:[0-9]+]]=, $0, $1{{$}}
1279; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +00001280define <2 x double> @div_v2f64(<2 x double> %x, <2 x double> %y) {
1281 %a = fdiv <2 x double> %x, %y
1282 ret <2 x double> %a
1283}
1284
Thomas Livelya3937b22018-09-14 21:21:42 +00001285; CHECK-LABEL: mul_v2f64:
Derek Schuff51ed1312018-08-07 21:24:01 +00001286; NO-SIMD128-NOT: f64x2
Thomas Livelya3937b22018-09-14 21:21:42 +00001287; SIMD128-VM-NOT: f62x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001288; SIMD128-NEXT: .functype mul_v2f64 (v128, v128) -> (v128){{$}}
Thomas Lively66f3dc02018-09-15 01:12:48 +00001289; SIMD128-NEXT: f64x2.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
1290; SIMD128-NEXT: return $pop[[R]]{{$}}
Derek Schuff51ed1312018-08-07 21:24:01 +00001291define <2 x double> @mul_v2f64(<2 x double> %x, <2 x double> %y) {
1292 %a = fmul <2 x double> %x, %y
1293 ret <2 x double> %a
1294}
Thomas Lively12da0f92018-09-25 03:39:28 +00001295
1296; CHECK-LABEL: sqrt_v2f64:
1297; NO-SIMD128-NOT: f64x2
Wouter van Oortmerssen49482f82018-11-19 17:10:36 +00001298; SIMD128-NEXT: .functype sqrt_v2f64 (v128) -> (v128){{$}}
Thomas Lively12da0f92018-09-25 03:39:28 +00001299; SIMD128-NEXT: f64x2.sqrt $push[[R:[0-9]+]]=, $0{{$}}
1300; SIMD128-NEXT: return $pop[[R]]{{$}}
1301declare <2 x double> @llvm.sqrt.v2f64(<2 x double> %x)
1302define <2 x double> @sqrt_v2f64(<2 x double> %x) {
1303 %a = call <2 x double> @llvm.sqrt.v2f64(<2 x double> %x)
1304 ret <2 x double> %a
1305}