]> granicus.if.org Git - llvm/commitdiff
[CodeGen][X86] Fuchsia supports sincos* libcalls and sin+cos->sincos optimization
authorPetr Hosek <phosek@chromium.org>
Sun, 23 Jul 2017 22:30:00 +0000 (22:30 +0000)
committerPetr Hosek <phosek@chromium.org>
Sun, 23 Jul 2017 22:30:00 +0000 (22:30 +0000)
Patch by Roland McGrath

Differential Revision: https://reviews.llvm.org/D35748

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308854 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TargetLoweringBase.cpp
lib/Target/X86/X86Subtarget.cpp
test/CodeGen/X86/sincos-opt.ll

index 8be9e192e5b28c066aca24884619711eacc1331d..40a126a89fc5f1fa6dd2d9cc733ea4e25c1d08d5 100644 (file)
@@ -97,7 +97,7 @@ static void InitLibcallNames(const char **Names, const Triple &TT) {
     Names[RTLIB::FPROUND_F32_F16] = "__gnu_f2h_ieee";
   }
 
-  if (TT.isGNUEnvironment()) {
+  if (TT.isGNUEnvironment() || TT.isOSFuchsia()) {
     Names[RTLIB::SINCOS_F32] = "sincosf";
     Names[RTLIB::SINCOS_F64] = "sincos";
     Names[RTLIB::SINCOS_F80] = "sincosl";
index 24845beac22d1eb8be4262296fb5fb1628f4c521..ea921cfac23b68522b9ffb6069df0879655ea128 100644 (file)
@@ -189,9 +189,12 @@ const char *X86Subtarget::getBZeroEntry() const {
 }
 
 bool X86Subtarget::hasSinCos() const {
-  return getTargetTriple().isMacOSX() &&
-    !getTargetTriple().isMacOSXVersionLT(10, 9) &&
-    is64Bit();
+  if (getTargetTriple().isMacOSX()) {
+    return !getTargetTriple().isMacOSXVersionLT(10, 9) && is64Bit();
+  } else if (getTargetTriple().isOSFuchsia()) {
+    return true;
+  }
+  return false;
 }
 
 /// Return true if the subtarget allows calls to immediate address.
index e2fd63eab30fcaf382e6dc8f789c6b96bc2f80b2..dfe6e784e38306e15a938f38e4920be5141bd231 100644 (file)
@@ -3,6 +3,8 @@
 ; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu -mcpu=core2 | FileCheck %s --check-prefix=GNU_SINCOS
 ; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu -mcpu=core2 -enable-unsafe-fp-math | FileCheck %s --check-prefix=GNU_SINCOS_FASTMATH
 ; 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
 
 ; Combine sin / cos into a single call unless they may write errno (as
 ; captured by readnone attrbiute, controlled by clang -fmath-errno