Skip to content

RuntimeLibcalls: Cleanup sincos predicate functions #143081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Jun 6, 2025

The darwinHasSinCos wasn't actually used for sincos, only the stret
variant. Rename this to reflect that, and introduce a new one for
enabling sincos.

Copy link
Contributor Author

arsenm commented Jun 6, 2025

@llvmbot
Copy link
Member

llvmbot commented Jun 6, 2025

@llvm/pr-subscribers-llvm-ir

Author: Matt Arsenault (arsenm)

Changes

The darwinHasSinCos wasn't actually used for sincos, only the stret
variant. Rename this to reflect that, and introduce a new one for
enabling sincos.


Full diff: https://github.com/llvm/llvm-project/pull/143081.diff

2 Files Affected:

  • (modified) llvm/include/llvm/IR/RuntimeLibcalls.h (+7-1)
  • (modified) llvm/lib/IR/RuntimeLibcalls.cpp (+2-3)
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h
index 6cc65fabfcc99..d2704d5aa2616 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -103,7 +103,7 @@ struct RuntimeLibcallsInfo {
   // opcode.
   CmpInst::Predicate SoftFloatCompareLibcallPredicates[RTLIB::UNKNOWN_LIBCALL];
 
-  static bool darwinHasSinCos(const Triple &TT) {
+  static bool darwinHasSinCosStret(const Triple &TT) {
     assert(TT.isOSDarwin() && "should be called with darwin triple");
     // Don't bother with 32 bit x86.
     if (TT.getArch() == Triple::x86)
@@ -118,6 +118,12 @@ struct RuntimeLibcallsInfo {
     return true;
   }
 
+  /// Return true if the target has sincosf/sincos/sincosl functions
+  static bool hasSinCos(const Triple &TT) {
+    return TT.isGNUEnvironment() || TT.isOSFuchsia() ||
+           (TT.isAndroid() && !TT.isAndroidVersionLT(9));
+  }
+
   void initSoftFloatCmpLibcallPredicates();
 
   /// Set default libcall names. If a target wants to opt-out of a libcall it
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index 91f303c9e3d3c..a6fda0cfeadd2 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -170,7 +170,7 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
       break;
     }
 
-    if (darwinHasSinCos(TT)) {
+    if (darwinHasSinCosStret(TT)) {
       setLibcallName(RTLIB::SINCOS_STRET_F32, "__sincosf_stret");
       setLibcallName(RTLIB::SINCOS_STRET_F64, "__sincos_stret");
       if (TT.isWatchABI()) {
@@ -214,8 +214,7 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
     setLibcallName(RTLIB::EXP10_F64, "__exp10");
   }
 
-  if (TT.isGNUEnvironment() || TT.isOSFuchsia() ||
-      (TT.isAndroid() && !TT.isAndroidVersionLT(9))) {
+  if (hasSinCos(TT)) {
     setLibcallName(RTLIB::SINCOS_F32, "sincosf");
     setLibcallName(RTLIB::SINCOS_F64, "sincos");
     setLibcallName(RTLIB::SINCOS_F80, "sincosl");

@arsenm arsenm force-pushed the users/arsenm/dag/move-runtime-libcalls-predicate-setting branch from 25d7dd2 to b7f272a Compare June 6, 2025 07:18
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/cleanup-has-sincos-predicates branch from ee79ca1 to 65cb831 Compare June 6, 2025 07:18
@arsenm arsenm force-pushed the users/arsenm/dag/move-runtime-libcalls-predicate-setting branch from b7f272a to e245a54 Compare June 6, 2025 14:09
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/cleanup-has-sincos-predicates branch 2 times, most recently from 6e17ae5 to 30983d1 Compare June 9, 2025 02:35
@arsenm arsenm force-pushed the users/arsenm/dag/move-runtime-libcalls-predicate-setting branch from e245a54 to dff6aca Compare June 9, 2025 02:35
Copy link
Collaborator

@efriedma-quic efriedma-quic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/cleanup-has-sincos-predicates branch from 30983d1 to fbfc09b Compare June 11, 2025 00:33
@arsenm arsenm force-pushed the users/arsenm/dag/move-runtime-libcalls-predicate-setting branch from dff6aca to 581f775 Compare June 11, 2025 00:33
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/cleanup-has-sincos-predicates branch from fbfc09b to fc327d3 Compare June 12, 2025 03:11
@arsenm arsenm force-pushed the users/arsenm/dag/move-runtime-libcalls-predicate-setting branch from 581f775 to 219358e Compare June 12, 2025 03:11
Copy link
Contributor Author

arsenm commented Jun 17, 2025

Merge activity

  • Jun 17, 12:37 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 17, 12:43 AM UTC: Graphite rebased this pull request as part of a merge.
  • Jun 17, 12:46 AM UTC: @arsenm merged this pull request with Graphite.

@arsenm arsenm force-pushed the users/arsenm/dag/move-runtime-libcalls-predicate-setting branch from 219358e to 15a5c10 Compare June 17, 2025 00:39
Base automatically changed from users/arsenm/dag/move-runtime-libcalls-predicate-setting to main June 17, 2025 00:42
The darwinHasSinCos wasn't actually used for sincos, only the stret
variant. Rename this to reflect that, and introduce a new one for
enabling sincos.
@arsenm arsenm force-pushed the users/arsenm/runtime-libcalls/cleanup-has-sincos-predicates branch from fc327d3 to c85d667 Compare June 17, 2025 00:43
@arsenm arsenm merged commit 1ffd9f5 into main Jun 17, 2025
5 of 7 checks passed
@arsenm arsenm deleted the users/arsenm/runtime-libcalls/cleanup-has-sincos-predicates branch June 17, 2025 00:46
ajaden-codes pushed a commit to Jaddyen/llvm-project that referenced this pull request Jun 17, 2025
The darwinHasSinCos wasn't actually used for sincos, only the stret
variant. Rename this to reflect that, and introduce a new one for
enabling sincos.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants