[PATCH] D62321: [ARM] Promote fp16 frem
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 23 08:34:09 PDT 2019
dmgreen created this revision.
dmgreen added reviewers: SjoerdMeijer, dnsampaio, t.p.northover, miyuki, ostannard.
Herald added subscribers: hiraditya, kristof.beyls, javed.absar.
Herald added a project: LLVM.
Promote fp16 frem operations on ARM so they call fmodf. Otherwise we fail to select them.
Test is new and not in-tree yet.
https://reviews.llvm.org/D62321
Files:
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/test/CodeGen/ARM/fp16-full.ll
Index: llvm/test/CodeGen/ARM/fp16-full.ll
===================================================================
--- llvm/test/CodeGen/ARM/fp16-full.ll
+++ llvm/test/CodeGen/ARM/fp16-full.ll
@@ -57,14 +57,25 @@
ret void
}
-; FIXME
-;define void @test_frem(half* %p, half* %q) {
-; %a = load half, half* %p, align 2
-; %b = load half, half* %q, align 2
-; %r = frem half %a, %b
-; store half %r, half* %p
-; ret void
-;}
+define arm_aapcs_vfpcc void @test_frem(half* %p, half* %q) {
+; CHECK-LABEL: test_frem:
+; CHECK: .save {r4, lr}
+; CHECK-NEXT: push {r4, lr}
+; CHECK-NEXT: vldr.16 s2, [r1]
+; CHECK-NEXT: vldr.16 s0, [r0]
+; CHECK-NEXT: mov r4, r0
+; CHECK-NEXT: vcvtb.f32.f16 s0, s0
+; CHECK-NEXT: vcvtb.f32.f16 s1, s2
+; CHECK-NEXT: bl fmodf
+; CHECK-NEXT: vcvtb.f16.f32 s0, s0
+; CHECK-NEXT: vstr.16 s0, [r4]
+; CHECK-NEXT: pop {r4, pc}
+ %a = load half, half* %p, align 2
+ %b = load half, half* %q, align 2
+ %r = frem half %a, %b
+ store half %r, half* %p
+ ret void
+}
define void @test_load_store(half* %p, half* %q) {
; CHECK-LABEL: test_load_store:
Index: llvm/lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -1142,6 +1142,11 @@
}
}
+ // FP16 often need to be promoted to call lib functions
+ if (Subtarget->hasFullFP16()) {
+ setOperationAction(ISD::FREM, MVT::f16, Promote);
+ }
+
if (Subtarget->hasNEON()) {
// vmin and vmax aren't available in a scalar form, so we use
// a NEON instruction with an undef lane instead.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62321.200983.patch
Type: text/x-patch
Size: 1668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190523/84480d5a/attachment.bin>
More information about the llvm-commits
mailing list