[PATCH] D62321: [ARM] Promote fp16 frem

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 26 03:27:45 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL361713: [ARM] Promote fp16 frem (authored by dmgreen, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62321?vs=200983&id=201439#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62321/new/

https://reviews.llvm.org/D62321

Files:
  llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
  llvm/trunk/test/CodeGen/ARM/fp16-fullfp16.ll


Index: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
+++ llvm/trunk/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.
Index: llvm/trunk/test/CodeGen/ARM/fp16-fullfp16.ll
===================================================================
--- llvm/trunk/test/CodeGen/ARM/fp16-fullfp16.ll
+++ llvm/trunk/test/CodeGen/ARM/fp16-fullfp16.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:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62321.201439.patch
Type: text/x-patch
Size: 1716 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190526/65b9400d/attachment.bin>


More information about the llvm-commits mailing list