Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13091,10 +13091,10 @@ static SDValue combineVSelectWithAllOnesOrZeros(SDValue Cond, SDValue TVal,
EVT CondVT = Cond.getValueType();
assert(CondVT.isVector() && "Vector select expects a vector selector!");

bool IsTAllZero = ISD::isBuildVectorAllZeros(TVal.getNode());
bool IsTAllOne = ISD::isBuildVectorAllOnes(TVal.getNode());
bool IsFAllZero = ISD::isBuildVectorAllZeros(FVal.getNode());
bool IsFAllOne = ISD::isBuildVectorAllOnes(FVal.getNode());
bool IsTAllZero = ISD::isConstantSplatVectorAllZeros(TVal.getNode());
bool IsTAllOne = ISD::isConstantSplatVectorAllOnes(TVal.getNode());
bool IsFAllZero = ISD::isConstantSplatVectorAllZeros(FVal.getNode());
bool IsFAllOne = ISD::isConstantSplatVectorAllOnes(FVal.getNode());

// no vselect(cond, 0/-1, X) or vselect(cond, X, 0/-1), return
if (!IsTAllZero && !IsTAllOne && !IsFAllZero && !IsFAllOne)
Expand Down
12 changes: 4 additions & 8 deletions llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,9 @@ define <2 x i32> @ustest_f64i32(<2 x double> %x) {
; CHECK-NEXT: v128.bitselect
; CHECK-NEXT: local.tee 0
; CHECK-NEXT: v128.const 0, 0
; CHECK-NEXT: local.tee 1
; CHECK-NEXT: local.get 0
; CHECK-NEXT: local.get 1
; CHECK-NEXT: i64x2.gt_s
; CHECK-NEXT: v128.bitselect
; CHECK-NEXT: local.get 0
; CHECK-NEXT: v128.and
; CHECK-NEXT: local.get 0
; CHECK-NEXT: i8x16.shuffle 0, 1, 2, 3, 8, 9, 10, 11, 0, 1, 2, 3, 0, 1, 2, 3
; CHECK-NEXT: # fallthrough-return
Expand Down Expand Up @@ -1558,11 +1556,9 @@ define <2 x i32> @ustest_f64i32_mm(<2 x double> %x) {
; CHECK-NEXT: v128.bitselect
; CHECK-NEXT: local.tee 0
; CHECK-NEXT: v128.const 0, 0
; CHECK-NEXT: local.tee 1
; CHECK-NEXT: local.get 0
; CHECK-NEXT: local.get 1
; CHECK-NEXT: i64x2.gt_s
; CHECK-NEXT: v128.bitselect
; CHECK-NEXT: local.get 0
; CHECK-NEXT: v128.and
; CHECK-NEXT: local.get 0
; CHECK-NEXT: i8x16.shuffle 0, 1, 2, 3, 8, 9, 10, 11, 0, 1, 2, 3, 0, 1, 2, 3
; CHECK-NEXT: # fallthrough-return
Expand Down
71 changes: 71 additions & 0 deletions llvm/test/CodeGen/WebAssembly/simd-bitselect.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc < %s -O3 -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128 | FileCheck %s
target triple = "wasm32-unknown-unknown"

define <4 x i32> @bitselect_splat_first_zero_and_icmp(<4 x i32> %input) {
; CHECK-LABEL: bitselect_splat_first_zero_and_icmp:
; CHECK: .functype bitselect_splat_first_zero_and_icmp (v128) -> (v128)
; CHECK-NEXT: # %bb.0: # %start
; CHECK-NEXT: v128.const $push0=, 2139095040, 2139095040, 2139095040, 2139095040
; CHECK-NEXT: v128.and $push1=, $0, $pop0
; CHECK-NEXT: v128.const $push2=, 0, 0, 0, 0
; CHECK-NEXT: i32x4.ne $push3=, $pop1, $pop2
; CHECK-NEXT: v128.and $push4=, $pop3, $0
; CHECK-NEXT: return $pop4
start:
%0 = and <4 x i32> %input, splat (i32 2139095040)
%1 = icmp eq <4 x i32> %0, zeroinitializer
%2 = select <4 x i1> %1, <4 x i32> zeroinitializer, <4 x i32> %input
ret <4 x i32> %2
}


define <4 x i32> @bitselect_splat_second_zero_and_icmp(<4 x i32> %input) {
; CHECK-LABEL: bitselect_splat_second_zero_and_icmp:
; CHECK: .functype bitselect_splat_second_zero_and_icmp (v128) -> (v128)
; CHECK-NEXT: # %bb.0: # %start
; CHECK-NEXT: v128.const $push0=, 2139095040, 2139095040, 2139095040, 2139095040
; CHECK-NEXT: v128.and $push1=, $0, $pop0
; CHECK-NEXT: v128.const $push2=, 0, 0, 0, 0
; CHECK-NEXT: i32x4.eq $push3=, $pop1, $pop2
; CHECK-NEXT: v128.and $push4=, $pop3, $0
; CHECK-NEXT: return $pop4
start:
%0 = and <4 x i32> %input, splat (i32 2139095040)
%1 = icmp eq <4 x i32> %0, zeroinitializer
%2 = select <4 x i1> %1, <4 x i32> %input, <4 x i32> zeroinitializer
ret <4 x i32> %2
}


define <4 x i32> @bitselect_splat_first_zero_cond_input(<4 x i1> %cond, <4 x i32> %input) {
; CHECK-LABEL: bitselect_splat_first_zero_cond_input:
; CHECK: .functype bitselect_splat_first_zero_cond_input (v128, v128) -> (v128)
; CHECK-NEXT: # %bb.0: # %start
; CHECK-NEXT: v128.const $push3=, 0, 0, 0, 0
; CHECK-NEXT: i32.const $push0=, 31
; CHECK-NEXT: i32x4.shl $push1=, $0, $pop0
; CHECK-NEXT: i32.const $push5=, 31
; CHECK-NEXT: i32x4.shr_s $push2=, $pop1, $pop5
; CHECK-NEXT: v128.bitselect $push4=, $pop3, $1, $pop2
; CHECK-NEXT: return $pop4
start:
%2 = select <4 x i1> %cond, <4 x i32> zeroinitializer, <4 x i32> %input
ret <4 x i32> %2
}

define <4 x i32> @bitselect_splat_second_zero_cond_input(<4 x i1> %cond, <4 x i32> %input) {
; CHECK-LABEL: bitselect_splat_second_zero_cond_input:
; CHECK: .functype bitselect_splat_second_zero_cond_input (v128, v128) -> (v128)
; CHECK-NEXT: # %bb.0: # %start
; CHECK-NEXT: i32.const $push0=, 31
; CHECK-NEXT: i32x4.shl $push1=, $0, $pop0
; CHECK-NEXT: i32.const $push4=, 31
; CHECK-NEXT: i32x4.shr_s $push2=, $pop1, $pop4
; CHECK-NEXT: v128.and $push3=, $pop2, $1
; CHECK-NEXT: return $pop3
start:
%2 = select <4 x i1> %cond, <4 x i32> %input, <4 x i32> zeroinitializer
ret <4 x i32> %2
}