[llvm] Fix scalar overload name constructed by ReplaceWithVeclib.cpp (PR #111095)
Tex Riddell via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 8 18:48:03 PDT 2024
================
@@ -100,27 +100,38 @@ static void replaceWithTLIFunction(IntrinsicInst *II, VFInfo &Info,
static bool replaceWithCallToVeclib(const TargetLibraryInfo &TLI,
IntrinsicInst *II) {
assert(II != nullptr && "Intrinsic cannot be null");
+ Intrinsic::ID IID = II->getIntrinsicID();
+ if (IID == Intrinsic::not_intrinsic)
+ return false;
// At the moment VFABI assumes the return type is always widened unless it is
// a void type.
auto *VTy = dyn_cast<VectorType>(II->getType());
ElementCount EC(VTy ? VTy->getElementCount() : ElementCount::getFixed(0));
+ Type *ScalarRetTy = II->getType()->getScalarType();
// Compute the argument types of the corresponding scalar call and check that
// all vector operands match the previously found EC.
SmallVector<Type *, 8> ScalarArgTypes;
- Intrinsic::ID IID = II->getIntrinsicID();
+
+ // OloadTys collects types used in scalar intrinsic overload name.
+ SmallVector<Type *, 3> OloadTys;
+ if (!ScalarRetTy->isVoidTy() &&
+ isVectorIntrinsicWithOverloadTypeAtArg(IID, -1))
+ OloadTys.push_back(ScalarRetTy);
+
for (auto Arg : enumerate(II->args())) {
auto *ArgTy = Arg.value()->getType();
- if (isVectorIntrinsicWithScalarOpAtArg(IID, Arg.index())) {
- ScalarArgTypes.push_back(ArgTy);
- } else if (auto *VectorArgTy = dyn_cast<VectorType>(ArgTy)) {
- ScalarArgTypes.push_back(VectorArgTy->getElementType());
+ auto *ScalarArgTy = ArgTy->getScalarType();
+ ScalarArgTypes.push_back(ScalarArgTy);
+ if (isVectorIntrinsicWithOverloadTypeAtArg(IID, Arg.index()))
+ OloadTys.push_back(ScalarArgTy);
+ if (auto *VectorArgTy = dyn_cast<VectorType>(ArgTy)) {
----------------
tex3d wrote:
I've updated the change to preserve vectors when considered `isVectorIntrinsicWithScalarOpAtArg` just to be on the safe side. The latest change returns the flow control in the loop to something closer to the original.
https://github.com/llvm/llvm-project/pull/111095
More information about the llvm-commits
mailing list