[PATCH] D35748: [CodeGen][X86] Fuchsia supports sincos* libcalls and sin+cos->sincos optimization

Roland McGrath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 21 16:56:27 PDT 2017


mcgrathr created this revision.

Repository:
  rL LLVM

https://reviews.llvm.org/D35748

Files:
  lib/CodeGen/TargetLoweringBase.cpp
  lib/Target/X86/X86Subtarget.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
@@ -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
Index: lib/Target/X86/X86Subtarget.cpp
===================================================================
--- lib/Target/X86/X86Subtarget.cpp
+++ lib/Target/X86/X86Subtarget.cpp
@@ -189,9 +189,12 @@
 }
 
 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: lib/CodeGen/TargetLoweringBase.cpp
===================================================================
--- lib/CodeGen/TargetLoweringBase.cpp
+++ lib/CodeGen/TargetLoweringBase.cpp
@@ -97,7 +97,7 @@
     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";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35748.107753.patch
Type: text/x-patch
Size: 2025 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170721/af335cdb/attachment.bin>


More information about the llvm-commits mailing list