[llvm] [ConstantFolding] Fold intrinsics of scalable vectors with splatted operands (PR #141845)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Wed May 28 15:06:07 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?
----------------
lukel97 wrote:
Will do this in a follow up, seems to be NFC?
https://github.com/llvm/llvm-project/pull/141845
More information about the llvm-commits
mailing list