diff options
| author | Robert Lougher <rob.lougher@gmail.com> | 2019-09-02 16:53:32 +0000 |
|---|---|---|
| committer | Robert Lougher <rob.lougher@gmail.com> | 2019-09-02 16:53:32 +0000 |
| commit | 13190c422530593f3d0a37eccd33608b5c7cc7eb (patch) | |
| tree | 9b4cd5441c31d338339d6b01a5ed3bd5025197a1 /llvm | |
| parent | b21e24571146bb043ce5374928e81cad48392b13 (diff) | |
| download | bcm5719-llvm-13190c422530593f3d0a37eccd33608b5c7cc7eb.tar.gz bcm5719-llvm-13190c422530593f3d0a37eccd33608b5c7cc7eb.zip | |
[TargetLowering][PS4] Add sincos(f) lib functions when target is PS4
PS4 supports sincosf and sincos. Adding the library functions enables
the sin(f)+cos(f) -> sincos(f) optimization.
Differential Revision: https://reviews.llvm.org/D67009
llvm-svn: 370675
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/CodeGen/TargetLoweringBase.cpp | 5 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/sincos-opt.ll | 27 |
2 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index dcedca7e9fb..e9a7d4b5252 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -197,6 +197,11 @@ void TargetLoweringBase::InitLibcalls(const Triple &TT) { setLibcallName(RTLIB::SINCOS_PPCF128, "sincosl"); } + if (TT.isPS4CPU()) { + setLibcallName(RTLIB::SINCOS_F32, "sincosf"); + setLibcallName(RTLIB::SINCOS_F64, "sincos"); + } + if (TT.isOSOpenBSD()) { setLibcallName(RTLIB::STACKPROTECTOR_CHECK_FAIL, nullptr); } diff --git a/llvm/test/CodeGen/X86/sincos-opt.ll b/llvm/test/CodeGen/X86/sincos-opt.ll index b6445086342..821f2b14487 100644 --- a/llvm/test/CodeGen/X86/sincos-opt.ll +++ b/llvm/test/CodeGen/X86/sincos-opt.ll @@ -5,6 +5,7 @@ ; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 -mcpu=core2 -enable-unsafe-fp-math | FileCheck %s --check-prefix=GNU_SINCOS_FASTMATH ; RUN: llc < %s -mtriple=x86_64-fuchsia -mcpu=core2 | FileCheck %s --check-prefix=GNU_SINCOS ; RUN: llc < %s -mtriple=x86_64-fuchsia -mcpu=core2 -enable-unsafe-fp-math | FileCheck %s --check-prefix=GNU_SINCOS_FASTMATH +; RUN: llc < %s -mtriple=x86_64-scei-ps4 -mcpu=btver2 | FileCheck %s --check-prefix=PS4_SINCOS ; Combine sin / cos into a single call unless they may write errno (as ; captured by readnone attrbiute, controlled by clang -fmath-errno @@ -32,6 +33,11 @@ entry: ; OSX_NOOPT-LABEL: test1: ; OSX_NOOPT: callq _sinf ; OSX_NOOPT: callq _cosf + +; PS4_SINCOS-LABEL: test1: +; PS4_SINCOS: callq sincosf +; PS4_SINCOS: vmovss 4(%rsp), %xmm0 +; PS4_SINCOS: vaddss (%rsp), %xmm0, %xmm0 %call = tail call float @sinf(float %x) readnone %call1 = tail call float @cosf(float %x) readnone %add = fadd float %call, %call1 @@ -55,6 +61,10 @@ entry: ; OSX_NOOPT-LABEL: test1_errno: ; OSX_NOOPT: callq _sinf ; OSX_NOOPT: callq _cosf + +; PS4_SINCOS-LABEL: test1_errno: +; PS4_SINCOS: callq sinf +; PS4_SINCOS: callq cosf %call = tail call float @sinf(float %x) %call1 = tail call float @cosf(float %x) %add = fadd float %call, %call1 @@ -80,6 +90,11 @@ entry: ; OSX_NOOPT-LABEL: test2: ; OSX_NOOPT: callq _sin ; OSX_NOOPT: callq _cos + +; PS4_SINCOS-LABEL: test2: +; PS4_SINCOS: callq sincos +; PS4_SINCOS: vmovsd 16(%rsp), %xmm0 +; PS4_SINCOS: vaddsd 8(%rsp), %xmm0, %xmm0 %call = tail call double @sin(double %x) readnone %call1 = tail call double @cos(double %x) readnone %add = fadd double %call, %call1 @@ -103,6 +118,10 @@ entry: ; OSX_NOOPT-LABEL: test2_errno: ; OSX_NOOPT: callq _sin ; OSX_NOOPT: callq _cos + +; PS4_SINCOS-LABEL: test2_errno: +; PS4_SINCOS: callq sin +; PS4_SINCOS: callq cos %call = tail call double @sin(double %x) %call1 = tail call double @cos(double %x) %add = fadd double %call, %call1 @@ -122,6 +141,10 @@ entry: ; GNU_SINCOS_FASTMATH: fldt 16(%{{[re]}}sp) ; GNU_SINCOS_FASTMATH: fldt 32(%{{[re]}}sp) ; GNU_SINCOS_FASTMATH: faddp %st, %st(1) + +; PS4_SINCOS-LABEL: test3: +; PS4_SINCOS: callq sinl +; PS4_SINCOS: callq cosl %call = tail call x86_fp80 @sinl(x86_fp80 %x) readnone %call1 = tail call x86_fp80 @cosl(x86_fp80 %x) readnone %add = fadd x86_fp80 %call, %call1 @@ -137,6 +160,10 @@ entry: ; GNU_SINCOS_FASTMATH-LABEL: test3_errno: ; GNU_SINCOS_FASTMATH: callq sinl ; GNU_SINCOS_FASTMATH: callq cosl + +; PS4_SINCOS-LABEL: test3_errno: +; PS4_SINCOS: callq sinl +; PS4_SINCOS: callq cosl %call = tail call x86_fp80 @sinl(x86_fp80 %x) %call1 = tail call x86_fp80 @cosl(x86_fp80 %x) %add = fadd x86_fp80 %call, %call1 |

