Skip to content

Commit 50afafb

Browse files
authored
[RISCV][TTI] Adjust constant materialization cost for (z/s)ext from i1 (#110282)
When we're lowering to a split sequence, we only need one materialization of the zero constant. Our codegen looks something like this: vmv.v.i v24, 0 vmerge.vim v8, v24, -1, v0 vmv1r.v v0, v16 vmerge.vim v16, v24, -1, v0 Note: Doing this specific case since it was pointed out in #110164 (comment), but it's worth noting that we have the same basic problem (over costing split operations with split invariant terms) at multiple places through this file.
1 parent cd5f5b7 commit 50afafb

File tree

3 files changed

+165
-165
lines changed

3 files changed

+165
-165
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,10 +1182,10 @@ InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
11821182
// We do not use vsext/vzext to extend from mask vector.
11831183
// Instead we use the following instructions to extend from mask vector:
11841184
// vmv.v.i v8, 0
1185-
// vmerge.vim v8, v8, -1, v0
1186-
return DstLT.first *
1187-
getRISCVInstructionCost({RISCV::VMV_V_I, RISCV::VMERGE_VIM},
1188-
DstLT.second, CostKind) +
1185+
// vmerge.vim v8, v8, -1, v0 (repeated per split)
1186+
return getRISCVInstructionCost(RISCV::VMV_V_I, DstLT.second, CostKind) +
1187+
DstLT.first * getRISCVInstructionCost(RISCV::VMERGE_VIM,
1188+
DstLT.second, CostKind) +
11891189
DstLT.first - 1;
11901190
}
11911191
break;

0 commit comments

Comments
 (0)