Skip to content

[X86] Consistently use f128 libcalls #142386

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

Merged
merged 2 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ Changes to the Windows Target
Changes to the X86 Backend
--------------------------

* `fp128` will now use `*f128` libcalls on 32-bit GNU targets as well.

Changes to the OCaml bindings
-----------------------------

Expand Down
9 changes: 7 additions & 2 deletions llvm/lib/IR/RuntimeLibcalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
for (int LC = 0; LC < RTLIB::UNKNOWN_LIBCALL; ++LC)
setLibcallCallingConv((RTLIB::Libcall)LC, CallingConv::C);

// Use the f128 variants of math functions on x86_64
if (TT.getArch() == Triple::ArchType::x86_64 && TT.isGNUEnvironment()) {
// Use the f128 variants of math functions on x86
if (TT.isX86() && TT.isGNUEnvironment()) {
setLibcallName(RTLIB::REM_F128, "fmodf128");
setLibcallName(RTLIB::FMA_F128, "fmaf128");
setLibcallName(RTLIB::SQRT_F128, "sqrtf128");
Expand Down Expand Up @@ -65,12 +65,17 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
setLibcallName(RTLIB::COPYSIGN_F128, "copysignf128");
setLibcallName(RTLIB::FMIN_F128, "fminf128");
setLibcallName(RTLIB::FMAX_F128, "fmaxf128");
setLibcallName(RTLIB::FMINIMUM_F128, "fminimumf128");
setLibcallName(RTLIB::FMAXIMUM_F128, "fmaximumf128");
setLibcallName(RTLIB::FMINIMUMNUM_F128, "fminimum_numf128");
setLibcallName(RTLIB::FMAXIMUMNUM_F128, "fmaximum_numf128");
setLibcallName(RTLIB::LROUND_F128, "lroundf128");
setLibcallName(RTLIB::LLROUND_F128, "llroundf128");
setLibcallName(RTLIB::LRINT_F128, "lrintf128");
setLibcallName(RTLIB::LLRINT_F128, "llrintf128");
setLibcallName(RTLIB::LDEXP_F128, "ldexpf128");
setLibcallName(RTLIB::FREXP_F128, "frexpf128");
setLibcallName(RTLIB::MODF_F128, "modff128");
}

// For IEEE quad-precision libcall names, PPC uses "kf" instead of "tf".
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/CodeGen/X86/fminimum-fmaximum-i686.ll
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ define fp128 @maximum_fp128(fp128 %x, fp128 %y) nounwind {
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
; CHECK-NEXT: pushl %eax
; CHECK-NEXT: calll fmaximuml
; CHECK-NEXT: calll fmaximumf128
; CHECK-NEXT: addl $44, %esp
; CHECK-NEXT: movl (%esp), %eax
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
Expand Down Expand Up @@ -496,7 +496,7 @@ define fp128 @minimum_fp128(fp128 %x, fp128 %y) nounwind {
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
; CHECK-NEXT: pushl %eax
; CHECK-NEXT: calll fminimuml
; CHECK-NEXT: calll fminimumf128
; CHECK-NEXT: addl $44, %esp
; CHECK-NEXT: movl (%esp), %eax
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
Expand Down Expand Up @@ -533,7 +533,7 @@ define fp128 @maximumnum_fp128(fp128 %x, fp128 %y) nounwind {
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
; CHECK-NEXT: pushl %eax
; CHECK-NEXT: calll fmaximum_numl
; CHECK-NEXT: calll fmaximum_numf128
; CHECK-NEXT: addl $44, %esp
; CHECK-NEXT: movl (%esp), %eax
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
Expand Down Expand Up @@ -570,7 +570,7 @@ define fp128 @minimumnum_fp128(fp128 %x, fp128 %y) nounwind {
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
; CHECK-NEXT: pushl %eax
; CHECK-NEXT: calll fminimum_numl
; CHECK-NEXT: calll fminimum_numf128
; CHECK-NEXT: addl $44, %esp
; CHECK-NEXT: movl (%esp), %eax
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
Expand Down
64 changes: 32 additions & 32 deletions llvm/test/CodeGen/X86/fp128-libcalls-strict.ll
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ define fp128 @fma(fp128 %x, fp128 %y, fp128 %z) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll fmal
; X86-NEXT: calll fmaf128
; X86-NEXT: addl $60, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -552,7 +552,7 @@ define fp128 @frem(fp128 %x, fp128 %y) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll fmodl
; X86-NEXT: calll fmodf128
; X86-NEXT: addl $44, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -641,7 +641,7 @@ define fp128 @ceil(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll ceill
; X86-NEXT: calll ceilf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -723,7 +723,7 @@ define fp128 @acos(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll acosl
; X86-NEXT: calll acosf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -805,7 +805,7 @@ define fp128 @cos(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll cosl
; X86-NEXT: calll cosf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -887,7 +887,7 @@ define fp128 @cosh(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll coshl
; X86-NEXT: calll coshf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -969,7 +969,7 @@ define fp128 @exp(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll expl
; X86-NEXT: calll expf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -1051,7 +1051,7 @@ define fp128 @exp2(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll exp2l
; X86-NEXT: calll exp2f128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -1133,7 +1133,7 @@ define fp128 @floor(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll floorl
; X86-NEXT: calll floorf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -1215,7 +1215,7 @@ define fp128 @log(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll logl
; X86-NEXT: calll logf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -1297,7 +1297,7 @@ define fp128 @log10(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll log10l
; X86-NEXT: calll log10f128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -1379,7 +1379,7 @@ define fp128 @log2(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll log2l
; X86-NEXT: calll log2f128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -1465,7 +1465,7 @@ define fp128 @maxnum(fp128 %x, fp128 %y) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll fmaxl
; X86-NEXT: calll fmaxf128
; X86-NEXT: addl $44, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -1558,7 +1558,7 @@ define fp128 @minnum(fp128 %x, fp128 %y) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll fminl
; X86-NEXT: calll fminf128
; X86-NEXT: addl $44, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -1647,7 +1647,7 @@ define fp128 @nearbyint(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll nearbyintl
; X86-NEXT: calll nearbyintf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -1733,7 +1733,7 @@ define fp128 @pow(fp128 %x, fp128 %y) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll powl
; X86-NEXT: calll powf128
; X86-NEXT: addl $44, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -1913,7 +1913,7 @@ define fp128 @rint(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll rintl
; X86-NEXT: calll rintf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -1995,7 +1995,7 @@ define fp128 @round(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll roundl
; X86-NEXT: calll roundf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -2077,7 +2077,7 @@ define fp128 @roundeven(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll roundevenl
; X86-NEXT: calll roundevenf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -2159,7 +2159,7 @@ define fp128 @asin(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll asinl
; X86-NEXT: calll asinf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -2241,7 +2241,7 @@ define fp128 @sin(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll sinl
; X86-NEXT: calll sinf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -2323,7 +2323,7 @@ define fp128 @sinh(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll sinhl
; X86-NEXT: calll sinhf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -2405,7 +2405,7 @@ define fp128 @sqrt(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll sqrtl
; X86-NEXT: calll sqrtf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -2487,7 +2487,7 @@ define fp128 @atan(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll atanl
; X86-NEXT: calll atanf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -2573,7 +2573,7 @@ define fp128 @atan2(fp128 %x, fp128 %y) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll atan2l
; X86-NEXT: calll atan2f128
; X86-NEXT: addl $44, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -2662,7 +2662,7 @@ define fp128 @tan(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll tanl
; X86-NEXT: calll tanf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -2744,7 +2744,7 @@ define fp128 @tanh(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll tanhl
; X86-NEXT: calll tanhf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -2826,7 +2826,7 @@ define fp128 @trunc(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl %eax
; X86-NEXT: calll truncl
; X86-NEXT: calll truncf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: movaps (%esp), %xmm0
; X86-NEXT: movaps %xmm0, (%esi)
Expand Down Expand Up @@ -2903,7 +2903,7 @@ define i32 @lrint(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: calll lrintl
; X86-NEXT: calll lrintf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: retl
;
Expand Down Expand Up @@ -2953,7 +2953,7 @@ define i64 @llrint(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: calll llrintl
; X86-NEXT: calll llrintf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: retl
;
Expand Down Expand Up @@ -3003,7 +3003,7 @@ define i32 @lround(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: calll lroundl
; X86-NEXT: calll lroundf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: retl
;
Expand Down Expand Up @@ -3053,7 +3053,7 @@ define i64 @llround(fp128 %x) nounwind strictfp {
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: pushl {{[0-9]+}}(%esp)
; X86-NEXT: calll llroundl
; X86-NEXT: calll llroundf128
; X86-NEXT: addl $28, %esp
; X86-NEXT: retl
;
Expand Down
Loading