[llvm] [ConstantFolding] Fold intrinsics of scalable vectors with splatted operands (PR #141845)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 28 14:49:21 PDT 2025
================
@@ -3780,7 +3780,35 @@ static Constant *ConstantFoldScalableVectorCall(
default:
break;
}
- return nullptr;
+
+ // If trivially vectorizable, try folding it via the scalar call if all
+ // operands are splats.
+
+ // TODO: ConstantFoldFixedVectorCall should probably check this too?
+ if (!isTriviallyVectorizable(IntrinsicID))
+ return nullptr;
+
+ SmallVector<Constant *, 4> SplatOps;
+ for (auto [I, Op] : enumerate(Operands)) {
+ if (isVectorIntrinsicWithScalarOpAtArg(IntrinsicID, I, /*TTI=*/nullptr)) {
+ SplatOps.push_back(Op);
+ continue;
+ }
+ // TODO: Should getSplatValue return a poison scalar for a poison vector?
----------------
nikic wrote:
It should...
https://github.com/llvm/llvm-project/pull/141845
More information about the llvm-commits
mailing list