@@ -2515,56 +2515,14 @@ static bool canFoldStoreIntoLibCallOutputPointers(StoreSDNode *StoreNode,
25152515
25162516bool SelectionDAG::expandMultipleResultFPLibCall(
25172517 RTLIB::Libcall LC, SDNode *Node, SmallVectorImpl<SDValue> &Results,
2518- EVT CallVT, std::optional<unsigned> CallRetResNo) {
2518+ std::optional<unsigned> CallRetResNo) {
25192519 if (LC == RTLIB::UNKNOWN_LIBCALL)
25202520 return false;
25212521
2522- EVT VT = Node->getValueType(0);
2523-
2524- RTLIB::LibcallImpl Impl = TLI->getLibcallImpl(LC);
2525- if (Impl == RTLIB::Unsupported)
2526- return false;
2527-
2528- StringRef LCName = TLI->getLibcallImplName(Impl);
2529-
2530- // FIXME: This should not use TargetLibraryInfo. There should be
2531- // RTLIB::Libcall entries for each used vector type, and directly matched.
2532- auto getVecDesc = [&]() -> VecDesc const * {
2533- for (bool Masked : {false, true}) {
2534- if (VecDesc const *VD = getLibInfo().getVectorMappingInfo(
2535- LCName, VT.getVectorElementCount(), Masked)) {
2536- return VD;
2537- }
2538- }
2539- return nullptr;
2540- };
2541-
2542- // For vector types, we must find a vector mapping for the libcall.
2543- VecDesc const *VD = nullptr;
2544- if (VT.isVector() && !CallVT.isVector() && !(VD = getVecDesc()))
2522+ RTLIB::LibcallImpl LibcallImpl = TLI->getLibcallImpl(LC);
2523+ if (LibcallImpl == RTLIB::Unsupported)
25452524 return false;
25462525
2547- bool IsMasked = (VD && VD->isMasked()) ||
2548- RTLIB::RuntimeLibcallsInfo::hasVectorMaskArgument(Impl);
2549-
2550- // This wrapper function exists because getVectorMappingInfo works in terms of
2551- // function names instead of RTLIB enums.
2552-
2553- // FIXME: If we used a vector mapping, this assumes the calling convention of
2554- // the vector function is the same as the scalar.
2555-
2556- StringRef Name = VD ? VD->getVectorFnName() : LCName;
2557-
2558- return expandMultipleResultFPLibCall(Name,
2559- TLI->getLibcallImplCallingConv(Impl),
2560- Node, Results, CallRetResNo, IsMasked);
2561- }
2562-
2563- // FIXME: This belongs in TargetLowering
2564- bool SelectionDAG::expandMultipleResultFPLibCall(
2565- StringRef Name, CallingConv::ID CC, SDNode *Node,
2566- SmallVectorImpl<SDValue> &Results, std::optional<unsigned> CallRetResNo,
2567- bool IsMasked) {
25682526 LLVMContext &Ctx = *getContext();
25692527 EVT VT = Node->getValueType(0);
25702528 unsigned NumResults = Node->getNumValues();
@@ -2625,8 +2583,8 @@ bool SelectionDAG::expandMultipleResultFPLibCall(
26252583
26262584 SDLoc DL(Node);
26272585
2628- // Pass the vector mask ( if required).
2629- if (IsMasked) {
2586+ if (RTLIB::RuntimeLibcallsInfo::hasVectorMaskArgument(LibcallImpl)) {
2587+ // Pass the vector mask (if required).
26302588 EVT MaskVT = TLI->getSetCCResultType(getDataLayout(), Ctx, VT);
26312589 SDValue Mask = getBoolConstant(true, DL, MaskVT, VT);
26322590 Args.emplace_back(Mask, MaskVT.getTypeForEVT(Ctx));
@@ -2637,10 +2595,12 @@ bool SelectionDAG::expandMultipleResultFPLibCall(
26372595 : Type::getVoidTy(Ctx);
26382596 SDValue InChain = StoresInChain ? StoresInChain : getEntryNode();
26392597 SDValue Callee =
2640- getExternalSymbol(Name.data(), TLI->getPointerTy(getDataLayout()));
2598+ getExternalSymbol(TLI->getLibcallImplName(LibcallImpl).data(),
2599+ TLI->getPointerTy(getDataLayout()));
26412600 TargetLowering::CallLoweringInfo CLI(*this);
2642- CLI.setDebugLoc(DL).setChain(InChain).setLibCallee(CC, RetType, Callee,
2643- std::move(Args));
2601+ CLI.setDebugLoc(DL).setChain(InChain).setLibCallee(
2602+ TLI->getLibcallImplCallingConv(LibcallImpl), RetType, Callee,
2603+ std::move(Args));
26442604
26452605 auto [Call, CallChain] = TLI->LowerCallTo(CLI);
26462606
0 commit comments