[llvm] [RISCV][TTI] Extract subvector at index zero is free (PR #81751)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 10:09:17 PST 2024


================
@@ -432,12 +432,20 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
     // must be implemented here.
     break;
   case TTI::SK_ExtractSubvector:
+    // Extract at zero is always a subregister extract
+    if (Index == 0)
+      return TTI::TCC_Free;
+
     // Example sequence:
     // vsetivli     zero, 4, e8, mf2, tu, ma (ignored)
     // vslidedown.vi  v8, v9, 2
     return LT.first *
            getRISCVInstructionCost(RISCV::VSLIDEDOWN_VI, LT.second, CostKind);
   case TTI::SK_InsertSubvector:
+    // Insert at zero is always a subregister insert
+    if (Index == 0)
+      return TTI::TCC_Free;
----------------
preames wrote:

I reframed this review to be specifically about the extract case.  Once this lands, I'll take another attempt at the insert case.  That ones slightly annoying since I don't see an easy way in the current API to figure out what the passthru is.  I may have to resort to inspecting the operands of the instruction directly.  

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


More information about the llvm-commits mailing list