[llvm] [SLP] More accurately cost RISCV scalar splats (PR #213104)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 03:40:37 PDT 2026
================
@@ -2621,6 +2627,15 @@ InstructionCost RISCVTTIImpl::getVectorInstrCost(
return BaseT::getVectorInstrCost(Opcode, Val, CostKind, Index, Op0, Op1,
VIC);
+ // Scalar splat operand can be folded for vector ops that support splatting
+ // the scalar operand, so the explicit insertelement is free in this context.
+ if (Opcode == Instruction::InsertElement &&
+ VIC == TTI::VectorInstrContext::SplatOpFolded &&
+ ST->sinkSplatOperands()) {
+ assert(Index == 0 && "SplatOpFolded sequence must insert into lane 0");
----------------
alexey-bataev wrote:
```suggestion
ST->sinkSplatOperands() && Index == 0 ) {
```
https://github.com/llvm/llvm-project/pull/213104
More information about the llvm-commits
mailing list