[llvm-branch-commits] [llvm] DAG: Fall back to separate sin and cos when softening sincos (PR #147468)
Benjamin Maxwell via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jul 8 01:00:08 PDT 2025
================
@@ -849,17 +849,46 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_UnaryWithTwoFPResults(
SetSoftenedFloat(SDValue(N, ResNum), CreateStackLoad(SlackSlot));
}
- return SDValue();
+ return true;
}
SDValue DAGTypeLegalizer::SoftenFloatRes_FSINCOS(SDNode *N) {
- return SoftenFloatRes_UnaryWithTwoFPResults(
- N, RTLIB::getSINCOS(N->getValueType(0)));
+ EVT VT = N->getValueType(0);
+ if (SoftenFloatRes_UnaryWithTwoFPResults(N, RTLIB::getSINCOS(VT)))
+ return SDValue();
+
+ // Fall back on softening the separate sin and cos calls if available.
+ RTLIB::Libcall SinLC = RTLIB::getSIN(VT);
+ RTLIB::Libcall CosLC = RTLIB::getCOS(VT);
+
+ SDValue SoftSin, SoftCos;
+ if (!TLI.getLibcallName(SinLC) || !TLI.getLibcallName(CosLC)) {
+ DAG.getContext()->emitError("do not know how to soften fsincos");
+
+ EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
+ SoftSin = SoftCos = DAG.getPOISON(NVT);
+ } else {
+ SoftSin = SoftenFloatRes_Unary(N, SinLC);
+ SoftCos = SoftenFloatRes_Unary(N, CosLC);
----------------
MacDue wrote:
This seems off as `SoftenFloatRes_Unary` expects a single-result node, but I think here it's fine (looks like it wouldn't work for strict nodes though).
https://github.com/llvm/llvm-project/pull/147468
More information about the llvm-branch-commits
mailing list