[llvm] [X86][GlobalISel] Enable Trigonometric functions with libcall mapping (PR #126931)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 26 03:10:07 PST 2025
https://github.com/JaydeepChauhan14 updated https://github.com/llvm/llvm-project/pull/126931
>From c830b83e12be13ded0523efad36ee502715c18c5 Mon Sep 17 00:00:00 2001
From: Chauhan Jaydeep Ashwinbhai <chauhan.jaydeep.ashwinbhai at intel.com>
Date: Wed, 12 Feb 2025 23:50:48 +0800
Subject: [PATCH] [X86][GlobalISel] Enable Trigonometric functions with libcall
mapping
---
.../lib/Target/X86/GISel/X86LegalizerInfo.cpp | 7 +-
llvm/test/CodeGen/X86/llvm.acos.ll | 226 +++++++++++--
llvm/test/CodeGen/X86/llvm.asin.ll | 226 +++++++++++--
llvm/test/CodeGen/X86/llvm.atan.ll | 226 +++++++++++--
llvm/test/CodeGen/X86/llvm.atan2.ll | 308 +++++++++++++++---
llvm/test/CodeGen/X86/llvm.cos.ll | 110 +++++++
llvm/test/CodeGen/X86/llvm.cosh.ll | 226 +++++++++++--
llvm/test/CodeGen/X86/llvm.sin.ll | 110 +++++++
llvm/test/CodeGen/X86/llvm.sinh.ll | 226 +++++++++++--
llvm/test/CodeGen/X86/llvm.tan.ll | 226 +++++++++++--
llvm/test/CodeGen/X86/llvm.tanh.ll | 226 +++++++++++--
11 files changed, 1848 insertions(+), 269 deletions(-)
create mode 100644 llvm/test/CodeGen/X86/llvm.cos.ll
create mode 100644 llvm/test/CodeGen/X86/llvm.sin.ll
diff --git a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
index c73179c4c9466..684580d6fca06 100644
--- a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
+++ b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
@@ -99,9 +99,10 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
.widenScalarToNextPow2(0, /*Min=*/8)
.clampScalar(0, s8, sMaxScalar);
- getActionDefinitionsBuilder(G_LROUND).libcall();
-
- getActionDefinitionsBuilder(G_LLROUND).libcall();
+ getActionDefinitionsBuilder({G_LROUND, G_LLROUND, G_FCOS, G_FCOSH, G_FACOS,
+ G_FSIN, G_FSINH, G_FASIN, G_FTAN, G_FTANH,
+ G_FATAN, G_FATAN2})
+ .libcall();
// merge/unmerge
for (unsigned Op : {G_MERGE_VALUES, G_UNMERGE_VALUES}) {
diff --git a/llvm/test/CodeGen/X86/llvm.acos.ll b/llvm/test/CodeGen/X86/llvm.acos.ll
index 202fde8291930..bf1395d6239c9 100644
--- a/llvm/test/CodeGen/X86/llvm.acos.ll
+++ b/llvm/test/CodeGen/X86/llvm.acos.ll
@@ -1,63 +1,225 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
-; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+; We don't handle fp16 and fp128 types for "-global-isel" so we allow fallbacks in these cases to SDAG.
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X86,SDAG-X86
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X64,SDAG-X64
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86,GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X64,GISEL-X64
define half @use_acosf16(half %a) nounwind {
-; CHECK-LABEL: use_acosf16:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq __extendhfsf2 at PLT
-; CHECK-NEXT: callq acosf at PLT
-; CHECK-NEXT: callq __truncsfhf2 at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_acosf16:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl %eax, (%esp)
+; X86-NEXT: calll __gnu_h2f_ieee
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll acosf
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll __gnu_f2h_ieee
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_acosf16:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq __extendhfsf2 at PLT
+; X64-NEXT: callq acosf at PLT
+; X64-NEXT: callq __truncsfhf2 at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call half @llvm.acos.f16(half %a)
ret half %x
}
define float @use_acosf32(float %a) nounwind {
-; CHECK-LABEL: use_acosf32:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp acosf at PLT # TAILCALL
+; SDAG-X86-LABEL: use_acosf32:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: flds {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstps (%esp)
+; SDAG-X86-NEXT: calll acosf
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_acosf32:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp acosf at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_acosf32:
+; 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 acosf
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_acosf32:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq acosf
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call float @llvm.acos.f32(float %a)
ret float %x
}
define double @use_acosf64(double %a) nounwind {
-; CHECK-LABEL: use_acosf64:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp acos at PLT # TAILCALL
+; SDAG-X86-LABEL: use_acosf64:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: fldl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstpl (%esp)
+; SDAG-X86-NEXT: calll acos
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_acosf64:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp acos at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_acosf64:
+; 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 acos
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_acosf64:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq acos
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call double @llvm.acos.f64(double %a)
ret double %x
}
define x86_fp80 @use_acosf80(x86_fp80 %a) nounwind {
-; CHECK-LABEL: use_acosf80:
-; CHECK: # %bb.0:
-; CHECK-NEXT: subq $24, %rsp
-; CHECK-NEXT: fldt 32(%rsp)
-; CHECK-NEXT: fstpt (%rsp)
-; CHECK-NEXT: callq acosl at PLT
-; CHECK-NEXT: addq $24, %rsp
-; CHECK-NEXT: retq
+; X86-LABEL: use_acosf80:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: fldt {{[0-9]+}}(%esp)
+; X86-NEXT: fstpt (%esp)
+; X86-NEXT: calll acosl
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_acosf80:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: subq $24, %rsp
+; SDAG-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fstpt (%rsp)
+; SDAG-X64-NEXT: callq acosl at PLT
+; SDAG-X64-NEXT: addq $24, %rsp
+; SDAG-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: use_acosf80:
+; 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 acosl
+; GISEL-X64-NEXT: addq $24, %rsp
+; GISEL-X64-NEXT: retq
%x = call x86_fp80 @llvm.acos.f80(x86_fp80 %a)
ret x86_fp80 %x
}
define fp128 @use_acosfp128(fp128 %a) nounwind {
-; CHECK-LABEL: use_acosfp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp acosf128 at PLT # TAILCALL
+; X86-LABEL: use_acosfp128:
+; X86: # %bb.0:
+; X86-NEXT: pushl %edi
+; X86-NEXT: pushl %esi
+; X86-NEXT: subl $20, %esp
+; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl %eax
+; X86-NEXT: calll acosl
+; X86-NEXT: addl $28, %esp
+; X86-NEXT: movl (%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
+; X86-NEXT: movl %edi, 12(%esi)
+; X86-NEXT: movl %edx, 8(%esi)
+; X86-NEXT: movl %ecx, 4(%esi)
+; X86-NEXT: movl %eax, (%esi)
+; X86-NEXT: movl %esi, %eax
+; X86-NEXT: addl $20, %esp
+; X86-NEXT: popl %esi
+; X86-NEXT: popl %edi
+; X86-NEXT: retl $4
+;
+; SDAG-X64-LABEL: use_acosfp128:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp acosf128 at PLT # TAILCALL
+;
+; GISEL-X64-LABEL: use_acosfp128:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq acosf128
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call fp128 @llvm.acos.f128(fp128 %a)
ret fp128 %x
}
define ppc_fp128 @use_acosppc_fp128(ppc_fp128 %a) nounwind {
-; CHECK-LABEL: use_acosppc_fp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq acosl at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_acosppc_fp128:
+; X86: # %bb.0:
+; X86-NEXT: subl $92, %esp
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl (%esp)
+; X86-NEXT: calll acosl
+; X86-NEXT: fxch %st(1)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: addl $92, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_acosppc_fp128:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq acosl at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call ppc_fp128 @llvm.acos.ppcf128(ppc_fp128 %a)
ret ppc_fp128 %x
}
diff --git a/llvm/test/CodeGen/X86/llvm.asin.ll b/llvm/test/CodeGen/X86/llvm.asin.ll
index 1e047d01c703c..ddcf58a899240 100644
--- a/llvm/test/CodeGen/X86/llvm.asin.ll
+++ b/llvm/test/CodeGen/X86/llvm.asin.ll
@@ -1,63 +1,225 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
-; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+; We don't handle fp16 and fp128 types for "-global-isel" so we allow fallbacks in these cases to SDAG.
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X86,SDAG-X86
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X64,SDAG-X64
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86,GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X64,GISEL-X64
define half @use_asinf16(half %a) nounwind {
-; CHECK-LABEL: use_asinf16:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq __extendhfsf2 at PLT
-; CHECK-NEXT: callq asinf at PLT
-; CHECK-NEXT: callq __truncsfhf2 at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_asinf16:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl %eax, (%esp)
+; X86-NEXT: calll __gnu_h2f_ieee
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll asinf
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll __gnu_f2h_ieee
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_asinf16:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq __extendhfsf2 at PLT
+; X64-NEXT: callq asinf at PLT
+; X64-NEXT: callq __truncsfhf2 at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call half @llvm.asin.f16(half %a)
ret half %x
}
define float @use_asinf32(float %a) nounwind {
-; CHECK-LABEL: use_asinf32:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp asinf at PLT # TAILCALL
+; SDAG-X86-LABEL: use_asinf32:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: flds {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstps (%esp)
+; SDAG-X86-NEXT: calll asinf
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_asinf32:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp asinf at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_asinf32:
+; 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 asinf
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_asinf32:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq asinf
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call float @llvm.asin.f32(float %a)
ret float %x
}
define double @use_asinf64(double %a) nounwind {
-; CHECK-LABEL: use_asinf64:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp asin at PLT # TAILCALL
+; SDAG-X86-LABEL: use_asinf64:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: fldl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstpl (%esp)
+; SDAG-X86-NEXT: calll asin
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_asinf64:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp asin at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_asinf64:
+; 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 asin
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_asinf64:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq asin
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call double @llvm.asin.f64(double %a)
ret double %x
}
define x86_fp80 @use_asinf80(x86_fp80 %a) nounwind {
-; CHECK-LABEL: use_asinf80:
-; CHECK: # %bb.0:
-; CHECK-NEXT: subq $24, %rsp
-; CHECK-NEXT: fldt 32(%rsp)
-; CHECK-NEXT: fstpt (%rsp)
-; CHECK-NEXT: callq asinl at PLT
-; CHECK-NEXT: addq $24, %rsp
-; CHECK-NEXT: retq
+; X86-LABEL: use_asinf80:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: fldt {{[0-9]+}}(%esp)
+; X86-NEXT: fstpt (%esp)
+; X86-NEXT: calll asinl
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_asinf80:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: subq $24, %rsp
+; SDAG-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fstpt (%rsp)
+; SDAG-X64-NEXT: callq asinl at PLT
+; SDAG-X64-NEXT: addq $24, %rsp
+; SDAG-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: use_asinf80:
+; 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 asinl
+; GISEL-X64-NEXT: addq $24, %rsp
+; GISEL-X64-NEXT: retq
%x = call x86_fp80 @llvm.asin.f80(x86_fp80 %a)
ret x86_fp80 %x
}
define fp128 @use_asinfp128(fp128 %a) nounwind {
-; CHECK-LABEL: use_asinfp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp asinf128 at PLT # TAILCALL
+; X86-LABEL: use_asinfp128:
+; X86: # %bb.0:
+; X86-NEXT: pushl %edi
+; X86-NEXT: pushl %esi
+; X86-NEXT: subl $20, %esp
+; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl %eax
+; X86-NEXT: calll asinl
+; X86-NEXT: addl $28, %esp
+; X86-NEXT: movl (%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
+; X86-NEXT: movl %edi, 12(%esi)
+; X86-NEXT: movl %edx, 8(%esi)
+; X86-NEXT: movl %ecx, 4(%esi)
+; X86-NEXT: movl %eax, (%esi)
+; X86-NEXT: movl %esi, %eax
+; X86-NEXT: addl $20, %esp
+; X86-NEXT: popl %esi
+; X86-NEXT: popl %edi
+; X86-NEXT: retl $4
+;
+; SDAG-X64-LABEL: use_asinfp128:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp asinf128 at PLT # TAILCALL
+;
+; GISEL-X64-LABEL: use_asinfp128:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq asinf128
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call fp128 @llvm.asin.f128(fp128 %a)
ret fp128 %x
}
define ppc_fp128 @use_asinppc_fp128(ppc_fp128 %a) nounwind {
-; CHECK-LABEL: use_asinppc_fp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq asinl at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_asinppc_fp128:
+; X86: # %bb.0:
+; X86-NEXT: subl $92, %esp
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl (%esp)
+; X86-NEXT: calll asinl
+; X86-NEXT: fxch %st(1)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: addl $92, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_asinppc_fp128:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq asinl at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call ppc_fp128 @llvm.asin.ppcf128(ppc_fp128 %a)
ret ppc_fp128 %x
}
diff --git a/llvm/test/CodeGen/X86/llvm.atan.ll b/llvm/test/CodeGen/X86/llvm.atan.ll
index d33ef7fd3ac5f..8e1403c2cb904 100644
--- a/llvm/test/CodeGen/X86/llvm.atan.ll
+++ b/llvm/test/CodeGen/X86/llvm.atan.ll
@@ -1,63 +1,225 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
-; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+; We don't handle fp16 and fp128 types for "-global-isel" so we allow fallbacks in these cases to SDAG.
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X86,SDAG-X86
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X64,SDAG-X64
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86,GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X64,GISEL-X64
define half @use_atanf16(half %a) nounwind {
-; CHECK-LABEL: use_atanf16:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq __extendhfsf2 at PLT
-; CHECK-NEXT: callq atanf at PLT
-; CHECK-NEXT: callq __truncsfhf2 at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_atanf16:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl %eax, (%esp)
+; X86-NEXT: calll __gnu_h2f_ieee
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll atanf
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll __gnu_f2h_ieee
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_atanf16:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq __extendhfsf2 at PLT
+; X64-NEXT: callq atanf at PLT
+; X64-NEXT: callq __truncsfhf2 at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call half @llvm.atan.f16(half %a)
ret half %x
}
define float @use_atanf32(float %a) nounwind {
-; CHECK-LABEL: use_atanf32:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp atanf at PLT # TAILCALL
+; SDAG-X86-LABEL: use_atanf32:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: flds {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstps (%esp)
+; SDAG-X86-NEXT: calll atanf
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_atanf32:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp atanf at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_atanf32:
+; 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 atanf
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_atanf32:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq atanf
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call float @llvm.atan.f32(float %a)
ret float %x
}
define double @use_atanf64(double %a) nounwind {
-; CHECK-LABEL: use_atanf64:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp atan at PLT # TAILCALL
+; SDAG-X86-LABEL: use_atanf64:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: fldl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstpl (%esp)
+; SDAG-X86-NEXT: calll atan
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_atanf64:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp atan at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_atanf64:
+; 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 atan
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_atanf64:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq atan
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call double @llvm.atan.f64(double %a)
ret double %x
}
define x86_fp80 @use_atanf80(x86_fp80 %a) nounwind {
-; CHECK-LABEL: use_atanf80:
-; CHECK: # %bb.0:
-; CHECK-NEXT: subq $24, %rsp
-; CHECK-NEXT: fldt 32(%rsp)
-; CHECK-NEXT: fstpt (%rsp)
-; CHECK-NEXT: callq atanl at PLT
-; CHECK-NEXT: addq $24, %rsp
-; CHECK-NEXT: retq
+; X86-LABEL: use_atanf80:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: fldt {{[0-9]+}}(%esp)
+; X86-NEXT: fstpt (%esp)
+; X86-NEXT: calll atanl
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_atanf80:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: subq $24, %rsp
+; SDAG-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fstpt (%rsp)
+; SDAG-X64-NEXT: callq atanl at PLT
+; SDAG-X64-NEXT: addq $24, %rsp
+; SDAG-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: use_atanf80:
+; 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 atanl
+; GISEL-X64-NEXT: addq $24, %rsp
+; GISEL-X64-NEXT: retq
%x = call x86_fp80 @llvm.atan.f80(x86_fp80 %a)
ret x86_fp80 %x
}
define fp128 @use_atanfp128(fp128 %a) nounwind {
-; CHECK-LABEL: use_atanfp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp atanf128 at PLT # TAILCALL
+; X86-LABEL: use_atanfp128:
+; X86: # %bb.0:
+; X86-NEXT: pushl %edi
+; X86-NEXT: pushl %esi
+; X86-NEXT: subl $20, %esp
+; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl %eax
+; X86-NEXT: calll atanl
+; X86-NEXT: addl $28, %esp
+; X86-NEXT: movl (%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
+; X86-NEXT: movl %edi, 12(%esi)
+; X86-NEXT: movl %edx, 8(%esi)
+; X86-NEXT: movl %ecx, 4(%esi)
+; X86-NEXT: movl %eax, (%esi)
+; X86-NEXT: movl %esi, %eax
+; X86-NEXT: addl $20, %esp
+; X86-NEXT: popl %esi
+; X86-NEXT: popl %edi
+; X86-NEXT: retl $4
+;
+; SDAG-X64-LABEL: use_atanfp128:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp atanf128 at PLT # TAILCALL
+;
+; GISEL-X64-LABEL: use_atanfp128:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq atanf128
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call fp128 @llvm.atan.f128(fp128 %a)
ret fp128 %x
}
define ppc_fp128 @use_atanppc_fp128(ppc_fp128 %a) nounwind {
-; CHECK-LABEL: use_atanppc_fp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq atanl at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_atanppc_fp128:
+; X86: # %bb.0:
+; X86-NEXT: subl $92, %esp
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl (%esp)
+; X86-NEXT: calll atanl
+; X86-NEXT: fxch %st(1)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: addl $92, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_atanppc_fp128:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq atanl at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call ppc_fp128 @llvm.atan.ppcf128(ppc_fp128 %a)
ret ppc_fp128 %x
}
diff --git a/llvm/test/CodeGen/X86/llvm.atan2.ll b/llvm/test/CodeGen/X86/llvm.atan2.ll
index ef2e4be36203b..9fccb62d4116f 100644
--- a/llvm/test/CodeGen/X86/llvm.atan2.ll
+++ b/llvm/test/CodeGen/X86/llvm.atan2.ll
@@ -1,73 +1,297 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
-; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+; We don't handle fp16 and fp128 types for "-global-isel" so we allow fallbacks in these cases to SDAG.
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X86,SDAG-X86
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X64,SDAG-X64
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86,GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X64,GISEL-X64
define half @use_atan2f16(half %a, half %b) nounwind {
-; CHECK-LABEL: use_atan2f16:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: movss %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 4-byte Spill
-; CHECK-NEXT: movaps %xmm1, %xmm0
-; CHECK-NEXT: callq __extendhfsf2 at PLT
-; CHECK-NEXT: movss %xmm0, (%rsp) # 4-byte Spill
-; CHECK-NEXT: movss {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 4-byte Reload
-; CHECK-NEXT: # xmm0 = mem[0],zero,zero,zero
-; CHECK-NEXT: callq __extendhfsf2 at PLT
-; CHECK-NEXT: movss (%rsp), %xmm1 # 4-byte Reload
-; CHECK-NEXT: # xmm1 = mem[0],zero,zero,zero
-; CHECK-NEXT: callq atan2f at PLT
-; CHECK-NEXT: callq __truncsfhf2 at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_atan2f16:
+; X86: # %bb.0:
+; X86-NEXT: pushl %esi
+; X86-NEXT: subl $24, %esp
+; X86-NEXT: movzwl {{[0-9]+}}(%esp), %esi
+; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl %eax, (%esp)
+; X86-NEXT: calll __gnu_h2f_ieee
+; X86-NEXT: fstps {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Folded Spill
+; X86-NEXT: movl %esi, (%esp)
+; X86-NEXT: calll __gnu_h2f_ieee
+; X86-NEXT: fstps {{[0-9]+}}(%esp)
+; X86-NEXT: flds {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Folded Reload
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll atan2f
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll __gnu_f2h_ieee
+; X86-NEXT: addl $24, %esp
+; X86-NEXT: popl %esi
+; X86-NEXT: retl
+;
+; X64-LABEL: use_atan2f16:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: movss %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 4-byte Spill
+; X64-NEXT: movaps %xmm1, %xmm0
+; X64-NEXT: callq __extendhfsf2 at PLT
+; X64-NEXT: movss %xmm0, (%rsp) # 4-byte Spill
+; X64-NEXT: movss {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 4-byte Reload
+; X64-NEXT: # xmm0 = mem[0],zero,zero,zero
+; X64-NEXT: callq __extendhfsf2 at PLT
+; X64-NEXT: movss (%rsp), %xmm1 # 4-byte Reload
+; X64-NEXT: # xmm1 = mem[0],zero,zero,zero
+; X64-NEXT: callq atan2f at PLT
+; X64-NEXT: callq __truncsfhf2 at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call half @llvm.atan2.f16(half %a, half %b)
ret half %x
}
define float @use_atan2f32(float %a, float %b) nounwind {
-; CHECK-LABEL: use_atan2f32:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp atan2f at PLT # TAILCALL
+; SDAG-X86-LABEL: use_atan2f32:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: flds {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: flds {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstps {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstps (%esp)
+; SDAG-X86-NEXT: calll atan2f
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_atan2f32:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp atan2f at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_atan2f32:
+; GISEL-X86: # %bb.0:
+; GISEL-X86-NEXT: subl $12, %esp
+; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; GISEL-X86-NEXT: movl %eax, (%esp)
+; GISEL-X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; GISEL-X86-NEXT: calll atan2f
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_atan2f32:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq atan2f
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call float @llvm.atan2.f32(float %a, float %b)
ret float %x
}
define double @use_atan2f64(double %a, double %b) nounwind {
-; CHECK-LABEL: use_atan2f64:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp atan2 at PLT # TAILCALL
+; SDAG-X86-LABEL: use_atan2f64:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $28, %esp
+; SDAG-X86-NEXT: fldl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fldl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstpl (%esp)
+; SDAG-X86-NEXT: calll atan2
+; SDAG-X86-NEXT: addl $28, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_atan2f64:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp atan2 at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_atan2f64:
+; GISEL-X86: # %bb.0:
+; GISEL-X86-NEXT: pushl %edi
+; GISEL-X86-NEXT: pushl %esi
+; GISEL-X86-NEXT: subl $20, %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: leal {{[0-9]+}}(%esp), %edx
+; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %esi
+; GISEL-X86-NEXT: movl 4(%edx), %edx
+; GISEL-X86-NEXT: xorl %edi, %edi
+; GISEL-X86-NEXT: addl %esp, %edi
+; GISEL-X86-NEXT: movl %ecx, (%esp)
+; GISEL-X86-NEXT: movl %eax, 4(%edi)
+; GISEL-X86-NEXT: movl $8, %eax
+; GISEL-X86-NEXT: addl %esp, %eax
+; GISEL-X86-NEXT: movl %esi, {{[0-9]+}}(%esp)
+; GISEL-X86-NEXT: movl %edx, 4(%eax)
+; GISEL-X86-NEXT: calll atan2
+; GISEL-X86-NEXT: addl $20, %esp
+; GISEL-X86-NEXT: popl %esi
+; GISEL-X86-NEXT: popl %edi
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_atan2f64:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq atan2
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call double @llvm.atan2.f64(double %a, double %b)
ret double %x
}
define x86_fp80 @use_atan2f80(x86_fp80 %a, x86_fp80 %b) nounwind {
-; CHECK-LABEL: use_atan2f80:
-; CHECK: # %bb.0:
-; CHECK-NEXT: subq $40, %rsp
-; CHECK-NEXT: fldt {{[0-9]+}}(%rsp)
-; CHECK-NEXT: fldt {{[0-9]+}}(%rsp)
-; CHECK-NEXT: fstpt {{[0-9]+}}(%rsp)
-; CHECK-NEXT: fstpt (%rsp)
-; CHECK-NEXT: callq atan2l at PLT
-; CHECK-NEXT: addq $40, %rsp
-; CHECK-NEXT: retq
+; SDAG-X86-LABEL: use_atan2f80:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $28, %esp
+; SDAG-X86-NEXT: fldt {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fldt {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstpt {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstpt (%esp)
+; SDAG-X86-NEXT: calll atan2l
+; SDAG-X86-NEXT: addl $28, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_atan2f80:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: subq $40, %rsp
+; SDAG-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fstpt {{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fstpt (%rsp)
+; SDAG-X64-NEXT: callq atan2l at PLT
+; SDAG-X64-NEXT: addq $40, %rsp
+; SDAG-X64-NEXT: retq
+;
+; GISEL-X86-LABEL: use_atan2f80:
+; GISEL-X86: # %bb.0:
+; GISEL-X86-NEXT: subl $28, %esp
+; GISEL-X86-NEXT: fldt {{[0-9]+}}(%esp)
+; GISEL-X86-NEXT: fldt {{[0-9]+}}(%esp)
+; GISEL-X86-NEXT: fxch %st(1)
+; GISEL-X86-NEXT: fstpt (%esp)
+; GISEL-X86-NEXT: fstpt {{[0-9]+}}(%esp)
+; GISEL-X86-NEXT: calll atan2l
+; GISEL-X86-NEXT: addl $28, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_atan2f80:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: subq $40, %rsp
+; GISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: fxch %st(1)
+; GISEL-X64-NEXT: fstpt (%rsp)
+; GISEL-X64-NEXT: fstpt {{[0-9]+}}(%rsp)
+; GISEL-X64-NEXT: callq atan2l
+; GISEL-X64-NEXT: addq $40, %rsp
+; GISEL-X64-NEXT: retq
%x = call x86_fp80 @llvm.atan2.f80(x86_fp80 %a, x86_fp80 %b)
ret x86_fp80 %x
}
define fp128 @use_atan2fp128(fp128 %a, fp128 %b) nounwind {
-; CHECK-LABEL: use_atan2fp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp atan2f128 at PLT # TAILCALL
+; X86-LABEL: use_atan2fp128:
+; X86: # %bb.0:
+; X86-NEXT: pushl %edi
+; X86-NEXT: pushl %esi
+; X86-NEXT: subl $20, %esp
+; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl %eax
+; X86-NEXT: calll atan2l
+; X86-NEXT: addl $44, %esp
+; X86-NEXT: movl (%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
+; X86-NEXT: movl %edi, 12(%esi)
+; X86-NEXT: movl %edx, 8(%esi)
+; X86-NEXT: movl %ecx, 4(%esi)
+; X86-NEXT: movl %eax, (%esi)
+; X86-NEXT: movl %esi, %eax
+; X86-NEXT: addl $20, %esp
+; X86-NEXT: popl %esi
+; X86-NEXT: popl %edi
+; X86-NEXT: retl $4
+;
+; SDAG-X64-LABEL: use_atan2fp128:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp atan2f128 at PLT # TAILCALL
+;
+; GISEL-X64-LABEL: use_atan2fp128:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq atan2f128
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call fp128 @llvm.atan2.f128(fp128 %a, fp128 %b)
ret fp128 %x
}
define ppc_fp128 @use_atan2ppc_fp128(ppc_fp128 %a, ppc_fp128 %b) nounwind {
-; CHECK-LABEL: use_atan2ppc_fp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq atan2l at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_atan2ppc_fp128:
+; X86: # %bb.0:
+; X86-NEXT: subl $140, %esp
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl (%esp)
+; X86-NEXT: calll atan2l
+; X86-NEXT: fxch %st(1)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: addl $140, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_atan2ppc_fp128:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq atan2l at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call ppc_fp128 @llvm.atan2.ppcf128(ppc_fp128 %a, ppc_fp128 %b)
ret ppc_fp128 %x
}
diff --git a/llvm/test/CodeGen/X86/llvm.cos.ll b/llvm/test/CodeGen/X86/llvm.cos.ll
new file mode 100644
index 0000000000000..2ab94e1d23426
--- /dev/null
+++ b/llvm/test/CodeGen/X86/llvm.cos.ll
@@ -0,0 +1,110 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; We don't handle fp16 and fp128 types for "-global-isel" so we allow fallbacks in these cases to SDAG.
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X86,SDAG-X86
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X64,SDAG-X64
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86,GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=GISEL-X64
+
+define float @test_cos_f32(float %Val) nounwind {
+; SDAG-X86-LABEL: test_cos_f32:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: flds {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstps (%esp)
+; SDAG-X86-NEXT: calll cosf
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; X64-LABEL: test_cos_f32:
+; X64: # %bb.0:
+; X64-NEXT: jmp cosf at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: test_cos_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 cosf
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: test_cos_f32:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq cosf
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
+ %res = call float @llvm.cos.f32(float %Val)
+ ret float %res
+}
+
+define double @test_cos_f64(double %Val) nounwind {
+; SDAG-X86-LABEL: test_cos_f64:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: fldl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstpl (%esp)
+; SDAG-X86-NEXT: calll cos
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; X64-LABEL: test_cos_f64:
+; X64: # %bb.0:
+; X64-NEXT: jmp cos at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: test_cos_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 cos
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: test_cos_f64:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq cos
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
+ %res = call double @llvm.cos.f64(double %Val)
+ ret double %res
+}
+
+define x86_fp80 @test_cos_f80(x86_fp80 %Val) nounwind {
+; X86-LABEL: test_cos_f80:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: fldt {{[0-9]+}}(%esp)
+; X86-NEXT: fstpt (%esp)
+; X86-NEXT: calll cosl
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: test_cos_f80:
+; X64: # %bb.0:
+; X64-NEXT: subq $24, %rsp
+; X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; X64-NEXT: fstpt (%rsp)
+; X64-NEXT: callq cosl at PLT
+; X64-NEXT: addq $24, %rsp
+; X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_cos_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 cosl
+; GISEL-X64-NEXT: addq $24, %rsp
+; GISEL-X64-NEXT: retq
+ %res = call x86_fp80 @llvm.cos.f80(x86_fp80 %Val)
+ ret x86_fp80 %res
+}
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; SDAG-X64: {{.*}}
diff --git a/llvm/test/CodeGen/X86/llvm.cosh.ll b/llvm/test/CodeGen/X86/llvm.cosh.ll
index 5e7582c8f86a4..8f881f658e448 100644
--- a/llvm/test/CodeGen/X86/llvm.cosh.ll
+++ b/llvm/test/CodeGen/X86/llvm.cosh.ll
@@ -1,63 +1,225 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
-; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+; We don't handle fp16 and fp128 types for "-global-isel" so we allow fallbacks in these cases to SDAG.
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X86,SDAG-X86
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X64,SDAG-X64
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86,GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X64,GISEL-X64
define half @use_coshf16(half %a) nounwind {
-; CHECK-LABEL: use_coshf16:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq __extendhfsf2 at PLT
-; CHECK-NEXT: callq coshf at PLT
-; CHECK-NEXT: callq __truncsfhf2 at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_coshf16:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl %eax, (%esp)
+; X86-NEXT: calll __gnu_h2f_ieee
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll coshf
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll __gnu_f2h_ieee
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_coshf16:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq __extendhfsf2 at PLT
+; X64-NEXT: callq coshf at PLT
+; X64-NEXT: callq __truncsfhf2 at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call half @llvm.cosh.f16(half %a)
ret half %x
}
define float @use_coshf32(float %a) nounwind {
-; CHECK-LABEL: use_coshf32:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp coshf at PLT # TAILCALL
+; SDAG-X86-LABEL: use_coshf32:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: flds {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstps (%esp)
+; SDAG-X86-NEXT: calll coshf
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_coshf32:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp coshf at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_coshf32:
+; 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 coshf
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_coshf32:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq coshf
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call float @llvm.cosh.f32(float %a)
ret float %x
}
define double @use_coshf64(double %a) nounwind {
-; CHECK-LABEL: use_coshf64:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp cosh at PLT # TAILCALL
+; SDAG-X86-LABEL: use_coshf64:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: fldl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstpl (%esp)
+; SDAG-X86-NEXT: calll cosh
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_coshf64:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp cosh at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_coshf64:
+; 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 cosh
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_coshf64:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq cosh
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call double @llvm.cosh.f64(double %a)
ret double %x
}
define x86_fp80 @use_coshf80(x86_fp80 %a) nounwind {
-; CHECK-LABEL: use_coshf80:
-; CHECK: # %bb.0:
-; CHECK-NEXT: subq $24, %rsp
-; CHECK-NEXT: fldt 32(%rsp)
-; CHECK-NEXT: fstpt (%rsp)
-; CHECK-NEXT: callq coshl at PLT
-; CHECK-NEXT: addq $24, %rsp
-; CHECK-NEXT: retq
+; X86-LABEL: use_coshf80:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: fldt {{[0-9]+}}(%esp)
+; X86-NEXT: fstpt (%esp)
+; X86-NEXT: calll coshl
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_coshf80:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: subq $24, %rsp
+; SDAG-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fstpt (%rsp)
+; SDAG-X64-NEXT: callq coshl at PLT
+; SDAG-X64-NEXT: addq $24, %rsp
+; SDAG-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: use_coshf80:
+; 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 coshl
+; GISEL-X64-NEXT: addq $24, %rsp
+; GISEL-X64-NEXT: retq
%x = call x86_fp80 @llvm.cosh.f80(x86_fp80 %a)
ret x86_fp80 %x
}
define fp128 @use_coshfp128(fp128 %a) nounwind {
-; CHECK-LABEL: use_coshfp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp coshf128 at PLT # TAILCALL
+; X86-LABEL: use_coshfp128:
+; X86: # %bb.0:
+; X86-NEXT: pushl %edi
+; X86-NEXT: pushl %esi
+; X86-NEXT: subl $20, %esp
+; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl %eax
+; X86-NEXT: calll coshl
+; X86-NEXT: addl $28, %esp
+; X86-NEXT: movl (%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
+; X86-NEXT: movl %edi, 12(%esi)
+; X86-NEXT: movl %edx, 8(%esi)
+; X86-NEXT: movl %ecx, 4(%esi)
+; X86-NEXT: movl %eax, (%esi)
+; X86-NEXT: movl %esi, %eax
+; X86-NEXT: addl $20, %esp
+; X86-NEXT: popl %esi
+; X86-NEXT: popl %edi
+; X86-NEXT: retl $4
+;
+; SDAG-X64-LABEL: use_coshfp128:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp coshf128 at PLT # TAILCALL
+;
+; GISEL-X64-LABEL: use_coshfp128:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq coshf128
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call fp128 @llvm.cosh.f128(fp128 %a)
ret fp128 %x
}
define ppc_fp128 @use_coshppc_fp128(ppc_fp128 %a) nounwind {
-; CHECK-LABEL: use_coshppc_fp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq coshl at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_coshppc_fp128:
+; X86: # %bb.0:
+; X86-NEXT: subl $92, %esp
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl (%esp)
+; X86-NEXT: calll coshl
+; X86-NEXT: fxch %st(1)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: addl $92, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_coshppc_fp128:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq coshl at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call ppc_fp128 @llvm.cosh.ppcf128(ppc_fp128 %a)
ret ppc_fp128 %x
}
diff --git a/llvm/test/CodeGen/X86/llvm.sin.ll b/llvm/test/CodeGen/X86/llvm.sin.ll
new file mode 100644
index 0000000000000..e211020dc28c8
--- /dev/null
+++ b/llvm/test/CodeGen/X86/llvm.sin.ll
@@ -0,0 +1,110 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; We don't handle fp16 and fp128 types for "-global-isel" so we allow fallbacks in these cases to SDAG.
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X86,SDAG-X86
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X64,SDAG-X64
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86,GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=GISEL-X64
+
+define float @test_sin_f32(float %Val) nounwind {
+; SDAG-X86-LABEL: test_sin_f32:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: flds {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstps (%esp)
+; SDAG-X86-NEXT: calll sinf
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; X64-LABEL: test_sin_f32:
+; X64: # %bb.0:
+; X64-NEXT: jmp sinf at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: test_sin_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 sinf
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: test_sin_f32:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq sinf
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
+ %res = call float @llvm.sin.f32(float %Val)
+ ret float %res
+}
+
+define double @test_sin_f64(double %Val) nounwind {
+; SDAG-X86-LABEL: test_sin_f64:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: fldl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstpl (%esp)
+; SDAG-X86-NEXT: calll sin
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; X64-LABEL: test_sin_f64:
+; X64: # %bb.0:
+; X64-NEXT: jmp sin at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: test_sin_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 sin
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: test_sin_f64:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq sin
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
+ %res = call double @llvm.sin.f64(double %Val)
+ ret double %res
+}
+
+define x86_fp80 @test_sin_f80(x86_fp80 %Val) nounwind {
+; X86-LABEL: test_sin_f80:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: fldt {{[0-9]+}}(%esp)
+; X86-NEXT: fstpt (%esp)
+; X86-NEXT: calll sinl
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: test_sin_f80:
+; X64: # %bb.0:
+; X64-NEXT: subq $24, %rsp
+; X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; X64-NEXT: fstpt (%rsp)
+; X64-NEXT: callq sinl at PLT
+; X64-NEXT: addq $24, %rsp
+; X64-NEXT: retq
+;
+; GISEL-X64-LABEL: test_sin_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 sinl
+; GISEL-X64-NEXT: addq $24, %rsp
+; GISEL-X64-NEXT: retq
+ %res = call x86_fp80 @llvm.sin.f80(x86_fp80 %Val)
+ ret x86_fp80 %res
+}
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; SDAG-X64: {{.*}}
diff --git a/llvm/test/CodeGen/X86/llvm.sinh.ll b/llvm/test/CodeGen/X86/llvm.sinh.ll
index ba228421117f0..0e954ffd4064f 100644
--- a/llvm/test/CodeGen/X86/llvm.sinh.ll
+++ b/llvm/test/CodeGen/X86/llvm.sinh.ll
@@ -1,63 +1,225 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
-; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+; We don't handle fp16 and fp128 types for "-global-isel" so we allow fallbacks in these cases to SDAG.
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X86,SDAG-X86
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X64,SDAG-X64
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86,GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X64,GISEL-X64
define half @use_sinhf16(half %a) nounwind {
-; CHECK-LABEL: use_sinhf16:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq __extendhfsf2 at PLT
-; CHECK-NEXT: callq sinhf at PLT
-; CHECK-NEXT: callq __truncsfhf2 at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_sinhf16:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl %eax, (%esp)
+; X86-NEXT: calll __gnu_h2f_ieee
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll sinhf
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll __gnu_f2h_ieee
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_sinhf16:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq __extendhfsf2 at PLT
+; X64-NEXT: callq sinhf at PLT
+; X64-NEXT: callq __truncsfhf2 at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call half @llvm.sinh.f16(half %a)
ret half %x
}
define float @use_sinhf32(float %a) nounwind {
-; CHECK-LABEL: use_sinhf32:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp sinhf at PLT # TAILCALL
+; SDAG-X86-LABEL: use_sinhf32:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: flds {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstps (%esp)
+; SDAG-X86-NEXT: calll sinhf
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_sinhf32:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp sinhf at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_sinhf32:
+; 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 sinhf
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_sinhf32:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq sinhf
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call float @llvm.sinh.f32(float %a)
ret float %x
}
define double @use_sinhf64(double %a) nounwind {
-; CHECK-LABEL: use_sinhf64:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp sinh at PLT # TAILCALL
+; SDAG-X86-LABEL: use_sinhf64:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: fldl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstpl (%esp)
+; SDAG-X86-NEXT: calll sinh
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_sinhf64:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp sinh at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_sinhf64:
+; 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 sinh
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_sinhf64:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq sinh
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call double @llvm.sinh.f64(double %a)
ret double %x
}
define x86_fp80 @use_sinhf80(x86_fp80 %a) nounwind {
-; CHECK-LABEL: use_sinhf80:
-; CHECK: # %bb.0:
-; CHECK-NEXT: subq $24, %rsp
-; CHECK-NEXT: fldt 32(%rsp)
-; CHECK-NEXT: fstpt (%rsp)
-; CHECK-NEXT: callq sinhl at PLT
-; CHECK-NEXT: addq $24, %rsp
-; CHECK-NEXT: retq
+; X86-LABEL: use_sinhf80:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: fldt {{[0-9]+}}(%esp)
+; X86-NEXT: fstpt (%esp)
+; X86-NEXT: calll sinhl
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_sinhf80:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: subq $24, %rsp
+; SDAG-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fstpt (%rsp)
+; SDAG-X64-NEXT: callq sinhl at PLT
+; SDAG-X64-NEXT: addq $24, %rsp
+; SDAG-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: use_sinhf80:
+; 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 sinhl
+; GISEL-X64-NEXT: addq $24, %rsp
+; GISEL-X64-NEXT: retq
%x = call x86_fp80 @llvm.sinh.f80(x86_fp80 %a)
ret x86_fp80 %x
}
define fp128 @use_sinhfp128(fp128 %a) nounwind {
-; CHECK-LABEL: use_sinhfp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp sinhf128 at PLT # TAILCALL
+; X86-LABEL: use_sinhfp128:
+; X86: # %bb.0:
+; X86-NEXT: pushl %edi
+; X86-NEXT: pushl %esi
+; X86-NEXT: subl $20, %esp
+; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl %eax
+; X86-NEXT: calll sinhl
+; X86-NEXT: addl $28, %esp
+; X86-NEXT: movl (%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
+; X86-NEXT: movl %edi, 12(%esi)
+; X86-NEXT: movl %edx, 8(%esi)
+; X86-NEXT: movl %ecx, 4(%esi)
+; X86-NEXT: movl %eax, (%esi)
+; X86-NEXT: movl %esi, %eax
+; X86-NEXT: addl $20, %esp
+; X86-NEXT: popl %esi
+; X86-NEXT: popl %edi
+; X86-NEXT: retl $4
+;
+; SDAG-X64-LABEL: use_sinhfp128:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp sinhf128 at PLT # TAILCALL
+;
+; GISEL-X64-LABEL: use_sinhfp128:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq sinhf128
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call fp128 @llvm.sinh.f128(fp128 %a)
ret fp128 %x
}
define ppc_fp128 @use_sinhppc_fp128(ppc_fp128 %a) nounwind {
-; CHECK-LABEL: use_sinhppc_fp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq sinhl at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_sinhppc_fp128:
+; X86: # %bb.0:
+; X86-NEXT: subl $92, %esp
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl (%esp)
+; X86-NEXT: calll sinhl
+; X86-NEXT: fxch %st(1)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: addl $92, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_sinhppc_fp128:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq sinhl at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call ppc_fp128 @llvm.sinh.ppcf128(ppc_fp128 %a)
ret ppc_fp128 %x
}
diff --git a/llvm/test/CodeGen/X86/llvm.tan.ll b/llvm/test/CodeGen/X86/llvm.tan.ll
index 24b30038687f2..85670f714cb9b 100644
--- a/llvm/test/CodeGen/X86/llvm.tan.ll
+++ b/llvm/test/CodeGen/X86/llvm.tan.ll
@@ -1,63 +1,225 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
-; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+; We don't handle fp16 and fp128 types for "-global-isel" so we allow fallbacks in these cases to SDAG.
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X86,SDAG-X86
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X64,SDAG-X64
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86,GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X64,GISEL-X64
define half @use_tanf16(half %a) nounwind {
-; CHECK-LABEL: use_tanf16:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq __extendhfsf2 at PLT
-; CHECK-NEXT: callq tanf at PLT
-; CHECK-NEXT: callq __truncsfhf2 at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_tanf16:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl %eax, (%esp)
+; X86-NEXT: calll __gnu_h2f_ieee
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll tanf
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll __gnu_f2h_ieee
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_tanf16:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq __extendhfsf2 at PLT
+; X64-NEXT: callq tanf at PLT
+; X64-NEXT: callq __truncsfhf2 at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call half @llvm.tan.f16(half %a)
ret half %x
}
define float @use_tanf32(float %a) nounwind {
-; CHECK-LABEL: use_tanf32:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp tanf at PLT # TAILCALL
+; SDAG-X86-LABEL: use_tanf32:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: flds {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstps (%esp)
+; SDAG-X86-NEXT: calll tanf
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_tanf32:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp tanf at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_tanf32:
+; 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 tanf
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_tanf32:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq tanf
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call float @llvm.tan.f32(float %a)
ret float %x
}
define double @use_tanf64(double %a) nounwind {
-; CHECK-LABEL: use_tanf64:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp tan at PLT # TAILCALL
+; SDAG-X86-LABEL: use_tanf64:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: fldl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstpl (%esp)
+; SDAG-X86-NEXT: calll tan
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_tanf64:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp tan at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_tanf64:
+; 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 tan
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_tanf64:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq tan
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call double @llvm.tan.f64(double %a)
ret double %x
}
define x86_fp80 @use_tanf80(x86_fp80 %a) nounwind {
-; CHECK-LABEL: use_tanf80:
-; CHECK: # %bb.0:
-; CHECK-NEXT: subq $24, %rsp
-; CHECK-NEXT: fldt 32(%rsp)
-; CHECK-NEXT: fstpt (%rsp)
-; CHECK-NEXT: callq tanl at PLT
-; CHECK-NEXT: addq $24, %rsp
-; CHECK-NEXT: retq
+; X86-LABEL: use_tanf80:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: fldt {{[0-9]+}}(%esp)
+; X86-NEXT: fstpt (%esp)
+; X86-NEXT: calll tanl
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_tanf80:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: subq $24, %rsp
+; SDAG-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fstpt (%rsp)
+; SDAG-X64-NEXT: callq tanl at PLT
+; SDAG-X64-NEXT: addq $24, %rsp
+; SDAG-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: use_tanf80:
+; 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 tanl
+; GISEL-X64-NEXT: addq $24, %rsp
+; GISEL-X64-NEXT: retq
%x = call x86_fp80 @llvm.tan.f80(x86_fp80 %a)
ret x86_fp80 %x
}
define fp128 @use_tanfp128(fp128 %a) nounwind {
-; CHECK-LABEL: use_tanfp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp tanf128 at PLT # TAILCALL
+; X86-LABEL: use_tanfp128:
+; X86: # %bb.0:
+; X86-NEXT: pushl %edi
+; X86-NEXT: pushl %esi
+; X86-NEXT: subl $20, %esp
+; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl %eax
+; X86-NEXT: calll tanl
+; X86-NEXT: addl $28, %esp
+; X86-NEXT: movl (%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
+; X86-NEXT: movl %edi, 12(%esi)
+; X86-NEXT: movl %edx, 8(%esi)
+; X86-NEXT: movl %ecx, 4(%esi)
+; X86-NEXT: movl %eax, (%esi)
+; X86-NEXT: movl %esi, %eax
+; X86-NEXT: addl $20, %esp
+; X86-NEXT: popl %esi
+; X86-NEXT: popl %edi
+; X86-NEXT: retl $4
+;
+; SDAG-X64-LABEL: use_tanfp128:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp tanf128 at PLT # TAILCALL
+;
+; GISEL-X64-LABEL: use_tanfp128:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq tanf128
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call fp128 @llvm.tan.f128(fp128 %a)
ret fp128 %x
}
define ppc_fp128 @use_tanppc_fp128(ppc_fp128 %a) nounwind {
-; CHECK-LABEL: use_tanppc_fp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq tanl at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_tanppc_fp128:
+; X86: # %bb.0:
+; X86-NEXT: subl $92, %esp
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl (%esp)
+; X86-NEXT: calll tanl
+; X86-NEXT: fxch %st(1)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: addl $92, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_tanppc_fp128:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq tanl at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call ppc_fp128 @llvm.tan.ppcf128(ppc_fp128 %a)
ret ppc_fp128 %x
}
diff --git a/llvm/test/CodeGen/X86/llvm.tanh.ll b/llvm/test/CodeGen/X86/llvm.tanh.ll
index 7119c401c8040..4a5b84cf14fc3 100644
--- a/llvm/test/CodeGen/X86/llvm.tanh.ll
+++ b/llvm/test/CodeGen/X86/llvm.tanh.ll
@@ -1,63 +1,225 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
-; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+; We don't handle fp16 and fp128 types for "-global-isel" so we allow fallbacks in these cases to SDAG.
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X86,SDAG-X86
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 | FileCheck %s --check-prefixes=X64,SDAG-X64
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86,GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X64,GISEL-X64
define half @use_tanhf16(half %a) nounwind {
-; CHECK-LABEL: use_tanhf16:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq __extendhfsf2 at PLT
-; CHECK-NEXT: callq tanhf at PLT
-; CHECK-NEXT: callq __truncsfhf2 at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_tanhf16:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl %eax, (%esp)
+; X86-NEXT: calll __gnu_h2f_ieee
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll tanhf
+; X86-NEXT: fstps (%esp)
+; X86-NEXT: calll __gnu_f2h_ieee
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_tanhf16:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq __extendhfsf2 at PLT
+; X64-NEXT: callq tanhf at PLT
+; X64-NEXT: callq __truncsfhf2 at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call half @llvm.tanh.f16(half %a)
ret half %x
}
define float @use_tanhf32(float %a) nounwind {
-; CHECK-LABEL: use_tanhf32:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp tanhf at PLT # TAILCALL
+; SDAG-X86-LABEL: use_tanhf32:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: flds {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstps (%esp)
+; SDAG-X86-NEXT: calll tanhf
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_tanhf32:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp tanhf at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_tanhf32:
+; 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 tanhf
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_tanhf32:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq tanhf
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call float @llvm.tanh.f32(float %a)
ret float %x
}
define double @use_tanhf64(double %a) nounwind {
-; CHECK-LABEL: use_tanhf64:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp tanh at PLT # TAILCALL
+; SDAG-X86-LABEL: use_tanhf64:
+; SDAG-X86: # %bb.0:
+; SDAG-X86-NEXT: subl $12, %esp
+; SDAG-X86-NEXT: fldl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT: fstpl (%esp)
+; SDAG-X86-NEXT: calll tanh
+; SDAG-X86-NEXT: addl $12, %esp
+; SDAG-X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_tanhf64:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp tanh at PLT # TAILCALL
+;
+; GISEL-X86-LABEL: use_tanhf64:
+; 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 tanh
+; GISEL-X86-NEXT: addl $12, %esp
+; GISEL-X86-NEXT: retl
+;
+; GISEL-X64-LABEL: use_tanhf64:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq tanh
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call double @llvm.tanh.f64(double %a)
ret double %x
}
define x86_fp80 @use_tanhf80(x86_fp80 %a) nounwind {
-; CHECK-LABEL: use_tanhf80:
-; CHECK: # %bb.0:
-; CHECK-NEXT: subq $24, %rsp
-; CHECK-NEXT: fldt 32(%rsp)
-; CHECK-NEXT: fstpt (%rsp)
-; CHECK-NEXT: callq tanhl at PLT
-; CHECK-NEXT: addq $24, %rsp
-; CHECK-NEXT: retq
+; X86-LABEL: use_tanhf80:
+; X86: # %bb.0:
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: fldt {{[0-9]+}}(%esp)
+; X86-NEXT: fstpt (%esp)
+; X86-NEXT: calll tanhl
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: retl
+;
+; SDAG-X64-LABEL: use_tanhf80:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: subq $24, %rsp
+; SDAG-X64-NEXT: fldt {{[0-9]+}}(%rsp)
+; SDAG-X64-NEXT: fstpt (%rsp)
+; SDAG-X64-NEXT: callq tanhl at PLT
+; SDAG-X64-NEXT: addq $24, %rsp
+; SDAG-X64-NEXT: retq
+;
+; GISEL-X64-LABEL: use_tanhf80:
+; 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 tanhl
+; GISEL-X64-NEXT: addq $24, %rsp
+; GISEL-X64-NEXT: retq
%x = call x86_fp80 @llvm.tanh.f80(x86_fp80 %a)
ret x86_fp80 %x
}
define fp128 @use_tanhfp128(fp128 %a) nounwind {
-; CHECK-LABEL: use_tanhfp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: jmp tanhf128 at PLT # TAILCALL
+; X86-LABEL: use_tanhfp128:
+; X86: # %bb.0:
+; X86-NEXT: pushl %edi
+; X86-NEXT: pushl %esi
+; X86-NEXT: subl $20, %esp
+; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl {{[0-9]+}}(%esp)
+; X86-NEXT: pushl %eax
+; X86-NEXT: calll tanhl
+; X86-NEXT: addl $28, %esp
+; X86-NEXT: movl (%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
+; X86-NEXT: movl %edi, 12(%esi)
+; X86-NEXT: movl %edx, 8(%esi)
+; X86-NEXT: movl %ecx, 4(%esi)
+; X86-NEXT: movl %eax, (%esi)
+; X86-NEXT: movl %esi, %eax
+; X86-NEXT: addl $20, %esp
+; X86-NEXT: popl %esi
+; X86-NEXT: popl %edi
+; X86-NEXT: retl $4
+;
+; SDAG-X64-LABEL: use_tanhfp128:
+; SDAG-X64: # %bb.0:
+; SDAG-X64-NEXT: jmp tanhf128 at PLT # TAILCALL
+;
+; GISEL-X64-LABEL: use_tanhfp128:
+; GISEL-X64: # %bb.0:
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: callq tanhf128
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: retq
%x = call fp128 @llvm.tanh.f128(fp128 %a)
ret fp128 %x
}
define ppc_fp128 @use_tanhppc_fp128(ppc_fp128 %a) nounwind {
-; CHECK-LABEL: use_tanhppc_fp128:
-; CHECK: # %bb.0:
-; CHECK-NEXT: pushq %rax
-; CHECK-NEXT: callq tanhl at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
+; X86-LABEL: use_tanhppc_fp128:
+; X86: # %bb.0:
+; X86-NEXT: subl $92, %esp
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl (%esp)
+; X86-NEXT: calll tanhl
+; X86-NEXT: fxch %st(1)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: fstpl {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
+; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: addl $92, %esp
+; X86-NEXT: retl
+;
+; X64-LABEL: use_tanhppc_fp128:
+; X64: # %bb.0:
+; X64-NEXT: pushq %rax
+; X64-NEXT: callq tanhl at PLT
+; X64-NEXT: popq %rax
+; X64-NEXT: retq
%x = call ppc_fp128 @llvm.tanh.ppcf128(ppc_fp128 %a)
ret ppc_fp128 %x
}
More information about the llvm-commits
mailing list