@@ -2572,11 +2572,8 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
25722572 }
25732573
25742574 // Combine sin / cos into _sincos_stret if it is available.
2575- if (getLibcallName(RTLIB::SINCOS_STRET_F32) != nullptr &&
2576- getLibcallName(RTLIB::SINCOS_STRET_F64) != nullptr) {
2577- setOperationAction(ISD::FSINCOS, MVT::f64, Custom);
2578- setOperationAction(ISD::FSINCOS, MVT::f32, Custom);
2579- }
2575+ setOperationAction(ISD::FSINCOS, MVT::f64, Custom);
2576+ setOperationAction(ISD::FSINCOS, MVT::f32, Custom);
25802577
25812578 if (Subtarget.isTargetWin64()) {
25822579 setOperationAction(ISD::SDIV, MVT::i128, Custom);
@@ -33067,26 +33064,30 @@ static SDValue LowerADDSUBO_CARRY(SDValue Op, SelectionDAG &DAG) {
3306733064
3306833065static SDValue LowerFSINCOS(SDValue Op, const X86Subtarget &Subtarget,
3306933066 SelectionDAG &DAG) {
33067+ const TargetLowering &TLI = DAG.getTargetLoweringInfo();
33068+ SDValue Arg = Op.getOperand(0);
33069+ EVT ArgVT = Arg.getValueType();
33070+ bool isF64 = ArgVT == MVT::f64;
33071+
33072+ RTLIB::Libcall LC = isF64 ? RTLIB::SINCOS_STRET_F64 : RTLIB::SINCOS_STRET_F32;
33073+ const char *LibcallName = TLI.getLibcallName(LC);
33074+ if (!LibcallName)
33075+ return SDValue();
33076+
3307033077 assert(Subtarget.isTargetDarwin() && Subtarget.is64Bit());
3307133078
3307233079 // For MacOSX, we want to call an alternative entry point: __sincos_stret,
3307333080 // which returns the values as { float, float } (in XMM0) or
3307433081 // { double, double } (which is returned in XMM0, XMM1).
3307533082 SDLoc dl(Op);
33076- SDValue Arg = Op.getOperand(0);
33077- EVT ArgVT = Arg.getValueType();
3307833083 Type *ArgTy = ArgVT.getTypeForEVT(*DAG.getContext());
3307933084
3308033085 TargetLowering::ArgListTy Args;
3308133086 Args.emplace_back(Arg, ArgTy);
3308233087
33083- bool isF64 = ArgVT == MVT::f64;
3308433088 // Only optimize x86_64 for now. i386 is a bit messy. For f32,
3308533089 // the small struct {f32, f32} is returned in (eax, edx). For f64,
3308633090 // the results are returned via SRet in memory.
33087- const TargetLowering &TLI = DAG.getTargetLoweringInfo();
33088- RTLIB::Libcall LC = isF64 ? RTLIB::SINCOS_STRET_F64 : RTLIB::SINCOS_STRET_F32;
33089- const char *LibcallName = TLI.getLibcallName(LC);
3309033091 SDValue Callee =
3309133092 DAG.getExternalSymbol(LibcallName, TLI.getPointerTy(DAG.getDataLayout()));
3309233093
0 commit comments