[llvm-branch-commits] [llvm] DAG: Fall back to separate sin and cos when softening sincos (PR #147468)
Matt Arsenault via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jul 8 01:03:36 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);
+ }
+
+ SetSoftenedFloat(SDValue(N, 0), SoftSin);
+ SetSoftenedFloat(SDValue(N, 1), SoftCos);
+ return SDValue();
}
SDValue DAGTypeLegalizer::SoftenFloatRes_FMODF(SDNode *N) {
- return SoftenFloatRes_UnaryWithTwoFPResults(
- N, RTLIB::getMODF(N->getValueType(0)), /*CallRetResNo=*/0);
+ EVT VT = N->getValueType(0);
+ if (SoftenFloatRes_UnaryWithTwoFPResults(N, RTLIB::getMODF(VT),
+ /*CallRetResNo=*/0))
+ return SDValue();
+
+ EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
+ DAG.getContext()->emitError("do not know how to soften fmodf");
+ SDValue Poison = DAG.getPOISON(NVT);
+ SetSoftenedFloat(SDValue(N, 0), Poison);
+ SetSoftenedFloat(SDValue(N, 1), Poison);
----------------
arsenm wrote:
It doesn't assert when they aren't set later. You still need to produce something in the error case if you aren't fatal erroring
https://github.com/llvm/llvm-project/pull/147468
More information about the llvm-branch-commits
mailing list