Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
MVT::v2f64})
setOperationAction(ISD::VECTOR_SHUFFLE, T, Custom);

if (Subtarget->hasFP16())
setOperationAction(ISD::VECTOR_SHUFFLE, MVT::v8f16, Custom);

// Support splatting
for (auto T : {MVT::v16i8, MVT::v8i16, MVT::v4i32, MVT::v4f32, MVT::v2i64,
MVT::v2f64})
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ defm SHUFFLE :
// Shuffles after custom lowering
def wasm_shuffle_t : SDTypeProfile<1, 18, []>;
def wasm_shuffle : SDNode<"WebAssemblyISD::SHUFFLE", wasm_shuffle_t>;
foreach vec = StdVecs in {
foreach vec = AllVecs in {
// The @llvm.wasm.shuffle intrinsic has immediate arguments that become TargetConstants.
def : Pat<(vec.vt (wasm_shuffle (vec.vt V128:$x), (vec.vt V128:$y),
(i32 timm:$m0), (i32 timm:$m1),
Expand Down
24 changes: 24 additions & 0 deletions llvm/test/CodeGen/WebAssembly/half-precision.ll
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,27 @@ define void @store_v8f16(<8 x half> %v, ptr %p) {
store <8 x half> %v , ptr %p
ret void
}

; ==============================================================================
; Shuffle
; ==============================================================================
define <8 x half> @shuffle_v8f16(<8 x half> %x, <8 x half> %y) {
; CHECK-LABEL: shuffle_v8f16:
; CHECK: .functype shuffle_v8f16 (v128, v128) -> (v128)
; CHECK-NEXT: i8x16.shuffle $push0=, $0, $1, 0, 1, 18, 19, 4, 5, 22, 23, 8, 9, 26, 27, 12, 13, 30, 31
; CHECK-NEXT: return $pop0
%res = shufflevector <8 x half> %x, <8 x half> %y,
<8 x i32> <i32 0, i32 9, i32 2, i32 11, i32 4, i32 13, i32 6, i32 15>
ret <8 x half> %res
}

define <8 x half> @shuffle_undef_v8f16(<8 x half> %x, <8 x half> %y) {
; CHECK-LABEL: shuffle_undef_v8f16:
; CHECK: .functype shuffle_undef_v8f16 (v128, v128) -> (v128)
; CHECK-NEXT: i8x16.shuffle $push0=, $0, $0, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1
; CHECK-NEXT: return $pop0
%res = shufflevector <8 x half> %x, <8 x half> %y,
<8 x i32> <i32 1, i32 undef, i32 undef, i32 undef,
i32 undef, i32 undef, i32 undef, i32 undef>
ret <8 x half> %res
}
Loading