[PATCH] D94557: [ARM] Fixed incorrect lowering when using GNUEABI (libgcc) and 16bit floats

Kevin Peizner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 12 14:44:32 PST 2021


kevinpeizner created this revision.
kevinpeizner added a reviewer: rengolin.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls.
kevinpeizner requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

  When compiling code that uses 16bit floating point and the compilation
  targets GNUEABI, the intrinsic __gnu_d2h_ieee from libgcc should be
  used rather than __aeabi_d2h which is not available in libgcc.
  
  An example of this issue can be found in this Compiler Explorer
  instance (using clang trunk as of Jan 04, 2020):
  https://godbolt.org/z/anj1Y6
  
  In the Compiler Explorer example, if you switch the target between
  armv7-unknown-linux-gnueabihf and armv7-unknown-linux-eabihf you can
  see many intrinsics are correctly swapped except for __aeabi_d2h.
  
  This commit makes correct the code comment (line 710 in
  ARMISelLowering.cpp as of commit 32c47ebef18):
  
    // In EABI, these functions have an __aeabi_ prefix, but in GNUEABI they have
    // a __gnu_ prefix (which is the default).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94557

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


Index: llvm/test/CodeGen/ARM/fp16.ll
===================================================================
--- llvm/test/CodeGen/ARM/fp16.ll
+++ llvm/test/CodeGen/ARM/fp16.ll
@@ -82,7 +82,7 @@
   %val = call i16 @llvm.convert.to.fp16.f64(double %in)
 ; CHECK-HARDFLOAT-EABI: bl __aeabi_d2h
 
-; CHECK-HARDFLOAT-GNU: bl __aeabi_d2h
+; CHECK-HARDFLOAT-GNU: bl __gnu_d2h_ieee
 
 ; CHECK-FP16-SAFE: bl __aeabi_d2h
 
@@ -94,7 +94,7 @@
 
 ; CHECK-SOFTFLOAT-EABI: bl __aeabi_d2h
 
-; CHECK-SOFTFLOAT-GNU: bl __aeabi_d2h
+; CHECK-SOFTFLOAT-GNU: bl __gnu_d2h_ieee
   ret i16 %val
 }
 
Index: llvm/lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -598,7 +598,7 @@
       // Conversions between floating types.
       // RTABI chapter 4.1.2, Table 7
       { RTLIB::FPROUND_F64_F32, "__aeabi_d2f", CallingConv::ARM_AAPCS, ISD::SETCC_INVALID },
-      { RTLIB::FPROUND_F64_F16, "__aeabi_d2h", CallingConv::ARM_AAPCS, ISD::SETCC_INVALID },
+      { RTLIB::FPROUND_F64_F16, "__gnu_d2h_ieee", CallingConv::ARM_AAPCS, ISD::SETCC_INVALID },
       { RTLIB::FPEXT_F32_F64,   "__aeabi_f2d", CallingConv::ARM_AAPCS, ISD::SETCC_INVALID },
 
       // Integer to floating-point conversions.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94557.316243.patch
Type: text/x-patch
Size: 1312 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210112/88e97a13/attachment.bin>


More information about the llvm-commits mailing list