|
2 | 2 | ; RUN: llc < %s -O3 -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128 | FileCheck %s
|
3 | 3 | target triple = "wasm32-unknown-unknown"
|
4 | 4 |
|
5 |
| -define void @bitselect_first_zero(ptr %output, ptr %input) { |
6 |
| -; CHECK-LABEL: bitselect_first_zero: |
7 |
| -; CHECK: .functype bitselect_first_zero (i32, i32) -> () |
| 5 | +define <4 x i32> @bitselect_splat_first_zero_and_icmp(<4 x i32> %input) { |
| 6 | +; CHECK-LABEL: bitselect_splat_first_zero_and_icmp: |
| 7 | +; CHECK: .functype bitselect_splat_first_zero_and_icmp (v128) -> (v128) |
8 | 8 | ; CHECK-NEXT: # %bb.0: # %start
|
9 |
| -; CHECK-NEXT: v128.load $push6=, 0($1) |
10 |
| -; CHECK-NEXT: local.tee $push5=, $2=, $pop6 |
11 | 9 | ; CHECK-NEXT: v128.const $push0=, 2139095040, 2139095040, 2139095040, 2139095040
|
12 |
| -; CHECK-NEXT: v128.and $push1=, $2, $pop0 |
| 10 | +; CHECK-NEXT: v128.and $push1=, $0, $pop0 |
13 | 11 | ; CHECK-NEXT: v128.const $push2=, 0, 0, 0, 0
|
14 | 12 | ; CHECK-NEXT: i32x4.ne $push3=, $pop1, $pop2
|
15 |
| -; CHECK-NEXT: v128.and $push4=, $pop5, $pop3 |
16 |
| -; CHECK-NEXT: v128.store 0($0), $pop4 |
17 |
| -; CHECK-NEXT: return |
| 13 | +; CHECK-NEXT: v128.and $push4=, $pop3, $0 |
| 14 | +; CHECK-NEXT: return $pop4 |
18 | 15 | start:
|
19 |
| - %input.val = load <4 x i32>, ptr %input, align 16 |
20 |
| - %0 = and <4 x i32> %input.val, splat (i32 2139095040) |
| 16 | + %0 = and <4 x i32> %input, splat (i32 2139095040) |
21 | 17 | %1 = icmp eq <4 x i32> %0, zeroinitializer
|
22 |
| - %2 = select <4 x i1> %1, <4 x i32> zeroinitializer, <4 x i32> %input.val |
23 |
| - store <4 x i32> %2, ptr %output, align 16 |
24 |
| - ret void |
| 18 | + %2 = select <4 x i1> %1, <4 x i32> zeroinitializer, <4 x i32> %input |
| 19 | + ret <4 x i32> %2 |
25 | 20 | }
|
26 | 21 |
|
27 | 22 |
|
28 |
| -define void @bitselect_second_zero(ptr %output, ptr %input) { |
29 |
| -; CHECK-LABEL: bitselect_second_zero: |
30 |
| -; CHECK: .functype bitselect_second_zero (i32, i32) -> () |
| 23 | +define <4 x i32> @bitselect_splat_second_zero_and_icmp(<4 x i32> %input) { |
| 24 | +; CHECK-LABEL: bitselect_splat_second_zero_and_icmp: |
| 25 | +; CHECK: .functype bitselect_splat_second_zero_and_icmp (v128) -> (v128) |
31 | 26 | ; CHECK-NEXT: # %bb.0: # %start
|
32 |
| -; CHECK-NEXT: v128.load $push6=, 0($1) |
33 |
| -; CHECK-NEXT: local.tee $push5=, $2=, $pop6 |
34 | 27 | ; CHECK-NEXT: v128.const $push0=, 2139095040, 2139095040, 2139095040, 2139095040
|
35 |
| -; CHECK-NEXT: v128.and $push1=, $2, $pop0 |
| 28 | +; CHECK-NEXT: v128.and $push1=, $0, $pop0 |
36 | 29 | ; CHECK-NEXT: v128.const $push2=, 0, 0, 0, 0
|
37 | 30 | ; CHECK-NEXT: i32x4.eq $push3=, $pop1, $pop2
|
38 |
| -; CHECK-NEXT: v128.and $push4=, $pop5, $pop3 |
39 |
| -; CHECK-NEXT: v128.store 0($0), $pop4 |
40 |
| -; CHECK-NEXT: return |
| 31 | +; CHECK-NEXT: v128.and $push4=, $pop3, $0 |
| 32 | +; CHECK-NEXT: return $pop4 |
41 | 33 | start:
|
42 |
| - %input.val = load <4 x i32>, ptr %input, align 16 |
43 |
| - %0 = and <4 x i32> %input.val, splat (i32 2139095040) |
| 34 | + %0 = and <4 x i32> %input, splat (i32 2139095040) |
44 | 35 | %1 = icmp eq <4 x i32> %0, zeroinitializer
|
45 |
| - %2 = select <4 x i1> %1, <4 x i32> %input.val, <4 x i32> zeroinitializer |
46 |
| - store <4 x i32> %2, ptr %output, align 16 |
47 |
| - ret void |
| 36 | + %2 = select <4 x i1> %1, <4 x i32> %input, <4 x i32> zeroinitializer |
| 37 | + ret <4 x i32> %2 |
| 38 | +} |
| 39 | + |
| 40 | + |
| 41 | +define <4 x i32> @bitselect_splat_first_zero_cond_input(<4 x i1> %cond, <4 x i32> %input) { |
| 42 | +; CHECK-LABEL: bitselect_splat_first_zero_cond_input: |
| 43 | +; CHECK: .functype bitselect_splat_first_zero_cond_input (v128, v128) -> (v128) |
| 44 | +; CHECK-NEXT: # %bb.0: # %start |
| 45 | +; CHECK-NEXT: i32.const $push0=, 31 |
| 46 | +; CHECK-NEXT: i32x4.shl $push1=, $0, $pop0 |
| 47 | +; CHECK-NEXT: i32.const $push4=, 31 |
| 48 | +; CHECK-NEXT: i32x4.shr_s $push2=, $pop1, $pop4 |
| 49 | +; CHECK-NEXT: v128.andnot $push3=, $pop2, $1 |
| 50 | +; CHECK-NEXT: return $pop3 |
| 51 | +start: |
| 52 | + %2 = select <4 x i1> %cond, <4 x i32> zeroinitializer, <4 x i32> %input |
| 53 | + ret <4 x i32> %2 |
| 54 | +} |
| 55 | + |
| 56 | + |
| 57 | +define <4 x i32> @bitselect_splat_second_zero_cond_input(<4 x i1> %cond, <4 x i32> %input) { |
| 58 | +; CHECK-LABEL: bitselect_splat_second_zero_cond_input: |
| 59 | +; CHECK: .functype bitselect_splat_second_zero_cond_input (v128, v128) -> (v128) |
| 60 | +; CHECK-NEXT: # %bb.0: # %start |
| 61 | +; CHECK-NEXT: i32.const $push0=, 31 |
| 62 | +; CHECK-NEXT: i32x4.shl $push1=, $0, $pop0 |
| 63 | +; CHECK-NEXT: i32.const $push4=, 31 |
| 64 | +; CHECK-NEXT: i32x4.shr_s $push2=, $pop1, $pop4 |
| 65 | +; CHECK-NEXT: v128.and $push3=, $pop2, $1 |
| 66 | +; CHECK-NEXT: return $pop3 |
| 67 | +start: |
| 68 | + %2 = select <4 x i1> %cond, <4 x i32> %input, <4 x i32> zeroinitializer |
| 69 | + ret <4 x i32> %2 |
48 | 70 | }
|
0 commit comments