[llvm] [RISCV][TTI] Improve SiFive7 reduction cost (PR #90951)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue May 21 22:24:06 PDT 2024
================
@@ -76,37 +113,63 @@ RISCVTTIImpl::getRISCVInstructionCost(ArrayRef<unsigned> OpCodes, MVT VT,
case RISCV::VFREDUSUM_VS: {
unsigned VL = VT.getVectorMinNumElements();
if (!VT.isFixedLengthVector())
- VL *= *getVScaleForTuning();
- Cost += Log2_32_Ceil(VL);
+ VL *= VScale;
+ // For the cases with small VL, we use a lookup table for accurate
+ // cost estimation.
+ unsigned LookUpSiFive7ReduceLatency[] = {0, 20, 27, 32, 34,
+ 38, 40, 41, 42};
+ if (VL <= 32) {
+ Cost += LookUpSiFive7ReduceLatency[(VL + 3) >> 2];
----------------
topperc wrote:
Use divideCeil instead of `(VL + 3) >> 2`
https://github.com/llvm/llvm-project/pull/90951
More information about the llvm-commits
mailing list