[llvm] [RISCV] Scale i64 insert/extract element cost on RV32 with LMUL (PR #214609)
Ryan Buchner via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 6 23:02:47 PDT 2026
================
@@ -2702,16 +2702,23 @@ InstructionCost RISCVTTIImpl::getVectorInstrCost(
// vmv.x.s a1, v8
// For insertelement, we need the following instructions:
- // vsetivli zero, 2, e32, m4, ta, mu (not count)
- // vmv.v.i v12, 0
- // vslide1up.vx v16, v12, a1
- // vslide1up.vx v12, v16, a0
+ // vsetivli zero, 2, e32, m4, ta, ma (don't count)
+ // vslide1down.vx v12, v8, a0
+ // vslide1down.vx v12, v12, a1
// addi a0, a2, 1
- // vsetvli zero, a0, e64, m4, tu, mu (not count)
+ // vsetvli zero, a0, e64, m4, tu, ma (don't count)
// vslideup.vx v8, v12, a2
// TODO: should we count these special vsetvlis?
- BaseCost = Opcode == Instruction::InsertElement ? 3 : 4;
+ BaseCost =
+ Opcode == Instruction::InsertElement
+ ? getRISCVInstructionCost({RISCV::VSLIDE1DOWN_VX,
+ RISCV::VSLIDE1DOWN_VX,
+ RISCV::VSLIDEUP_VX},
+ LT.second, CostKind)
+ : getRISCVInstructionCost({RISCV::VSLIDEDOWN_VX, RISCV::VMV_X_S,
+ RISCV::VSRL_VX, RISCV::VMV_S_X},
----------------
bababuck wrote:
```suggestion
: getRISCVInstructionCost({RISCV::VSLIDEDOWN_VX, RISCV::VMV_X_S,
RISCV::VSRL_VX, RISCV::VMV_X_S},
```
https://github.com/llvm/llvm-project/pull/214609
More information about the llvm-commits
mailing list