Skip to content

Commit 415288a

Browse files
authored
[WebAssembly] Add load and store patterns for V8F16. (#108119)
1 parent 866b93e commit 415288a

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
9696
setOperationAction(ISD::STORE, T, Custom);
9797
}
9898
}
99+
if (Subtarget->hasFP16()) {
100+
setOperationAction(ISD::LOAD, MVT::v8f16, Custom);
101+
setOperationAction(ISD::STORE, MVT::v8f16, Custom);
102+
}
99103
if (Subtarget->hasReferenceTypes()) {
100104
// We need custom load and store lowering for both externref, funcref and
101105
// Other. The MVT::Other here represents tables of reference types.

llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ defm LOAD_V128_A64 :
189189
}
190190

191191
// Def load patterns from WebAssemblyInstrMemory.td for vector types
192-
foreach vec = StdVecs in {
192+
foreach vec = AllVecs in {
193193
defm : LoadPat<vec.vt, load, "LOAD_V128">;
194194
}
195195

@@ -390,7 +390,7 @@ defm STORE_V128_A64 :
390390
}
391391

392392
// Def store patterns from WebAssemblyInstrMemory.td for vector types
393-
foreach vec = StdVecs in {
393+
foreach vec = AllVecs in {
394394
defm : StorePat<vec.vt, store, "STORE_V128">;
395395
}
396396

llvm/test/CodeGen/WebAssembly/half-precision.ll

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+fp16,+simd128 | FileCheck %s
2-
; RUN: llc < %s --mtriple=wasm64-unknown-unknown -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+fp16,+simd128 | FileCheck %s
32

43
declare float @llvm.wasm.loadf32.f16(ptr)
54
declare void @llvm.wasm.storef16.f32(float, ptr)
@@ -308,3 +307,24 @@ define <8 x i16> @trunc_sat_u_v8i16_sat(<8 x half> %x) {
308307
%a = call <8 x i16> @llvm.fptoui.sat.v8i16.v8f16(<8 x half> %x)
309308
ret <8 x i16> %a
310309
}
310+
311+
; ==============================================================================
312+
; Load and Store
313+
; ==============================================================================
314+
define <8 x half> @load_v8f16(ptr %p) {
315+
; CHECK-LABEL: load_v8f16:
316+
; CHECK: .functype load_v8f16 (i32) -> (v128)
317+
; CHECK-NEXT: v128.load $push0=, 0($0)
318+
; CHECK-NEXT: return $pop0
319+
%v = load <8 x half>, ptr %p
320+
ret <8 x half> %v
321+
}
322+
323+
define void @store_v8f16(<8 x half> %v, ptr %p) {
324+
; CHECK-LABEL: store_v8f16:
325+
; CHECK: .functype store_v8f16 (v128, i32) -> ()
326+
; CHECK-NEXT: v128.store 0($1), $0
327+
; CHECK-NEXT: return
328+
store <8 x half> %v , ptr %p
329+
ret void
330+
}

0 commit comments

Comments
 (0)