[llvm] [RISCV][TTI] Improve SiFive7 reduction cost (PR #90951)

Shih-Po Hung via llvm-commits llvm-commits at lists.llvm.org
Wed May 22 00:55:23 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];
----------------
arcbbb wrote:

Fixed. Thanks!

https://github.com/llvm/llvm-project/pull/90951


More information about the llvm-commits mailing list