[llvm] [RISCV][CostModel] Add getRISCVInstructionCost() to TTI for Cost… (PR #73651)
Shih-Po Hung via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 26 00:50:29 PST 2023
================
@@ -34,6 +34,63 @@ static cl::opt<unsigned> SLPMaxVF(
"exclusively by SLP vectorizer."),
cl::Hidden);
+InstructionCost
+RISCVTTIImpl::getRISCVInstructionCost(ArrayRef<unsigned> OpCodes, MVT VT,
+ TTI::TargetCostKind CostKind) {
+ size_t NumInstr = OpCodes.size();
+ if (CostKind == TTI::TCK_CodeSize)
+ return NumInstr;
+ InstructionCost LMULCost = TLI->getLMULCost(VT);
+ if ((CostKind != TTI::TCK_RecipThroughput) && (CostKind != TTI::TCK_Latency))
+ return LMULCost * NumInstr;
+ InstructionCost Cost = 0;
+ for (auto Op : OpCodes) {
+ switch (Op) {
+ case RISCV::VRGATHER_VI:
+ Cost += TLI->getVRGatherVICost(VT);
+ break;
+ case RISCV::VRGATHER_VV:
+ Cost += TLI->getVRGatherVVCost(VT);
+ break;
+ case RISCV::VSLIDEUP_VI:
+ case RISCV::VSLIDEDOWN_VI:
+ case RISCV::VSLIDEUP_VX:
----------------
arcbbb wrote:
Yes, I think it would be good to expand getVSlideCost to getVSlideVXCost and getVSlideVICost. Fixed.
https://github.com/llvm/llvm-project/pull/73651
More information about the llvm-commits
mailing list