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