[llvm] BasicTTI: Cleanup multiple result intrinsic handling (PR #165970)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 1 22:00:55 PDT 2025
================
@@ -311,12 +310,45 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
!isVectorizedStructTy(cast<StructType>(RetTy)))
return std::nullopt;
+ Type *Ty = getContainedTypes(RetTy).front();
+ EVT VT = getTLI()->getValueType(DL, Ty);
+
+ EVT ScalarVT = VT.getScalarType();
+ RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
+
+ switch (ICA.getID()) {
+ case Intrinsic::modf:
+ LC = RTLIB::getMODF(ScalarVT);
+ break;
+ case Intrinsic::sincospi:
+ LC = RTLIB::getSINCOSPI(ScalarVT);
+ break;
+ case Intrinsic::sincos:
+ // TODO: Account for sincos_stret not always using a memory operation for
+ // the out argument
+ LC = RTLIB::getSINCOS_STRET(ScalarVT);
+
+ if (getTLI()->getLibcallImpl(LC) == RTLIB::Unsupported)
+ LC = RTLIB::getSINCOS(ScalarVT);
+
+ break;
+ default:
+ return std::nullopt;
+ }
+
// Find associated libcall.
- const char *LCName = getTLI()->getLibcallName(LC);
- if (!LCName)
+ RTLIB::LibcallImpl LibcallImpl = getTLI()->getLibcallImpl(LC);
+ if (LibcallImpl == RTLIB::Unsupported)
return std::nullopt;
+ StringRef LCName =
+ RTLIB::RuntimeLibcallsInfo::getLibcallImplName(LibcallImpl);
+
// Search for a corresponding vector variant.
+ //
+ // FIXME: CodeGen use RuntimeLibcallsInfo, not TargetLibraryInfo and has no
+ // path to using the vector libcalls. So this guess at how legalization will
+ // work is just wrong.
----------------
arsenm wrote:
Hmm, I found it. This is basically a special case system and no other intrinsic is handled this way. We should have entries in RuntimeLibcalls like we do for all the scalar types, rather than having a side mechanism (e.g., as it is now the vector libcalls will not be retained in full LTO which will later be necessary)
https://github.com/llvm/llvm-project/pull/165970
More information about the llvm-commits
mailing list