Skip to content

Commit 1ad59c0

Browse files
committed
[DAGCombine] Use isConstantSplatVectorAll in VSelect
- Use isConstantSplatVectorAll* in VSelect - Update tests to reflect this
1 parent a9d15d1 commit 1ad59c0

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13091,10 +13091,10 @@ static SDValue combineVSelectWithAllOnesOrZeros(SDValue Cond, SDValue TVal,
1309113091
EVT CondVT = Cond.getValueType();
1309213092
assert(CondVT.isVector() && "Vector select expects a vector selector!");
1309313093

13094-
bool IsTAllZero = ISD::isBuildVectorAllZeros(TVal.getNode());
13095-
bool IsTAllOne = ISD::isBuildVectorAllOnes(TVal.getNode());
13096-
bool IsFAllZero = ISD::isBuildVectorAllZeros(FVal.getNode());
13097-
bool IsFAllOne = ISD::isBuildVectorAllOnes(FVal.getNode());
13094+
bool IsTAllZero = ISD::isConstantSplatVectorAllZeros(TVal.getNode());
13095+
bool IsTAllOne = ISD::isConstantSplatVectorAllOnes(TVal.getNode());
13096+
bool IsFAllZero = ISD::isConstantSplatVectorAllZeros(FVal.getNode());
13097+
bool IsFAllOne = ISD::isConstantSplatVectorAllOnes(FVal.getNode());
1309813098

1309913099
// no vselect(cond, 0/-1, X) or vselect(cond, X, 0/-1), return
1310013100
if (!IsTAllZero && !IsTAllOne && !IsFAllZero && !IsFAllOne)

llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,9 @@ define <2 x i32> @ustest_f64i32(<2 x double> %x) {
107107
; CHECK-NEXT: v128.bitselect
108108
; CHECK-NEXT: local.tee 0
109109
; CHECK-NEXT: v128.const 0, 0
110-
; CHECK-NEXT: local.tee 1
111-
; CHECK-NEXT: local.get 0
112-
; CHECK-NEXT: local.get 1
113110
; CHECK-NEXT: i64x2.gt_s
114-
; CHECK-NEXT: v128.bitselect
111+
; CHECK-NEXT: local.get 0
112+
; CHECK-NEXT: v128.and
115113
; CHECK-NEXT: local.get 0
116114
; CHECK-NEXT: i8x16.shuffle 0, 1, 2, 3, 8, 9, 10, 11, 0, 1, 2, 3, 0, 1, 2, 3
117115
; CHECK-NEXT: # fallthrough-return
@@ -1558,11 +1556,9 @@ define <2 x i32> @ustest_f64i32_mm(<2 x double> %x) {
15581556
; CHECK-NEXT: v128.bitselect
15591557
; CHECK-NEXT: local.tee 0
15601558
; CHECK-NEXT: v128.const 0, 0
1561-
; CHECK-NEXT: local.tee 1
1562-
; CHECK-NEXT: local.get 0
1563-
; CHECK-NEXT: local.get 1
15641559
; CHECK-NEXT: i64x2.gt_s
1565-
; CHECK-NEXT: v128.bitselect
1560+
; CHECK-NEXT: local.get 0
1561+
; CHECK-NEXT: v128.and
15661562
; CHECK-NEXT: local.get 0
15671563
; CHECK-NEXT: i8x16.shuffle 0, 1, 2, 3, 8, 9, 10, 11, 0, 1, 2, 3, 0, 1, 2, 3
15681564
; CHECK-NEXT: # fallthrough-return

llvm/test/CodeGen/WebAssembly/simd-bitselect.ll

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ define <4 x i32> @bitselect_splat_first_zero_and_icmp(<4 x i32> %input) {
66
; CHECK-LABEL: bitselect_splat_first_zero_and_icmp:
77
; CHECK: .functype bitselect_splat_first_zero_and_icmp (v128) -> (v128)
88
; CHECK-NEXT: # %bb.0: # %start
9-
; CHECK-NEXT: v128.const $push5=, 0, 0, 0, 0
10-
; CHECK-NEXT: local.tee $push4=, $1=, $pop5
119
; CHECK-NEXT: v128.const $push0=, 2139095040, 2139095040, 2139095040, 2139095040
1210
; CHECK-NEXT: v128.and $push1=, $0, $pop0
13-
; CHECK-NEXT: i32x4.eq $push2=, $1, $pop1
14-
; CHECK-NEXT: v128.bitselect $push3=, $pop4, $0, $pop2
15-
; CHECK-NEXT: return $pop3
11+
; CHECK-NEXT: v128.const $push2=, 0, 0, 0, 0
12+
; CHECK-NEXT: i32x4.ne $push3=, $pop1, $pop2
13+
; CHECK-NEXT: v128.and $push4=, $pop3, $0
14+
; CHECK-NEXT: return $pop4
1615
start:
1716
%0 = and <4 x i32> %input, splat (i32 2139095040)
1817
%1 = icmp eq <4 x i32> %0, zeroinitializer
@@ -25,13 +24,12 @@ define <4 x i32> @bitselect_splat_second_zero_and_icmp(<4 x i32> %input) {
2524
; CHECK-LABEL: bitselect_splat_second_zero_and_icmp:
2625
; CHECK: .functype bitselect_splat_second_zero_and_icmp (v128) -> (v128)
2726
; CHECK-NEXT: # %bb.0: # %start
28-
; CHECK-NEXT: v128.const $push5=, 0, 0, 0, 0
29-
; CHECK-NEXT: local.tee $push4=, $1=, $pop5
3027
; CHECK-NEXT: v128.const $push0=, 2139095040, 2139095040, 2139095040, 2139095040
3128
; CHECK-NEXT: v128.and $push1=, $0, $pop0
32-
; CHECK-NEXT: i32x4.eq $push2=, $1, $pop1
33-
; CHECK-NEXT: v128.bitselect $push3=, $0, $pop4, $pop2
34-
; CHECK-NEXT: return $pop3
29+
; CHECK-NEXT: v128.const $push2=, 0, 0, 0, 0
30+
; CHECK-NEXT: i32x4.eq $push3=, $pop1, $pop2
31+
; CHECK-NEXT: v128.and $push4=, $pop3, $0
32+
; CHECK-NEXT: return $pop4
3533
start:
3634
%0 = and <4 x i32> %input, splat (i32 2139095040)
3735
%1 = icmp eq <4 x i32> %0, zeroinitializer
@@ -60,13 +58,12 @@ define <4 x i32> @bitselect_splat_second_zero_cond_input(<4 x i1> %cond, <4 x i3
6058
; CHECK-LABEL: bitselect_splat_second_zero_cond_input:
6159
; CHECK: .functype bitselect_splat_second_zero_cond_input (v128, v128) -> (v128)
6260
; CHECK-NEXT: # %bb.0: # %start
63-
; CHECK-NEXT: v128.const $push3=, 0, 0, 0, 0
6461
; CHECK-NEXT: i32.const $push0=, 31
6562
; CHECK-NEXT: i32x4.shl $push1=, $0, $pop0
66-
; CHECK-NEXT: i32.const $push5=, 31
67-
; CHECK-NEXT: i32x4.shr_s $push2=, $pop1, $pop5
68-
; CHECK-NEXT: v128.bitselect $push4=, $1, $pop3, $pop2
69-
; CHECK-NEXT: return $pop4
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
7067
start:
7168
%2 = select <4 x i1> %cond, <4 x i32> %input, <4 x i32> zeroinitializer
7269
ret <4 x i32> %2

0 commit comments

Comments
 (0)