-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[X86][BF16] Add libcall for F80 -> BF16 #109116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This fixes llvm#108936, but the calling convention doesn't match with GCC. I doubt we have such a lib function for now, so leave the calling convention as is.
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-backend-x86 Author: Phoebe Wang (phoebewang) ChangesThis fixes #108936, but the calling convention doesn't match with GCC. I doubt we have such a lib function for now, so leave the calling convention as is. Full diff: https://github.com/llvm/llvm-project/pull/109116.diff 3 Files Affected:
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.def b/llvm/include/llvm/IR/RuntimeLibcalls.def
index c3d5ef9f4e4f82..69cf43140ad4bd 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.def
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.def
@@ -367,6 +367,7 @@ HANDLE_LIBCALL(FPROUND_F128_F16, "__trunctfhf2")
HANDLE_LIBCALL(FPROUND_PPCF128_F16, "__trunctfhf2")
HANDLE_LIBCALL(FPROUND_F32_BF16, "__truncsfbf2")
HANDLE_LIBCALL(FPROUND_F64_BF16, "__truncdfbf2")
+HANDLE_LIBCALL(FPROUND_F80_BF16, "__truncxfbf2")
HANDLE_LIBCALL(FPROUND_F64_F32, "__truncdfsf2")
HANDLE_LIBCALL(FPROUND_F80_F32, "__truncxfsf2")
HANDLE_LIBCALL(FPROUND_F128_F32, "__trunctfsf2")
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index eb3190c7cd247a..9fdde454559171 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -169,6 +169,8 @@ RTLIB::Libcall RTLIB::getFPROUND(EVT OpVT, EVT RetVT) {
return FPROUND_F32_BF16;
if (OpVT == MVT::f64)
return FPROUND_F64_BF16;
+ if (OpVT == MVT::f80)
+ return FPROUND_F80_BF16;
} else if (RetVT == MVT::f32) {
if (OpVT == MVT::f64)
return FPROUND_F64_F32;
diff --git a/llvm/test/CodeGen/X86/bfloat.ll b/llvm/test/CodeGen/X86/bfloat.ll
index 3759909a2ccc8e..3144fd56d9ccf3 100644
--- a/llvm/test/CodeGen/X86/bfloat.ll
+++ b/llvm/test/CodeGen/X86/bfloat.ll
@@ -1953,3 +1953,25 @@ define void @PR92471(ptr %0, ptr %1) nounwind {
store <7 x float> %4, ptr %1, align 4
ret void
}
+
+define bfloat @PR108936(x86_fp80 %0) nounwind {
+; X86-LABEL: PR108936:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: fldt {{[0-9]+}}(%esp)
+; X86-NEXT: fstpt (%esp)
+; X86-NEXT: calll __truncxfbf2
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; CHECK-LABEL: PR108936:
+; CHECK: # %bb.0:
+; CHECK-NEXT: subq $24, %rsp
+; CHECK-NEXT: fldt {{[0-9]+}}(%rsp)
+; CHECK-NEXT: fstpt (%rsp)
+; CHECK-NEXT: callq __truncxfbf2@PLT
+; CHECK-NEXT: addq $24, %rsp
+; CHECK-NEXT: retq
+ %2 = fptrunc x86_fp80 %0 to bfloat
+ ret bfloat %2
+}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If GCC already has the method people will eventually end up linking with libgcc and run into calling convention differences. Why are they different?
Sorry, I mixed up. We have the same behavior with GCC. GCC supports it since 13.1 https://godbolt.org/z/dnhaeGvf7 |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/6849 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/159/builds/6335 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/12/builds/6066 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/123/builds/5859 Here is the relevant piece of the build log for the reference
|
This reverts commit 76eda76.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/174/builds/5337 Here is the relevant piece of the build log for the reference
|
This reverts commit ababfee78714313a0cad87591b819f0944b90d09.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/8/builds/4662 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/5720 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/11/builds/5213 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/32/builds/5156 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/7/builds/4512 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/9289 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/113/builds/2862 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/4/builds/2238 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/143/builds/2242 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/56/builds/7705 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/146/builds/1188 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/128/builds/682 Here is the relevant piece of the build log for the reference
|
This fixes llvm#108936, but the calling convention doesn't match with GCC. I doubt we have such a lib function for now, so leave the calling convention as is.
…109143) This reverts commit ababfee78714313a0cad87591b819f0944b90d09. Add X86 FP80 check.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/133/builds/3999 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/81/builds/1960 Here is the relevant piece of the build log for the reference
|
This fixes #108936, but the calling convention doesn't match with GCC. I doubt we have such a lib function for now, so leave the calling convention as is.