[llvm] [RISCV] Fix missing scaling by LMUL in cost model (PR #73342)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 18 17:14:40 PST 2024


================
@@ -1163,7 +1165,7 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
     auto LT = getTypeLegalizationCost(RetTy);
     if (const auto *Entry = CostTableLookup(VectorIntrinsicCostTable,
                                             ICA.getID(), LT.second))
-      return LT.first * Entry->Cost;
+      return LT.first * TLI->getLMULCost(LT.second) * Entry->Cost;
----------------
preames wrote:

Thinking about this further.  The actual values in the table aren't LMUL sensitive.  It does depend on element type (i.e. SEW).  I went ahead and modified the table (8bf624af4776cdaad82c0fc4da9e9b0f14e9ea10) to make that explicit.  

When doing that, I realized I'd been completely wrong here the whole time.  The original table was keyed by vector type, and that's fixed with respect to LMUL.  What got me confused is that changing VLEN (a related but distinct notion), does change the fixed mappings.  I got myself confused, sorry for the confusion!

Given that, LGTM to the change as whole.

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


More information about the llvm-commits mailing list