[llvm] [SLP] More accurately cost RISCV scalar splats (PR #213104)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 12 05:42:00 PDT 2026
================
@@ -666,6 +666,31 @@ TargetTransformInfo::getVectorInstrContextHint(const Instruction *I) {
return VectorInstrContext::None;
}
+TargetTransformInfo::VectorInstrContext
+TargetTransformInfo::getBuildVectorContextHint(
+ ArrayRef<int> Mask, ArrayRef<Value *> Scalars,
+ function_ref<bool(SmallVectorImpl<BuildVectorUseOp> &)> GatherUseOps)
+ const {
+ if (Scalars.empty() ||
+ !ShuffleVectorInst::isZeroEltSplatMask(Mask, Mask.size()))
+ return VectorInstrContext::None;
+
+ Value *SplatVal = Scalars.front();
+ if (isa<VectorType>(SplatVal->getType()) || isa<ExtractElementInst>(SplatVal))
+ return VectorInstrContext::None;
+
+ SmallVector<BuildVectorUseOp, 4> UserOps;
+ if (!GatherUseOps(UserOps) || UserOps.empty())
+ return VectorInstrContext::None;
+
+ if (all_of(UserOps, [this](const BuildVectorUseOp &UserOp) {
+ return canSplatOperand(UserOp.Opcode, UserOp.OperandIndex);
+ }))
+ return VectorInstrContext::SplatOpFolded;
----------------
alexey-bataev wrote:
Can it be hidden in the predicate function too? In this case canSplatOperand can be removed completely
https://github.com/llvm/llvm-project/pull/213104
More information about the llvm-commits
mailing list