-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[X86][GlobalISel] Enable G_LROUND/G_LLROUND with libcall mapping #125096
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
@llvm/pr-subscribers-backend-x86 @llvm/pr-subscribers-llvm-globalisel Author: None (JaydeepChauhan14) ChangesFull diff: https://github.com/llvm/llvm-project/pull/125096.diff 4 Files Affected:
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index d0a62340a5f322..8550e684eed328 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -411,6 +411,10 @@ static RTLIB::Libcall getRTLibDesc(unsigned Opcode, unsigned Size) {
} while (0)
switch (Opcode) {
+ case TargetOpcode::G_LROUND:
+ RTLIBCASE(LROUND_F);
+ case TargetOpcode::G_LLROUND:
+ RTLIBCASE(LLROUND_F);
case TargetOpcode::G_MUL:
RTLIBCASE_INT(MUL_I);
case TargetOpcode::G_SDIV:
@@ -1267,6 +1271,8 @@ LegalizerHelper::libcall(MachineInstr &MI, LostDebugLocObserver &LocObserver) {
return Status;
break;
}
+ case TargetOpcode::G_LROUND:
+ case TargetOpcode::G_LLROUND:
case TargetOpcode::G_INTRINSIC_LRINT:
case TargetOpcode::G_INTRINSIC_LLRINT: {
LLT LLTy = MRI.getType(MI.getOperand(1).getReg());
diff --git a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
index bab7fe9d25e441..ff0a0b1d0fd216 100644
--- a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
+++ b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
@@ -99,6 +99,18 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
.widenScalarToNextPow2(0, /*Min=*/8)
.clampScalar(0, s8, sMaxScalar);
+ getActionDefinitionsBuilder(G_LROUND)
+ .libcallIf([=](const LegalityQuery &Query) -> bool {
+ return (typeInSet(0, {s32, s64})(Query) &&
+ typeInSet(1, {s32, s64, s80})(Query));
+ });
+
+ getActionDefinitionsBuilder(G_LLROUND)
+ .libcallIf([=](const LegalityQuery &Query) -> bool {
+ return (typeIs(0, s64)(Query) &&
+ typeInSet(1, {s32, s64, s80})(Query));
+ });
+
// merge/unmerge
for (unsigned Op : {G_MERGE_VALUES, G_UNMERGE_VALUES}) {
unsigned BigTyIdx = Op == G_MERGE_VALUES ? 0 : 1;
diff --git a/llvm/test/CodeGen/X86/isel-llround.ll b/llvm/test/CodeGen/X86/isel-llround.ll
new file mode 100644
index 00000000000000..6f644cbe6ea2e4
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-llround.ll
@@ -0,0 +1,139 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc < %s -mtriple=i686-linux-gnu | FileCheck %s --check-prefixes=X86,SDAG-X86
+; RUN: llc < %s -mtriple=i686-linux-gnu -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=X86,FASTISEL-X86
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu | FileCheck %s --check-prefixes=SDAG-X64
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=FASTISEL-X64
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X64
+
+define i64 @test_llround_i64_f32(float %x) nounwind {
+; X86-LABEL: test_llround_i64_f32:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: flds {{[0-9]+}}(%esp)
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll llroundf
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; GISEL-X86-LABEL: test_llround_i64_f32:
+; GISEL-X86: # %bb.0:
+; GISEL-X86-NEXT: subl $12, %esp
+; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT: movl %eax, (%esp)
+; GISEL-X86-NEXT: calll llroundf
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: test_llround_i64_f32:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp llroundf@PLT # TAILCALL
+;
+; FASTISEL-X64-LABEL: test_llround_i64_f32:
+; FASTISEL-X64: # %bb.0:
+; FASTISEL-X64-NEXT: pushq %rax
+; FASTISEL-X64-NEXT: callq llroundf@PLT
+; FASTISEL-X64-NEXT: popq %rcx
+; FASTISEL-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_llround_i64_f32:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq llroundf
+; GISEL-X64-NEXT: popq %rcx
+; GISEL-X64-NEXT: retq
+ %conv = call i64 @llvm.llround.i64.f32(float %x)
+ ret i64 %conv
+}
+
+define i64 @test_llround_i64_f64(double %x) nounwind {
+; X86-LABEL: test_llround_i64_f64:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl (%esp)
+; X86-NEXT: calll llround
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; GISEL-X86-LABEL: test_llround_i64_f64:
+; GISEL-X86: # %bb.0:
+; GISEL-X86-NEXT: subl $12, %esp
+; GISEL-X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; GISEL-X86-NEXT: movl 4(%eax), %eax
+; GISEL-X86-NEXT: xorl %edx, %edx
+; GISEL-X86-NEXT: addl %esp, %edx
+; GISEL-X86-NEXT: movl %ecx, (%esp)
+; GISEL-X86-NEXT: movl %eax, 4(%edx)
+; GISEL-X86-NEXT: calll llround
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: test_llround_i64_f64:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp llround@PLT # TAILCALL
+;
+; FASTISEL-X64-LABEL: test_llround_i64_f64:
+; FASTISEL-X64: # %bb.0:
+; FASTISEL-X64-NEXT: pushq %rax
+; FASTISEL-X64-NEXT: callq llround@PLT
+; FASTISEL-X64-NEXT: popq %rcx
+; FASTISEL-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_llround_i64_f64:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq llround
+; GISEL-X64-NEXT: popq %rcx
+; GISEL-X64-NEXT: retq
+ %conv = call i64 @llvm.llround.i64.f64(double %x)
+ ret i64 %conv
+}
+
+define i64 @test_llround_i64_f80(x86_fp80 %x) nounwind {
+; X86-LABEL: test_llround_i64_f80:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: fldt {{[0-9]+}}(%esp)
+; X86-NEXT: fstpt (%esp)
+; X86-NEXT: calll llroundl
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; GISEL-X86-LABEL: test_llround_i64_f80:
+; GISEL-X86: # %bb.0:
+; GISEL-X86-NEXT: subl $12, %esp
+; GISEL-X86-NEXT: fldt {{[0-9]+}}(%esp)
+; GISEL-X86-NEXT: fstpt (%esp)
+; GISEL-X86-NEXT: calll llroundl
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: test_llround_i64_f80:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp llroundl@PLT # TAILCALL
+;
+; FASTISEL-X64-LABEL: test_llround_i64_f80:
+; FASTISEL-X64: # %bb.0:
+; FASTISEL-X64-NEXT: subq $24, %rsp
+; FASTISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; FASTISEL-X64-NEXT: fstpt (%rsp)
+; FASTISEL-X64-NEXT: callq llroundl@PLT
+; FASTISEL-X64-NEXT: addq $24, %rsp
+; FASTISEL-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_llround_i64_f80:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: subq $24, %rsp
+; GISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fstpt (%rsp)
+; GISEL-X64-NEXT: callq llroundl
+; GISEL-X64-NEXT: addq $24, %rsp
+; GISEL-X64-NEXT: retq
+ %conv = call i64 @llvm.llround.i64.f80(x86_fp80 %x)
+ ret i64 %conv
+}
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; FASTISEL-X86: {{.*}}
+; SDAG-X86: {{.*}}
diff --git a/llvm/test/CodeGen/X86/isel-lround.ll b/llvm/test/CodeGen/X86/isel-lround.ll
new file mode 100644
index 00000000000000..b175b4ec77f910
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-lround.ll
@@ -0,0 +1,277 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc < %s -mtriple=i686-linux-gnu | FileCheck %s --check-prefixes=X86,SDAG-X86
+; RUN: llc < %s -mtriple=i686-linux-gnu -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=X86,FASTISEL-X86
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu | FileCheck %s --check-prefixes=SDAG-X64
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=FASTISEL-X64
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X64
+
+define i32 @test_lround_i32_f32(float %x) nounwind {
+; SDAG-X86-LABEL: test_lround_i32_f32:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: jmp lroundf # TAILCALL
+;
+; FASTISEL-X86-LABEL: test_lround_i32_f32:
+; FASTISEL-X86: # %bb.0:
+; FASTISEL-X86-NEXT: subl $12, %esp
+; FASTISEL-X86-NEXT: flds {{[0-9]+}}(%esp)
+; FASTISEL-X86-NEXT: fstps (%esp)
+; FASTISEL-X86-NEXT: calll lroundf
+; FASTISEL-X86-NEXT: addl $12, %esp
+; FASTISEL-X86-NEXT: retl
+;
+; GISEL-X86-LABEL: test_lround_i32_f32:
+; GISEL-X86: # %bb.0:
+; GISEL-X86-NEXT: subl $12, %esp
+; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT: movl %eax, (%esp)
+; GISEL-X86-NEXT: calll lroundf
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: test_lround_i32_f32:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp lroundf@PLT # TAILCALL
+;
+; FASTISEL-X64-LABEL: test_lround_i32_f32:
+; FASTISEL-X64: # %bb.0:
+; FASTISEL-X64-NEXT: pushq %rax
+; FASTISEL-X64-NEXT: callq lroundf@PLT
+; FASTISEL-X64-NEXT: popq %rcx
+; FASTISEL-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_lround_i32_f32:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq lroundf
+; GISEL-X64-NEXT: popq %rcx
+; GISEL-X64-NEXT: retq
+ %conv = call i32 @llvm.lround.i32.f32(float %x)
+ ret i32 %conv
+}
+
+define i32 @test_lround_i32_f64(double %x) nounwind {
+; SDAG-X86-LABEL: test_lround_i32_f64:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: jmp lround # TAILCALL
+;
+; FASTISEL-X86-LABEL: test_lround_i32_f64:
+; FASTISEL-X86: # %bb.0:
+; FASTISEL-X86-NEXT: subl $12, %esp
+; FASTISEL-X86-NEXT: fldl {{[0-9]+}}(%esp)
+; FASTISEL-X86-NEXT: fstpl (%esp)
+; FASTISEL-X86-NEXT: calll lround
+; FASTISEL-X86-NEXT: addl $12, %esp
+; FASTISEL-X86-NEXT: retl
+;
+; GISEL-X86-LABEL: test_lround_i32_f64:
+; GISEL-X86: # %bb.0:
+; GISEL-X86-NEXT: subl $12, %esp
+; GISEL-X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; GISEL-X86-NEXT: movl 4(%eax), %eax
+; GISEL-X86-NEXT: xorl %edx, %edx
+; GISEL-X86-NEXT: addl %esp, %edx
+; GISEL-X86-NEXT: movl %ecx, (%esp)
+; GISEL-X86-NEXT: movl %eax, 4(%edx)
+; GISEL-X86-NEXT: calll lround
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: test_lround_i32_f64:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp lround@PLT # TAILCALL
+;
+; FASTISEL-X64-LABEL: test_lround_i32_f64:
+; FASTISEL-X64: # %bb.0:
+; FASTISEL-X64-NEXT: pushq %rax
+; FASTISEL-X64-NEXT: callq lround@PLT
+; FASTISEL-X64-NEXT: popq %rcx
+; FASTISEL-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_lround_i32_f64:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq lround
+; GISEL-X64-NEXT: popq %rcx
+; GISEL-X64-NEXT: retq
+ %conv = call i32 @llvm.lround.i32.f64(double %x)
+ ret i32 %conv
+}
+
+define i32 @test_lround_i32_f80(x86_fp80 %x) nounwind {
+; SDAG-X86-LABEL: test_lround_i32_f80:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: jmp lroundl # TAILCALL
+;
+; FASTISEL-X86-LABEL: test_lround_i32_f80:
+; FASTISEL-X86: # %bb.0:
+; FASTISEL-X86-NEXT: subl $12, %esp
+; FASTISEL-X86-NEXT: fldt {{[0-9]+}}(%esp)
+; FASTISEL-X86-NEXT: fstpt (%esp)
+; FASTISEL-X86-NEXT: calll lroundl
+; FASTISEL-X86-NEXT: addl $12, %esp
+; FASTISEL-X86-NEXT: retl
+;
+; GISEL-X86-LABEL: test_lround_i32_f80:
+; GISEL-X86: # %bb.0:
+; GISEL-X86-NEXT: subl $12, %esp
+; GISEL-X86-NEXT: fldt {{[0-9]+}}(%esp)
+; GISEL-X86-NEXT: fstpt (%esp)
+; GISEL-X86-NEXT: calll lroundl
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: test_lround_i32_f80:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp lroundl@PLT # TAILCALL
+;
+; FASTISEL-X64-LABEL: test_lround_i32_f80:
+; FASTISEL-X64: # %bb.0:
+; FASTISEL-X64-NEXT: subq $24, %rsp
+; FASTISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; FASTISEL-X64-NEXT: fstpt (%rsp)
+; FASTISEL-X64-NEXT: callq lroundl@PLT
+; FASTISEL-X64-NEXT: addq $24, %rsp
+; FASTISEL-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_lround_i32_f80:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: subq $24, %rsp
+; GISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fstpt (%rsp)
+; GISEL-X64-NEXT: callq lroundl
+; GISEL-X64-NEXT: addq $24, %rsp
+; GISEL-X64-NEXT: retq
+ %conv = call i32 @llvm.lround.i32.f80(x86_fp80 %x)
+ ret i32 %conv
+}
+
+define i64 @test_lround_i64_f32(float %x) nounwind {
+; X86-LABEL: test_lround_i64_f32:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: flds {{[0-9]+}}(%esp)
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll lroundf
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; GISEL-X86-LABEL: test_lround_i64_f32:
+; GISEL-X86: # %bb.0:
+; GISEL-X86-NEXT: subl $12, %esp
+; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT: movl %eax, (%esp)
+; GISEL-X86-NEXT: calll lroundf
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: test_lround_i64_f32:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp lroundf@PLT # TAILCALL
+;
+; FASTISEL-X64-LABEL: test_lround_i64_f32:
+; FASTISEL-X64: # %bb.0:
+; FASTISEL-X64-NEXT: pushq %rax
+; FASTISEL-X64-NEXT: callq lroundf@PLT
+; FASTISEL-X64-NEXT: popq %rcx
+; FASTISEL-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_lround_i64_f32:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq lroundf
+; GISEL-X64-NEXT: popq %rcx
+; GISEL-X64-NEXT: retq
+ %conv = call i64 @llvm.lround.i64.f32(float %x)
+ ret i64 %conv
+}
+
+define i64 @test_lround_i64_f64(double %x) nounwind {
+; X86-LABEL: test_lround_i64_f64:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl (%esp)
+; X86-NEXT: calll lround
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; GISEL-X86-LABEL: test_lround_i64_f64:
+; GISEL-X86: # %bb.0:
+; GISEL-X86-NEXT: subl $12, %esp
+; GISEL-X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; GISEL-X86-NEXT: movl 4(%eax), %eax
+; GISEL-X86-NEXT: xorl %edx, %edx
+; GISEL-X86-NEXT: addl %esp, %edx
+; GISEL-X86-NEXT: movl %ecx, (%esp)
+; GISEL-X86-NEXT: movl %eax, 4(%edx)
+; GISEL-X86-NEXT: calll lround
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: test_lround_i64_f64:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp lround@PLT # TAILCALL
+;
+; FASTISEL-X64-LABEL: test_lround_i64_f64:
+; FASTISEL-X64: # %bb.0:
+; FASTISEL-X64-NEXT: pushq %rax
+; FASTISEL-X64-NEXT: callq lround@PLT
+; FASTISEL-X64-NEXT: popq %rcx
+; FASTISEL-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_lround_i64_f64:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq lround
+; GISEL-X64-NEXT: popq %rcx
+; GISEL-X64-NEXT: retq
+ %conv = call i64 @llvm.lround.i64.f64(double %x)
+ ret i64 %conv
+}
+
+define i64 @test_lround_i64_f80(x86_fp80 %x) nounwind {
+; X86-LABEL: test_lround_i64_f80:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: fldt {{[0-9]+}}(%esp)
+; X86-NEXT: fstpt (%esp)
+; X86-NEXT: calll lroundl
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; GISEL-X86-LABEL: test_lround_i64_f80:
+; GISEL-X86: # %bb.0:
+; GISEL-X86-NEXT: subl $12, %esp
+; GISEL-X86-NEXT: fldt {{[0-9]+}}(%esp)
+; GISEL-X86-NEXT: fstpt (%esp)
+; GISEL-X86-NEXT: calll lroundl
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: test_lround_i64_f80:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp lroundl@PLT # TAILCALL
+;
+; FASTISEL-X64-LABEL: test_lround_i64_f80:
+; FASTISEL-X64: # %bb.0:
+; FASTISEL-X64-NEXT: subq $24, %rsp
+; FASTISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; FASTISEL-X64-NEXT: fstpt (%rsp)
+; FASTISEL-X64-NEXT: callq lroundl@PLT
+; FASTISEL-X64-NEXT: addq $24, %rsp
+; FASTISEL-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_lround_i64_f80:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: subq $24, %rsp
+; GISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fstpt (%rsp)
+; GISEL-X64-NEXT: callq lroundl
+; GISEL-X64-NEXT: addq $24, %rsp
+; GISEL-X64-NEXT: retq
+ %conv = call i64 @llvm.lround.i64.f80(x86_fp80 %x)
+ ret i64 %conv
+}
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
@e-kud please review PR. |
.libcallIf([=](const LegalityQuery &Query) -> bool { | ||
return (typeInSet(0, {s32, s64})(Query) && | ||
typeInSet(1, {s32, s64, s80})(Query)); | ||
}); | ||
|
||
getActionDefinitionsBuilder(G_LLROUND) | ||
.libcallIf([=](const LegalityQuery &Query) -> bool { | ||
return (typeIs(0, s64)(Query) && | ||
typeInSet(1, {s32, s64, s80})(Query)); | ||
}); |
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.
You're only doing basic type checks here. Use libcallFor?
But also, you're not specifying any actions that don't use a libcall. You could just make this an unconditional libcall()
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.
Done
@@ -0,0 +1,139 @@ | |||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | |||
; RUN: llc < %s -mtriple=i686-linux-gnu | FileCheck %s --check-prefixes=X86,SDAG-X86 |
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.
Should explicitly disable global isel for the DAG run lines.
Can you merge this into an existing test? If not should probably be in the GlobalISel subdirectory
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.
Done
No description provided.