[llvm] d8a68fe - [Hexagon] Omit calls to specialized {float,fix} routines (#117423)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 12:21:53 PST 2025
Author: Brian Cain
Date: 2025-01-15T14:21:48-06:00
New Revision: d8a68fe68093366a0218474b476fa4e795bef2f8
URL: https://github.com/llvm/llvm-project/commit/d8a68fe68093366a0218474b476fa4e795bef2f8
DIFF: https://github.com/llvm/llvm-project/commit/d8a68fe68093366a0218474b476fa4e795bef2f8.diff
LOG: [Hexagon] Omit calls to specialized {float,fix} routines (#117423)
These were introduced in 1213a7a57fdc (Hexagon backend support,
2011-12-12) but they aren't present in libclangrt.builtins-hexagon. The
generic versions of these functions are present in the builtins, though.
So it should suffice to call those instead.
Added:
llvm/test/CodeGen/Hexagon/i128-fpconv-strict.ll
Modified:
llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
index 900a9054fc2c3a..a19f9749cd9e3d 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -1861,13 +1861,6 @@ HexagonTargetLowering::HexagonTargetLowering(const TargetMachine &TM,
setLibcallName(RTLIB::UREM_I32, "__hexagon_umodsi3");
setLibcallName(RTLIB::UREM_I64, "__hexagon_umoddi3");
- setLibcallName(RTLIB::SINTTOFP_I128_F64, "__hexagon_floattidf");
- setLibcallName(RTLIB::SINTTOFP_I128_F32, "__hexagon_floattisf");
- setLibcallName(RTLIB::FPTOUINT_F32_I128, "__hexagon_fixunssfti");
- setLibcallName(RTLIB::FPTOUINT_F64_I128, "__hexagon_fixunsdfti");
- setLibcallName(RTLIB::FPTOSINT_F32_I128, "__hexagon_fixsfti");
- setLibcallName(RTLIB::FPTOSINT_F64_I128, "__hexagon_fixdfti");
-
// This is the only fast library function for sqrtd.
if (FastMath)
setLibcallName(RTLIB::SQRT_F64, "__hexagon_fast2_sqrtdf2");
diff --git a/llvm/test/CodeGen/Hexagon/i128-fpconv-strict.ll b/llvm/test/CodeGen/Hexagon/i128-fpconv-strict.ll
new file mode 100644
index 00000000000000..01ae98009d78c7
--- /dev/null
+++ b/llvm/test/CodeGen/Hexagon/i128-fpconv-strict.ll
@@ -0,0 +1,81 @@
+; RUN: llc < %s -mtriple=hexagon-unknown-linux-musl \
+; RUN: | FileCheck %s -check-prefix=CHECK
+
+define i64 @double_to_i128(double %d) nounwind strictfp {
+; CHECK-LABEL: double_to_i128:
+; CHECK: // %bb.0:
+; CHECK: call __fixdfti
+; CHECK: dealloc_return
+ %1 = tail call i128 @llvm.experimental.constrained.fptosi.i128.f64(double %d, metadata !"fpexcept.strict")
+ %2 = trunc i128 %1 to i64
+ ret i64 %2
+}
+
+define i64 @double_to_ui128(double %d) nounwind strictfp {
+; CHECK-LABEL: double_to_ui128:
+; CHECK: // %bb.0:
+; CHECK: call __fixunsdfti
+; CHECK: dealloc_return
+ %1 = tail call i128 @llvm.experimental.constrained.fptoui.i128.f64(double %d, metadata !"fpexcept.strict")
+ %2 = trunc i128 %1 to i64
+ ret i64 %2
+}
+
+define i64 @float_to_i128(float %d) nounwind strictfp {
+; CHECK-LABEL: float_to_i128:
+; CHECK: // %bb.0:
+; CHECK: call __fixsfti
+; CHECK: dealloc_return
+ %1 = tail call i128 @llvm.experimental.constrained.fptosi.i128.f32(float %d, metadata !"fpexcept.strict")
+ %2 = trunc i128 %1 to i64
+ ret i64 %2
+}
+
+define i64 @float_to_ui128(float %d) nounwind strictfp {
+; CHECK-LABEL: float_to_ui128:
+; CHECK: // %bb.0:
+; CHECK: call __fixunssfti
+; CHECK: dealloc_return
+ %1 = tail call i128 @llvm.experimental.constrained.fptoui.i128.f32(float %d, metadata !"fpexcept.strict")
+ %2 = trunc i128 %1 to i64
+ ret i64 %2
+}
+
+define double @ui128_to_double(ptr nocapture readonly %0) nounwind strictfp {
+; CHECK-LABEL: ui128_to_double:
+; CHECK: // %bb.0:
+; CHECK: call __floatuntidf
+; CHECK: dealloc_return
+ %2 = load i128, ptr %0, align 16
+ %3 = tail call double @llvm.experimental.constrained.uitofp.f64.i128(i128 %2, metadata !"round.dynamic", metadata !"fpexcept.strict")
+ ret double %3
+}
+
+define float @i128_to_float(ptr nocapture readonly %0) nounwind strictfp {
+; CHECK-LABEL: i128_to_float:
+; CHECK: // %bb.0:
+; CHECK: call __floattisf
+; CHECK: dealloc_return
+ %2 = load i128, ptr %0, align 16
+ %3 = tail call float @llvm.experimental.constrained.sitofp.f32.i128(i128 %2, metadata !"round.dynamic", metadata !"fpexcept.strict")
+ ret float %3
+}
+
+define float @ui128_to_float(ptr nocapture readonly %0) nounwind strictfp {
+; CHECK-LABEL: ui128_to_float:
+; CHECK: // %bb.0:
+; CHECK: call __floatuntisf
+; CHECK: dealloc_return
+ %2 = load i128, ptr %0, align 16
+ %3 = tail call float @llvm.experimental.constrained.uitofp.f32.i128(i128 %2, metadata !"round.dynamic", metadata !"fpexcept.strict")
+ ret float %3
+}
+
+declare i128 @llvm.experimental.constrained.fptosi.i128.f64(double, metadata)
+declare i128 @llvm.experimental.constrained.fptoui.i128.f64(double, metadata)
+declare i128 @llvm.experimental.constrained.fptosi.i128.f32(float, metadata)
+declare i128 @llvm.experimental.constrained.fptoui.i128.f32(float, metadata)
+declare double @llvm.experimental.constrained.sitofp.f64.i128(i128, metadata, metadata)
+declare double @llvm.experimental.constrained.uitofp.f64.i128(i128, metadata, metadata)
+declare float @llvm.experimental.constrained.sitofp.f32.i128(i128, metadata, metadata)
+declare float @llvm.experimental.constrained.uitofp.f32.i128(i128, metadata, metadata)
More information about the llvm-commits
mailing list