138c902bcSThomas Lively; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-unimplemented-simd -mattr=+simd128,+sign-ext | FileCheck %s
238c902bcSThomas Lively
338c902bcSThomas Lively; Test that vector selects of various varieties lower correctly to bitselects.
438c902bcSThomas Lively
538c902bcSThomas Livelytarget datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
638c902bcSThomas Livelytarget triple = "wasm32-unknown-unknown"
738c902bcSThomas Lively
838c902bcSThomas Lively; ==============================================================================
938c902bcSThomas Lively; 16 x i8
1038c902bcSThomas Lively; ==============================================================================
1138c902bcSThomas Lively; CHECK-LABEL: vselect_v16i8:
12*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype vselect_v16i8 (v128, v128, v128) -> (v128){{$}}
1338c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 7{{$}}
1438c902bcSThomas Lively; CHECK-NEXT: i8x16.shl $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
1538c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 7{{$}}
1638c902bcSThomas Lively; CHECK-NEXT: i8x16.shr_s $push[[L3:[0-9]+]]=, $pop[[L1]], $pop[[L2]]{{$}}
1738c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
1838c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
1938c902bcSThomas Livelydefine <16 x i8> @vselect_v16i8(<16 x i1> %c, <16 x i8> %x, <16 x i8> %y) {
2038c902bcSThomas Lively  %res = select <16 x i1> %c, <16 x i8> %x, <16 x i8> %y
2138c902bcSThomas Lively  ret <16 x i8> %res
2238c902bcSThomas Lively}
2338c902bcSThomas Lively
2438c902bcSThomas Lively; CHECK-LABEL: select_v16i8:
25*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_v16i8 (i32, v128, v128) -> (v128){{$}}
2638c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
2738c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
2838c902bcSThomas Lively; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
2938c902bcSThomas Lively; CHECK-NEXT: i8x16.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
3038c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
3138c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
3238c902bcSThomas Livelydefine <16 x i8> @select_v16i8(i1 %c, <16 x i8> %x, <16 x i8> %y) {
3338c902bcSThomas Lively  %res = select i1 %c, <16 x i8> %x, <16 x i8> %y
3438c902bcSThomas Lively  ret <16 x i8> %res
3538c902bcSThomas Lively}
3638c902bcSThomas Lively
3738c902bcSThomas Lively; CHECK-LABEL: select_cmp_v16i8:
38*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_cmp_v16i8 (i32, v128, v128) -> (v128){{$}}
3938c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 31
4038c902bcSThomas Lively; CHECK-NEXT: i32.shr_s $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
4138c902bcSThomas Lively; CHECK-NEXT: i8x16.splat $push[[L2:[0-9]+]]=, $pop[[L1]]{{$}}
4238c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L2]]{{$}}
4338c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
4438c902bcSThomas Livelydefine <16 x i8> @select_cmp_v16i8(i32 %i, <16 x i8> %x, <16 x i8> %y) {
4538c902bcSThomas Lively  %c = icmp slt i32 %i, 0
4638c902bcSThomas Lively  %res = select i1 %c, <16 x i8> %x, <16 x i8> %y
4738c902bcSThomas Lively  ret <16 x i8> %res
4838c902bcSThomas Lively}
4938c902bcSThomas Lively
5038c902bcSThomas Lively; CHECK-LABEL: select_ne_v16i8:
51*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_ne_v16i8 (i32, v128, v128) -> (v128){{$}}
5238c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
5338c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
5438c902bcSThomas Lively; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
5538c902bcSThomas Lively; CHECK-NEXT: i8x16.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
5638c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
5738c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
5838c902bcSThomas Livelydefine <16 x i8> @select_ne_v16i8(i32 %i, <16 x i8> %x, <16 x i8> %y) {
5938c902bcSThomas Lively  %c = icmp ne i32 %i, 0
6038c902bcSThomas Lively  %res = select i1 %c, <16 x i8> %x, <16 x i8> %y
6138c902bcSThomas Lively  ret <16 x i8> %res
6238c902bcSThomas Lively}
6338c902bcSThomas Lively
6438c902bcSThomas Lively; CHECK-LABEL: select_eq_v16i8:
65*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_eq_v16i8 (i32, v128, v128) -> (v128){{$}}
6638c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
6738c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, -1{{$}}
6838c902bcSThomas Lively; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
6938c902bcSThomas Lively; CHECK-NEXT: i8x16.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
7038c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
7138c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
7238c902bcSThomas Livelydefine <16 x i8> @select_eq_v16i8(i32 %i, <16 x i8> %x, <16 x i8> %y) {
7338c902bcSThomas Lively  %c = icmp eq i32 %i, 0
7438c902bcSThomas Lively  %res = select i1 %c, <16 x i8> %x, <16 x i8> %y
7538c902bcSThomas Lively  ret <16 x i8> %res
7638c902bcSThomas Lively}
7738c902bcSThomas Lively
7838c902bcSThomas Lively; ==============================================================================
7938c902bcSThomas Lively; 8 x i16
8038c902bcSThomas Lively; ==============================================================================
8138c902bcSThomas Lively; CHECK-LABEL: vselect_v8i16:
82*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype vselect_v8i16 (v128, v128, v128) -> (v128){{$}}
8338c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 15{{$}}
8438c902bcSThomas Lively; CHECK-NEXT: i16x8.shl $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
8538c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 15{{$}}
8638c902bcSThomas Lively; CHECK-NEXT: i16x8.shr_s $push[[L3:[0-9]+]]=, $pop[[L1]], $pop[[L2]]{{$}}
8738c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
8838c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
8938c902bcSThomas Livelydefine <8 x i16> @vselect_v8i16(<8 x i1> %c, <8 x i16> %x, <8 x i16> %y) {
9038c902bcSThomas Lively  %res = select <8 x i1> %c, <8 x i16> %x, <8 x i16> %y
9138c902bcSThomas Lively  ret <8 x i16> %res
9238c902bcSThomas Lively}
9338c902bcSThomas Lively
9438c902bcSThomas Lively; CHECK-LABEL: select_v8i16:
95*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_v8i16 (i32, v128, v128) -> (v128){{$}}
9638c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
9738c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
9838c902bcSThomas Lively; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
9938c902bcSThomas Lively; CHECK-NEXT: i16x8.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
10038c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
10138c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
10238c902bcSThomas Livelydefine <8 x i16> @select_v8i16(i1 %c, <8 x i16> %x, <8 x i16> %y) {
10338c902bcSThomas Lively  %res = select i1 %c, <8 x i16> %x, <8 x i16> %y
10438c902bcSThomas Lively  ret <8 x i16> %res
10538c902bcSThomas Lively}
10638c902bcSThomas Lively
10738c902bcSThomas Lively; CHECK-LABEL: select_cmp_v8i16:
108*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_cmp_v8i16 (i32, v128, v128) -> (v128){{$}}
10938c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 31{{$}}
11038c902bcSThomas Lively; CHECK-NEXT: i32.shr_s $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
11138c902bcSThomas Lively; CHECK-NEXT: i16x8.splat $push[[L2:[0-9]+]]=, $pop[[L1]]{{$}}
11238c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L2]]{{$}}
11338c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
11438c902bcSThomas Livelydefine <8 x i16> @select_cmp_v8i16(i32 %i, <8 x i16> %x, <8 x i16> %y) {
11538c902bcSThomas Lively  %c = icmp slt i32 %i, 0
11638c902bcSThomas Lively  %res = select i1 %c, <8 x i16> %x, <8 x i16> %y
11738c902bcSThomas Lively  ret <8 x i16> %res
11838c902bcSThomas Lively}
11938c902bcSThomas Lively
12038c902bcSThomas Lively; CHECK-LABEL: select_ne_v8i16:
121*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_ne_v8i16 (i32, v128, v128) -> (v128){{$}}
12238c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
12338c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
12438c902bcSThomas Lively; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
12538c902bcSThomas Lively; CHECK-NEXT: i16x8.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
12638c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
12738c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
12838c902bcSThomas Livelydefine <8 x i16> @select_ne_v8i16(i32 %i, <8 x i16> %x, <8 x i16> %y) {
12938c902bcSThomas Lively  %c = icmp ne i32 %i, 0
13038c902bcSThomas Lively  %res = select i1 %c, <8 x i16> %x, <8 x i16> %y
13138c902bcSThomas Lively  ret <8 x i16> %res
13238c902bcSThomas Lively}
13338c902bcSThomas Lively
13438c902bcSThomas Lively; CHECK-LABEL: select_eq_v8i16:
135*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_eq_v8i16 (i32, v128, v128) -> (v128){{$}}
13638c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
13738c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, -1{{$}}
13838c902bcSThomas Lively; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
13938c902bcSThomas Lively; CHECK-NEXT: i16x8.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
14038c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
14138c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
14238c902bcSThomas Livelydefine <8 x i16> @select_eq_v8i16(i32 %i, <8 x i16> %x, <8 x i16> %y) {
14338c902bcSThomas Lively  %c = icmp eq i32 %i, 0
14438c902bcSThomas Lively  %res = select i1 %c, <8 x i16> %x, <8 x i16> %y
14538c902bcSThomas Lively  ret <8 x i16> %res
14638c902bcSThomas Lively}
14738c902bcSThomas Lively
14838c902bcSThomas Lively; ==============================================================================
14938c902bcSThomas Lively; 4 x i32
15038c902bcSThomas Lively; ==============================================================================
15138c902bcSThomas Lively; CHECK-LABEL: vselect_v4i32:
152*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype vselect_v4i32 (v128, v128, v128) -> (v128){{$}}
15338c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 31{{$}}
15438c902bcSThomas Lively; CHECK-NEXT: i32x4.shl $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
15538c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 31{{$}}
15638c902bcSThomas Lively; CHECK-NEXT: i32x4.shr_s $push[[L3:[0-9]+]]=, $pop[[L1]], $pop[[L2]]{{$}}
15738c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
15838c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
15938c902bcSThomas Livelydefine <4 x i32> @vselect_v4i32(<4 x i1> %c, <4 x i32> %x, <4 x i32> %y) {
16038c902bcSThomas Lively  %res = select <4 x i1> %c, <4 x i32> %x, <4 x i32> %y
16138c902bcSThomas Lively  ret <4 x i32> %res
16238c902bcSThomas Lively}
16338c902bcSThomas Lively
16438c902bcSThomas Lively
16538c902bcSThomas Lively; CHECK-LABEL: select_v4i32:
166*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_v4i32 (i32, v128, v128) -> (v128){{$}}
16738c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
16838c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
16938c902bcSThomas Lively; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
17038c902bcSThomas Lively; CHECK-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
17138c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
17238c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
17338c902bcSThomas Livelydefine <4 x i32> @select_v4i32(i1 %c, <4 x i32> %x, <4 x i32> %y) {
17438c902bcSThomas Lively  %res = select i1 %c, <4 x i32> %x, <4 x i32> %y
17538c902bcSThomas Lively  ret <4 x i32> %res
17638c902bcSThomas Lively}
17738c902bcSThomas Lively
17838c902bcSThomas Lively; CHECK-LABEL: select_cmp_v4i32:
179*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_cmp_v4i32 (i32, v128, v128) -> (v128){{$}}
18038c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 31{{$}}
18138c902bcSThomas Lively; CHECK-NEXT: i32.shr_s $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
18238c902bcSThomas Lively; CHECK-NEXT: i32x4.splat $push[[L2:[0-9]+]]=, $pop[[L1]]{{$}}
18338c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L2]]{{$}}
18438c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
18538c902bcSThomas Livelydefine <4 x i32> @select_cmp_v4i32(i32 %i, <4 x i32> %x, <4 x i32> %y) {
18638c902bcSThomas Lively  %c = icmp slt i32 %i, 0
18738c902bcSThomas Lively  %res = select i1 %c, <4 x i32> %x, <4 x i32> %y
18838c902bcSThomas Lively  ret <4 x i32> %res
18938c902bcSThomas Lively}
19038c902bcSThomas Lively
19138c902bcSThomas Lively; CHECK-LABEL: select_ne_v4i32:
192*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_ne_v4i32 (i32, v128, v128) -> (v128){{$}}
19338c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
19438c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
19538c902bcSThomas Lively; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
19638c902bcSThomas Lively; CHECK-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
19738c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
19838c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
19938c902bcSThomas Livelydefine <4 x i32> @select_ne_v4i32(i32 %i, <4 x i32> %x, <4 x i32> %y) {
20038c902bcSThomas Lively  %c = icmp ne i32 %i, 0
20138c902bcSThomas Lively  %res = select i1 %c, <4 x i32> %x, <4 x i32> %y
20238c902bcSThomas Lively  ret <4 x i32> %res
20338c902bcSThomas Lively}
20438c902bcSThomas Lively
20538c902bcSThomas Lively; CHECK-LABEL: select_eq_v4i32:
206*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_eq_v4i32 (i32, v128, v128) -> (v128){{$}}
20738c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
20838c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, -1{{$}}
20938c902bcSThomas Lively; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
21038c902bcSThomas Lively; CHECK-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
21138c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
21238c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
21338c902bcSThomas Livelydefine <4 x i32> @select_eq_v4i32(i32 %i, <4 x i32> %x, <4 x i32> %y) {
21438c902bcSThomas Lively  %c = icmp eq i32 %i, 0
21538c902bcSThomas Lively  %res = select i1 %c, <4 x i32> %x, <4 x i32> %y
21638c902bcSThomas Lively  ret <4 x i32> %res
21738c902bcSThomas Lively}
21838c902bcSThomas Lively
21938c902bcSThomas Lively; ==============================================================================
22038c902bcSThomas Lively; 2 x i64
22138c902bcSThomas Lively; ==============================================================================
22238c902bcSThomas Lively; CHECK-LABEL: vselect_v2i64:
223*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype vselect_v2i64 (v128, v128, v128) -> (v128){{$}}
22438c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 63{{$}}
22538c902bcSThomas Lively; CHECK-NEXT: i64x2.shl $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
22638c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 63{{$}}
22738c902bcSThomas Lively; CHECK-NEXT: i64x2.shr_s $push[[L3:[0-9]+]]=, $pop[[L1]], $pop[[L2]]{{$}}
22838c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
22938c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
23038c902bcSThomas Livelydefine <2 x i64> @vselect_v2i64(<2 x i1> %c, <2 x i64> %x, <2 x i64> %y) {
23138c902bcSThomas Lively  %res = select <2 x i1> %c, <2 x i64> %x, <2 x i64> %y
23238c902bcSThomas Lively  ret <2 x i64> %res
23338c902bcSThomas Lively}
23438c902bcSThomas Lively
23538c902bcSThomas Lively; CHECK-LABEL: select_v2i64:
236*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_v2i64 (i32, v128, v128) -> (v128){{$}}
23738c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, -1{{$}}
23838c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, 0{{$}}
23938c902bcSThomas Lively; CHECK-NEXT: i64.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
24038c902bcSThomas Lively; CHECK-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
24138c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
24238c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
24338c902bcSThomas Livelydefine <2 x i64> @select_v2i64(i1 %c, <2 x i64> %x, <2 x i64> %y) {
24438c902bcSThomas Lively  %res = select i1 %c, <2 x i64> %x, <2 x i64> %y
24538c902bcSThomas Lively  ret <2 x i64> %res
24638c902bcSThomas Lively}
24738c902bcSThomas Lively
24838c902bcSThomas Lively; CHECK-LABEL: select_cmp_v2i64:
249*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_cmp_v2i64 (i32, v128, v128) -> (v128){{$}}
25038c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, -1{{$}}
25138c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, 0{{$}}
25238c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 0{{$}}
25338c902bcSThomas Lively; CHECK-NEXT: i32.lt_s $push[[L3:[0-9]+]]=, $0, $pop[[L2]]{{$}}
25438c902bcSThomas Lively; CHECK-NEXT: i64.select $push[[L4:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $pop[[L3]]{{$}}
25538c902bcSThomas Lively; CHECK-NEXT: i64x2.splat $push[[L5:[0-9]+]]=, $pop[[L4]]{{$}}
25638c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L5]]{{$}}
25738c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
25838c902bcSThomas Livelydefine <2 x i64> @select_cmp_v2i64(i32 %i, <2 x i64> %x, <2 x i64> %y) {
25938c902bcSThomas Lively  %c = icmp slt i32 %i, 0
26038c902bcSThomas Lively  %res = select i1 %c, <2 x i64> %x, <2 x i64> %y
26138c902bcSThomas Lively  ret <2 x i64> %res
26238c902bcSThomas Lively}
26338c902bcSThomas Lively
26438c902bcSThomas Lively; CHECK-LABEL: select_ne_v2i64:
265*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_ne_v2i64 (i32, v128, v128) -> (v128){{$}}
26638c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, -1{{$}}
26738c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, 0{{$}}
26838c902bcSThomas Lively; CHECK-NEXT: i64.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
26938c902bcSThomas Lively; CHECK-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
27038c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
27138c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
27238c902bcSThomas Livelydefine <2 x i64> @select_ne_v2i64(i32 %i, <2 x i64> %x, <2 x i64> %y) {
27338c902bcSThomas Lively  %c = icmp ne i32 %i, 0
27438c902bcSThomas Lively  %res = select i1 %c, <2 x i64> %x, <2 x i64> %y
27538c902bcSThomas Lively  ret <2 x i64> %res
27638c902bcSThomas Lively}
27738c902bcSThomas Lively
27838c902bcSThomas Lively; CHECK-LABEL: select_eq_v2i64:
279*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_eq_v2i64 (i32, v128, v128) -> (v128){{$}}
28038c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, 0{{$}}
28138c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, -1{{$}}
28238c902bcSThomas Lively; CHECK-NEXT: i64.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
28338c902bcSThomas Lively; CHECK-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
28438c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
28538c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
28638c902bcSThomas Livelydefine <2 x i64> @select_eq_v2i64(i32 %i, <2 x i64> %x, <2 x i64> %y) {
28738c902bcSThomas Lively  %c = icmp eq i32 %i, 0
28838c902bcSThomas Lively  %res = select i1 %c, <2 x i64> %x, <2 x i64> %y
28938c902bcSThomas Lively  ret <2 x i64> %res
29038c902bcSThomas Lively}
29138c902bcSThomas Lively
29238c902bcSThomas Lively; ==============================================================================
29338c902bcSThomas Lively; 4 x float
29438c902bcSThomas Lively; ==============================================================================
29538c902bcSThomas Lively; CHECK-LABEL: vselect_v4f32:
296*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype vselect_v4f32 (v128, v128, v128) -> (v128){{$}}
29738c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 31{{$}}
29838c902bcSThomas Lively; CHECK-NEXT: i32x4.shl $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
29938c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 31{{$}}
30038c902bcSThomas Lively; CHECK-NEXT: i32x4.shr_s $push[[L3:[0-9]+]]=, $pop[[L1]], $pop[[L2]]{{$}}
30138c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
30238c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
30338c902bcSThomas Livelydefine <4 x float> @vselect_v4f32(<4 x i1> %c, <4 x float> %x, <4 x float> %y) {
30438c902bcSThomas Lively  %res = select <4 x i1> %c, <4 x float> %x, <4 x float> %y
30538c902bcSThomas Lively  ret <4 x float> %res
30638c902bcSThomas Lively}
30738c902bcSThomas Lively
30838c902bcSThomas Lively; CHECK-LABEL: select_v4f32:
309*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_v4f32 (i32, v128, v128) -> (v128){{$}}
31038c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
31138c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
31238c902bcSThomas Lively; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
31338c902bcSThomas Lively; CHECK-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
31438c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
31538c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
31638c902bcSThomas Livelydefine <4 x float> @select_v4f32(i1 %c, <4 x float> %x, <4 x float> %y) {
31738c902bcSThomas Lively  %res = select i1 %c, <4 x float> %x, <4 x float> %y
31838c902bcSThomas Lively  ret <4 x float> %res
31938c902bcSThomas Lively}
32038c902bcSThomas Lively
32138c902bcSThomas Lively; CHECK-LABEL: select_cmp_v4f32:
322*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_cmp_v4f32 (i32, v128, v128) -> (v128){{$}}
32338c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 31{{$}}
32438c902bcSThomas Lively; CHECK-NEXT: i32.shr_s $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
32538c902bcSThomas Lively; CHECK-NEXT: i32x4.splat $push[[L2:[0-9]+]]=, $pop[[L1]]{{$}}
32638c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L2]]{{$}}
32738c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
32838c902bcSThomas Livelydefine <4 x float> @select_cmp_v4f32(i32 %i, <4 x float> %x, <4 x float> %y) {
32938c902bcSThomas Lively  %c = icmp slt i32 %i, 0
33038c902bcSThomas Lively  %res = select i1 %c, <4 x float> %x, <4 x float> %y
33138c902bcSThomas Lively  ret <4 x float> %res
33238c902bcSThomas Lively}
33338c902bcSThomas Lively
33438c902bcSThomas Lively; CHECK-LABEL: select_ne_v4f32:
335*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_ne_v4f32 (i32, v128, v128) -> (v128){{$}}
33638c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
33738c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
33838c902bcSThomas Lively; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
33938c902bcSThomas Lively; CHECK-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
34038c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
34138c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
34238c902bcSThomas Livelydefine <4 x float> @select_ne_v4f32(i32 %i, <4 x float> %x, <4 x float> %y) {
34338c902bcSThomas Lively  %c = icmp ne i32 %i, 0
34438c902bcSThomas Lively  %res = select i1 %c, <4 x float> %x, <4 x float> %y
34538c902bcSThomas Lively  ret <4 x float> %res
34638c902bcSThomas Lively}
34738c902bcSThomas Lively
34838c902bcSThomas Lively; CHECK-LABEL: select_eq_v4f32:
349*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_eq_v4f32 (i32, v128, v128) -> (v128){{$}}
35038c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
35138c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, -1{{$}}
35238c902bcSThomas Lively; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
35338c902bcSThomas Lively; CHECK-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
35438c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
35538c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
35638c902bcSThomas Livelydefine <4 x float> @select_eq_v4f32(i32 %i, <4 x float> %x, <4 x float> %y) {
35738c902bcSThomas Lively  %c = icmp eq i32 %i, 0
35838c902bcSThomas Lively  %res = select i1 %c, <4 x float> %x, <4 x float> %y
35938c902bcSThomas Lively  ret <4 x float> %res
36038c902bcSThomas Lively}
36138c902bcSThomas Lively
36238c902bcSThomas Lively; ==============================================================================
36338c902bcSThomas Lively; 2 x double
36438c902bcSThomas Lively; ==============================================================================
36538c902bcSThomas Lively; CHECK-LABEL: vselect_v2f64:
366*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype vselect_v2f64 (v128, v128, v128) -> (v128){{$}}
36738c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 63{{$}}
36838c902bcSThomas Lively; CHECK-NEXT: i64x2.shl $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
36938c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 63{{$}}
37038c902bcSThomas Lively; CHECK-NEXT: i64x2.shr_s $push[[L3:[0-9]+]]=, $pop[[L1]], $pop[[L2]]{{$}}
37138c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
37238c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
37338c902bcSThomas Livelydefine <2 x double> @vselect_v2f64(<2 x i1> %c, <2 x double> %x, <2 x double> %y) {
37438c902bcSThomas Lively  %res = select <2 x i1> %c, <2 x double> %x, <2 x double> %y
37538c902bcSThomas Lively  ret <2 x double> %res
37638c902bcSThomas Lively}
37738c902bcSThomas Lively
37838c902bcSThomas Lively; CHECK-LABEL: select_v2f64:
379*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_v2f64 (i32, v128, v128) -> (v128){{$}}
38038c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, -1{{$}}
38138c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, 0{{$}}
38238c902bcSThomas Lively; CHECK-NEXT: i64.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
38338c902bcSThomas Lively; CHECK-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
38438c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
38538c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
38638c902bcSThomas Livelydefine <2 x double> @select_v2f64(i1 %c, <2 x double> %x, <2 x double> %y) {
38738c902bcSThomas Lively  %res = select i1 %c, <2 x double> %x, <2 x double> %y
38838c902bcSThomas Lively  ret <2 x double> %res
38938c902bcSThomas Lively}
39038c902bcSThomas Lively
39138c902bcSThomas Lively; CHECK-LABEL: select_cmp_v2f64:
392*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_cmp_v2f64 (i32, v128, v128) -> (v128){{$}}
39338c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, -1{{$}}
39438c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, 0{{$}}
39538c902bcSThomas Lively; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 0{{$}}
39638c902bcSThomas Lively; CHECK-NEXT: i32.lt_s $push[[L3:[0-9]+]]=, $0, $pop[[L2]]{{$}}
39738c902bcSThomas Lively; CHECK-NEXT: i64.select $push[[L4:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $pop[[L3]]{{$}}
39838c902bcSThomas Lively; CHECK-NEXT: i64x2.splat $push[[L5:[0-9]+]]=, $pop[[L4]]{{$}}
39938c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L5]]{{$}}
40038c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
40138c902bcSThomas Livelydefine <2 x double> @select_cmp_v2f64(i32 %i, <2 x double> %x, <2 x double> %y) {
40238c902bcSThomas Lively  %c = icmp slt i32 %i, 0
40338c902bcSThomas Lively  %res = select i1 %c, <2 x double> %x, <2 x double> %y
40438c902bcSThomas Lively  ret <2 x double> %res
40538c902bcSThomas Lively}
40638c902bcSThomas Lively
40738c902bcSThomas Lively; CHECK-LABEL: select_ne_v2f64:
408*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_ne_v2f64 (i32, v128, v128) -> (v128){{$}}
40938c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, -1{{$}}
41038c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, 0{{$}}
41138c902bcSThomas Lively; CHECK-NEXT: i64.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
41238c902bcSThomas Lively; CHECK-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
41338c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
41438c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
41538c902bcSThomas Livelydefine <2 x double> @select_ne_v2f64(i32 %i, <2 x double> %x, <2 x double> %y) {
41638c902bcSThomas Lively  %c = icmp ne i32 %i, 0
41738c902bcSThomas Lively  %res = select i1 %c, <2 x double> %x, <2 x double> %y
41838c902bcSThomas Lively  ret <2 x double> %res
41938c902bcSThomas Lively}
42038c902bcSThomas Lively
42138c902bcSThomas Lively; CHECK-LABEL: select_eq_v2f64:
422*49482f82SWouter van Oortmerssen; CHECK-NEXT: .functype select_eq_v2f64 (i32, v128, v128) -> (v128){{$}}
42338c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, 0{{$}}
42438c902bcSThomas Lively; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, -1{{$}}
42538c902bcSThomas Lively; CHECK-NEXT: i64.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
42638c902bcSThomas Lively; CHECK-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
42738c902bcSThomas Lively; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
42838c902bcSThomas Lively; CHECK-NEXT: return $pop[[R]]{{$}}
42938c902bcSThomas Livelydefine <2 x double> @select_eq_v2f64(i32 %i, <2 x double> %x, <2 x double> %y) {
43038c902bcSThomas Lively  %c = icmp eq i32 %i, 0
43138c902bcSThomas Lively  %res = select i1 %c, <2 x double> %x, <2 x double> %y
43238c902bcSThomas Lively  ret <2 x double> %res
43338c902bcSThomas Lively}
434