Skip to content

Commit 8eb4ada

Browse files
authored
[RISCV][TTI] Discount slide cost if ri.vinsert/ri.vextract are available (#142036)
If we have the ri.vinsert/vextract instructions from xrivosvisni, we can do an element insert or extract without needing a vslide or a vector temporary register. Adjust the TTI cost to reflect this.
1 parent 443cdd0 commit 8eb4ada

File tree

3 files changed

+598
-1
lines changed

3 files changed

+598
-1
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2297,9 +2297,12 @@ InstructionCost RISCVTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
22972297
Index = Index % M1Max;
22982298
}
22992299

2300-
// We could extract/insert the first element without vslidedown/vslideup.
23012300
if (Index == 0)
2301+
// We can extract/insert the first element without vslidedown/vslideup.
23022302
SlideCost = 0;
2303+
else if (ST->hasVendorXRivosVisni() && isUInt<5>(Index) &&
2304+
Val->getScalarType()->isIntegerTy())
2305+
SlideCost = 0; // With ri.vinsert/ri.vextract there is no slide needed
23032306
else if (Opcode == Instruction::InsertElement)
23042307
SlideCost = 1; // With a constant index, we do not need to use addi.
23052308
}

0 commit comments

Comments
 (0)