[llvm] Emit float128 libcalls for some F128 variants (PR #79611)
Pranav Kant via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 5 09:26:12 PST 2024
https://github.com/pranavk updated https://github.com/llvm/llvm-project/pull/79611
>From ca1b79d0ebb269c16fae1759c19c93c4ba9719e0 Mon Sep 17 00:00:00 2001
From: Pranav Kant <prka at google.com>
Date: Fri, 26 Jan 2024 02:16:42 +0000
Subject: [PATCH 1/2] add f128 libcalls
---
llvm/include/llvm/IR/RuntimeLibcalls.def | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.def b/llvm/include/llvm/IR/RuntimeLibcalls.def
index 19dea60bebf9b..01cab92bf8414 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.def
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.def
@@ -252,17 +252,17 @@ HANDLE_LIBCALL(FLOOR_PPCF128, "floorl")
HANDLE_LIBCALL(COPYSIGN_F32, "copysignf")
HANDLE_LIBCALL(COPYSIGN_F64, "copysign")
HANDLE_LIBCALL(COPYSIGN_F80, "copysignl")
-HANDLE_LIBCALL(COPYSIGN_F128, "copysignl")
+HANDLE_LIBCALL(COPYSIGN_F128, "copysignf128")
HANDLE_LIBCALL(COPYSIGN_PPCF128, "copysignl")
HANDLE_LIBCALL(FMIN_F32, "fminf")
HANDLE_LIBCALL(FMIN_F64, "fmin")
HANDLE_LIBCALL(FMIN_F80, "fminl")
-HANDLE_LIBCALL(FMIN_F128, "fminl")
+HANDLE_LIBCALL(FMIN_F128, "fminf128")
HANDLE_LIBCALL(FMIN_PPCF128, "fminl")
HANDLE_LIBCALL(FMAX_F32, "fmaxf")
HANDLE_LIBCALL(FMAX_F64, "fmax")
HANDLE_LIBCALL(FMAX_F80, "fmaxl")
-HANDLE_LIBCALL(FMAX_F128, "fmaxl")
+HANDLE_LIBCALL(FMAX_F128, "fmaxf128")
HANDLE_LIBCALL(FMAX_PPCF128, "fmaxl")
HANDLE_LIBCALL(LROUND_F32, "lroundf")
HANDLE_LIBCALL(LROUND_F64, "lround")
>From 41c19c81bb0ad6bbb5de9ea2f9cf14fd96cd68d1 Mon Sep 17 00:00:00 2001
From: Pranav Kant <prka at google.com>
Date: Mon, 5 Feb 2024 17:25:26 +0000
Subject: [PATCH 2/2] change tests for f128 libcalls
---
llvm/test/CodeGen/AArch64/GlobalISel/legalize-fmaxnum.mir | 4 ++--
llvm/test/CodeGen/AArch64/GlobalISel/legalize-fminnum.mir | 2 +-
llvm/test/CodeGen/AArch64/fp-intrinsics.ll | 4 ++--
.../CodeGen/AArch64/vecreduce-fmax-legalization-nan.ll | 2 +-
llvm/test/CodeGen/AArch64/vecreduce-fmax-legalization.ll | 2 +-
llvm/test/CodeGen/AArch64/vecreduce-fmin-legalization.ll | 2 +-
llvm/test/CodeGen/Mips/cconv/fmaxl_call.ll | 2 +-
llvm/test/CodeGen/SystemZ/atomicrmw-fmax-03.ll | 2 +-
llvm/test/CodeGen/SystemZ/atomicrmw-fmin-03.ll | 2 +-
llvm/test/CodeGen/SystemZ/fp-libcall.ll | 2 +-
llvm/test/CodeGen/X86/fp128-libcalls-strict.ll | 8 ++++----
llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp | 4 ++--
12 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-fmaxnum.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-fmaxnum.mir
index 01b60f5584062..5042ef7003583 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-fmaxnum.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-fmaxnum.mir
@@ -109,7 +109,7 @@ body: |
; FP16-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
; FP16-NEXT: $q0 = COPY %a(s128)
; FP16-NEXT: $q1 = COPY %b(s128)
- ; FP16-NEXT: BL &fmaxl, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $q0, implicit $q1, implicit-def $q0
+ ; FP16-NEXT: BL &fmaxf128, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $q0, implicit $q1, implicit-def $q0
; FP16-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
; FP16-NEXT: %maxnum:_(s128) = COPY $q0
; FP16-NEXT: $q0 = COPY %maxnum(s128)
@@ -123,7 +123,7 @@ body: |
; NO-FP16-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
; NO-FP16-NEXT: $q0 = COPY %a(s128)
; NO-FP16-NEXT: $q1 = COPY %b(s128)
- ; NO-FP16-NEXT: BL &fmaxl, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $q0, implicit $q1, implicit-def $q0
+ ; NO-FP16-NEXT: BL &fmaxf128, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $q0, implicit $q1, implicit-def $q0
; NO-FP16-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
; NO-FP16-NEXT: %maxnum:_(s128) = COPY $q0
; NO-FP16-NEXT: $q0 = COPY %maxnum(s128)
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-fminnum.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-fminnum.mir
index 2d6f9f9e774c7..c6cbd0009d423 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-fminnum.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-fminnum.mir
@@ -91,7 +91,7 @@ body: |
; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
; CHECK-NEXT: $q0 = COPY %a(s128)
; CHECK-NEXT: $q1 = COPY %b(s128)
- ; CHECK-NEXT: BL &fminl, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $q0, implicit $q1, implicit-def $q0
+ ; CHECK-NEXT: BL &fminf128, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $q0, implicit $q1, implicit-def $q0
; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
; CHECK-NEXT: %minnum:_(s128) = COPY $q0
; CHECK-NEXT: $q0 = COPY %minnum(s128)
diff --git a/llvm/test/CodeGen/AArch64/fp-intrinsics.ll b/llvm/test/CodeGen/AArch64/fp-intrinsics.ll
index f80a8df18a03a..740c6407454e3 100644
--- a/llvm/test/CodeGen/AArch64/fp-intrinsics.ll
+++ b/llvm/test/CodeGen/AArch64/fp-intrinsics.ll
@@ -1185,14 +1185,14 @@ define i64 @llrint_f128(fp128 %x) #0 {
}
; CHECK-LABEL: maxnum_f128:
-; CHECK: bl fmaxl
+; CHECK: bl fmaxf128
define fp128 @maxnum_f128(fp128 %x, fp128 %y) #0 {
%val = call fp128 @llvm.experimental.constrained.maxnum.f128(fp128 %x, fp128 %y, metadata !"fpexcept.strict") #0
ret fp128 %val
}
; CHECK-LABEL: minnum_f128:
-; CHECK: bl fminl
+; CHECK: bl fminf128
define fp128 @minnum_f128(fp128 %x, fp128 %y) #0 {
%val = call fp128 @llvm.experimental.constrained.minnum.f128(fp128 %x, fp128 %y, metadata !"fpexcept.strict") #0
ret fp128 %val
diff --git a/llvm/test/CodeGen/AArch64/vecreduce-fmax-legalization-nan.ll b/llvm/test/CodeGen/AArch64/vecreduce-fmax-legalization-nan.ll
index 4354fcd465dac..ef2eed4e495c8 100644
--- a/llvm/test/CodeGen/AArch64/vecreduce-fmax-legalization-nan.ll
+++ b/llvm/test/CodeGen/AArch64/vecreduce-fmax-legalization-nan.ll
@@ -585,7 +585,7 @@ define float @test_v3f32_ninf(<3 x float> %a) nounwind {
define fp128 @test_v2f128(<2 x fp128> %a) nounwind {
; CHECK-LABEL: test_v2f128:
; CHECK: // %bb.0:
-; CHECK-NEXT: b fmaxl
+; CHECK-NEXT: b fmaxf128
%b = call fp128 @llvm.vector.reduce.fmax.v2f128(<2 x fp128> %a)
ret fp128 %b
}
diff --git a/llvm/test/CodeGen/AArch64/vecreduce-fmax-legalization.ll b/llvm/test/CodeGen/AArch64/vecreduce-fmax-legalization.ll
index 4f1e3fdc34fcd..8c81fc46486ac 100644
--- a/llvm/test/CodeGen/AArch64/vecreduce-fmax-legalization.ll
+++ b/llvm/test/CodeGen/AArch64/vecreduce-fmax-legalization.ll
@@ -650,7 +650,7 @@ define float @test_v3f32_ninf(<3 x float> %a) nounwind {
define fp128 @test_v2f128(<2 x fp128> %a) nounwind {
; CHECK-LABEL: test_v2f128:
; CHECK: // %bb.0:
-; CHECK-NEXT: b fmaxl
+; CHECK-NEXT: b fmaxf128
%b = call nnan fp128 @llvm.vector.reduce.fmax.v2f128(<2 x fp128> %a)
ret fp128 %b
}
diff --git a/llvm/test/CodeGen/AArch64/vecreduce-fmin-legalization.ll b/llvm/test/CodeGen/AArch64/vecreduce-fmin-legalization.ll
index a2bfc3c438da3..e99fc041effc9 100644
--- a/llvm/test/CodeGen/AArch64/vecreduce-fmin-legalization.ll
+++ b/llvm/test/CodeGen/AArch64/vecreduce-fmin-legalization.ll
@@ -650,7 +650,7 @@ define float @test_v3f32_ninf(<3 x float> %a) nounwind {
define fp128 @test_v2f128(<2 x fp128> %a) nounwind {
; CHECK-LABEL: test_v2f128:
; CHECK: // %bb.0:
-; CHECK-NEXT: b fminl
+; CHECK-NEXT: b fminf128
%b = call nnan fp128 @llvm.vector.reduce.fmin.v2f128(<2 x fp128> %a)
ret fp128 %b
}
diff --git a/llvm/test/CodeGen/Mips/cconv/fmaxl_call.ll b/llvm/test/CodeGen/Mips/cconv/fmaxl_call.ll
index 0e3078edae45d..a2dfede48226c 100644
--- a/llvm/test/CodeGen/Mips/cconv/fmaxl_call.ll
+++ b/llvm/test/CodeGen/Mips/cconv/fmaxl_call.ll
@@ -8,7 +8,7 @@ define fp128 @call_fmaxl(fp128 %a, fp128 %b) {
; CHECK-NEXT: .cfi_def_cfa_offset 16
; CHECK-NEXT: sd $ra, 8($sp) # 8-byte Folded Spill
; CHECK-NEXT: .cfi_offset 31, -8
-; CHECK-NEXT: jal fmaxl
+; CHECK-NEXT: jal fmaxf128
; CHECK-NEXT: nop
; CHECK-NEXT: mov.d $f12, $f0
; CHECK-NEXT: jal f
diff --git a/llvm/test/CodeGen/SystemZ/atomicrmw-fmax-03.ll b/llvm/test/CodeGen/SystemZ/atomicrmw-fmax-03.ll
index 3c8ea19f86f86..a3c50387ad09b 100644
--- a/llvm/test/CodeGen/SystemZ/atomicrmw-fmax-03.ll
+++ b/llvm/test/CodeGen/SystemZ/atomicrmw-fmax-03.ll
@@ -19,7 +19,7 @@ define void @f1(ptr %ret, ptr %src, ptr %b) {
; CHECK: la %r4, 160(%r15)
; CHECK: std [[FSL]], 176(%r15)
; CHECK: std [[FSH]], 184(%r15)
-; CHECK: brasl %r14, fmaxl at PLT
+; CHECK: brasl %r14, fmaxf128
; CHECK: ld [[FL:%f[0-9]+]], 192(%r15)
; CHECK: ld [[FH:%f[0-9]+]], 200(%r15)
; CHECK: lgdr [[RH:%r[0-9]+]], [[FH]]
diff --git a/llvm/test/CodeGen/SystemZ/atomicrmw-fmin-03.ll b/llvm/test/CodeGen/SystemZ/atomicrmw-fmin-03.ll
index dfa2cc021d166..9b41fac5ff026 100644
--- a/llvm/test/CodeGen/SystemZ/atomicrmw-fmin-03.ll
+++ b/llvm/test/CodeGen/SystemZ/atomicrmw-fmin-03.ll
@@ -19,7 +19,7 @@ define void @f1(ptr %ret, ptr %src, ptr %b) {
; CHECK: la %r4, 160(%r15)
; CHECK: std [[FSL]], 176(%r15)
; CHECK: std [[FSH]], 184(%r15)
-; CHECK: brasl %r14, fminl at PLT
+; CHECK: brasl %r14, fminf128
; CHECK: ld [[FL:%f[0-9]+]], 192(%r15)
; CHECK: ld [[FH:%f[0-9]+]], 200(%r15)
; CHECK: lgdr [[RH:%r[0-9]+]], [[FH]]
diff --git a/llvm/test/CodeGen/SystemZ/fp-libcall.ll b/llvm/test/CodeGen/SystemZ/fp-libcall.ll
index 60b698e34fcfe..c4bf5328017e2 100644
--- a/llvm/test/CodeGen/SystemZ/fp-libcall.ll
+++ b/llvm/test/CodeGen/SystemZ/fp-libcall.ll
@@ -228,7 +228,7 @@ define double @f32(double %x, double %y) {
define fp128 @f33(fp128 %x, fp128 %y) {
; CHECK-LABEL: f33:
-; CHECK: brasl %r14, fmaxl at PLT
+; CHECK: brasl %r14, fmaxf128
%tmp = call fp128 @llvm.maxnum.f128(fp128 %x, fp128 %y)
ret fp128 %tmp
}
diff --git a/llvm/test/CodeGen/X86/fp128-libcalls-strict.ll b/llvm/test/CodeGen/X86/fp128-libcalls-strict.ll
index 4722ce62f6e56..3cc06a312241e 100644
--- a/llvm/test/CodeGen/X86/fp128-libcalls-strict.ll
+++ b/llvm/test/CodeGen/X86/fp128-libcalls-strict.ll
@@ -505,7 +505,7 @@ define fp128 @maxnum(fp128 %x, fp128 %y) nounwind strictfp {
; CHECK-LABEL: maxnum:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq fmaxl at PLT
+; CHECK-NEXT: callq fmaxf128
; CHECK-NEXT: popq %rax
; CHECK-NEXT: retq
;
@@ -525,7 +525,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)
@@ -542,7 +542,7 @@ define fp128 @minnum(fp128 %x, fp128 %y) nounwind strictfp {
; CHECK-LABEL: minnum:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq fminl at PLT
+; CHECK-NEXT: callq fminf128
; CHECK-NEXT: popq %rax
; CHECK-NEXT: retq
;
@@ -562,7 +562,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)
diff --git a/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp b/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
index d7876b7ce8749..05f7af9bf6947 100644
--- a/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
+++ b/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
@@ -2957,7 +2957,7 @@ TEST_F(AArch64GISelMITest, LibcallFMinNum) {
CHECK: BL &fmin
CHECK: $q0 = COPY [[ANYEXT]]
CHECK: $q1 = COPY [[ANYEXT]]
- CHECK: BL &fminl
+ CHECK: BL &fminf128
)";
// Check
@@ -3008,7 +3008,7 @@ TEST_F(AArch64GISelMITest, LibcallFMaxNum) {
CHECK: BL &fmax
CHECK: $q0 = COPY [[ANYEXT]]
CHECK: $q1 = COPY [[ANYEXT]]
- CHECK: BL &fmaxl
+ CHECK: BL &fmaxf128
)";
// Check
More information about the llvm-commits
mailing list