[PATCH] D67009: [TargetLowering][PS4] Add sincos(f) lib functions when target is PS4
Robert Lougher via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 30 10:05:08 PDT 2019
rob.lougher created this revision.
rob.lougher added reviewers: probinson, RKSimon.
Herald added a project: LLVM.
PS4 supports sincosf and sincos. This patch enables the sin(f)+cos(f) -> sincos(f) optimization.
Repository:
rL LLVM
https://reviews.llvm.org/D67009
Files:
lib/CodeGen/TargetLoweringBase.cpp
test/CodeGen/X86/sincos-opt.ll
Index: test/CodeGen/X86/sincos-opt.ll
===================================================================
--- test/CodeGen/X86/sincos-opt.ll
+++ 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 @@
; 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 @@
; 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 @@
; 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 @@
; 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
Index: lib/CodeGen/TargetLoweringBase.cpp
===================================================================
--- lib/CodeGen/TargetLoweringBase.cpp
+++ lib/CodeGen/TargetLoweringBase.cpp
@@ -197,6 +197,11 @@
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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67009.218120.patch
Type: text/x-patch
Size: 2668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190830/2cfabfa8/attachment.bin>
More information about the llvm-commits
mailing list