DAG: Use sincos vector libcalls through RuntimeLibcalls (#166984)

Copy new process from sincospi.
This commit is contained in:
Matt Arsenault authored and GitHub committed 2025-11-11 10:51:23 -08:00
1 parent 843f1224cf
commit de68181d7f
3 files changed
+28 -11

No files matched your search

+6 -1
View File
@@ -334,7 +334,12 @@ private:
break;
case Intrinsic::sincos:
LC = RTLIB::getSINCOS(ScalarVT);
LC = RTLIB::getSINCOS(VT);
if (LC == RTLIB::UNKNOWN_LIBCALL)
LC = RTLIB::getSINCOS(ScalarVT);
else if (VT.isVector())
IsVectorCall = true;
break;
default:
return std::nullopt;
@@ -1268,10 +1268,12 @@ void VectorLegalizer::Expand(SDNode *Node, SmallVectorImpl<SDValue> &Results) {
return;
break;
case ISD::FSINCOS:
case ISD::FSINCOSPI: {
EVT VT = Node->getValueType(0);
RTLIB::Libcall LC = RTLIB::getSINCOSPI(VT);
RTLIB::Libcall LC = Node->getOpcode() == ISD::FSINCOS
? RTLIB::getSINCOS(VT)
: RTLIB::getSINCOSPI(VT);
if (LC != RTLIB::UNKNOWN_LIBCALL &&
DAG.expandMultipleResultFPLibCall(LC, Node, Results, VT))
return;
@@ -1280,14 +1282,6 @@ void VectorLegalizer::Expand(SDNode *Node, SmallVectorImpl<SDValue> &Results) {
// scalarizing.
break;
}
case ISD::FSINCOS: {
// FIXME: Try to directly match vector case like fsincospi
EVT VT = Node->getValueType(0).getVectorElementType();
RTLIB::Libcall LC = RTLIB::getSINCOS(VT);
if (DAG.expandMultipleResultFPLibCall(LC, Node, Results, VT))
return;
break;
}
case ISD::FMODF: {
EVT VT = Node->getValueType(0).getVectorElementType();
RTLIB::Libcall LC = RTLIB::getMODF(VT);
+18
View File
@@ -424,6 +424,24 @@ RTLIB::Libcall RTLIB::getCOS(EVT RetVT) {
}
RTLIB::Libcall RTLIB::getSINCOS(EVT RetVT) {
// TODO: Tablegen should generate this function
if (RetVT.isVector()) {
if (!RetVT.isSimple())
return RTLIB::UNKNOWN_LIBCALL;
switch (RetVT.getSimpleVT().SimpleTy) {
case MVT::v4f32:
return RTLIB::SINCOS_V4F32;
case MVT::v2f64:
return RTLIB::SINCOS_V2F64;
case MVT::nxv4f32:
return RTLIB::SINCOS_NXV4F32;
case MVT::nxv2f64:
return RTLIB::SINCOS_NXV2F64;
default:
return RTLIB::UNKNOWN_LIBCALL;
}
}
return getFPLibCall(RetVT, SINCOS_F32, SINCOS_F64, SINCOS_F80, SINCOS_F128,
SINCOS_PPCF128);
}