[llvm] [RISCV][TTI] Adjust VLS shuffle costing to account for sub-mask reuse (PR #129793)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 19 13:32:37 PDT 2025


================
@@ -430,11 +430,14 @@ costShuffleViaVRegSplitting(RISCVTTIImpl &TTI, MVT LegalVT,
   copy(Mask, NormalizedMask.begin());
   InstructionCost Cost = 0;
   int NumShuffles = 0;
+  DenseSet<std::pair<ArrayRef<int>, unsigned>> ReusedSingleSrcShuffles;
   processShuffleMasks(
       NormalizedMask, NumOfSrcRegs, NumOfDestRegs, NumOfDestRegs, []() {},
       [&](ArrayRef<int> RegMask, unsigned SrcReg, unsigned DestReg) {
         if (ShuffleVectorInst::isIdentityMask(RegMask, RegMask.size()))
           return;
+        if (!ReusedSingleSrcShuffles.insert(std::make_pair(RegMask, SrcReg)).second)
----------------
alexey-bataev wrote:

`!ReusedSingleSrcShuffles.try_emplace(RegMask, SrcReg).second`

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


More information about the llvm-commits mailing list