[llvm] [ARM][MVE] Add shuffle costs for LDn and STn instructions. (PR #145304)

John Brawn via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 23 05:56:30 PDT 2025


================
@@ -1336,6 +1336,37 @@ InstructionCost ARMTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
 
     if (!Mask.empty()) {
       std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(SrcTy);
+      // Check for LD2/LD4 instructions, which are represented in llvm IR as
+      // deinterleaving-shuffle(load). The shuffle cost could potentially be
+      // free, but we model it with a cost of LT.first so that LD2/LD4 have a
+      // higher cost than just the load.
+      if (Args.size() >= 1 && isa<LoadInst>(Args[0]) &&
+          (LT.second.getScalarSizeInBits() == 8 ||
+           LT.second.getScalarSizeInBits() == 16 ||
+           LT.second.getScalarSizeInBits() == 32) &&
+          LT.second.getSizeInBits() == 128 &&
+          (ShuffleVectorInst::isDeInterleaveMaskOfFactor(Mask, 2) ||
+           (TLI->getMaxSupportedInterleaveFactor() == 4 &&
+            ShuffleVectorInst::isDeInterleaveMaskOfFactor(Mask, 4))))
+        return ST->getMVEVectorCostFactor(TTI::TCK_RecipThroughput) *
----------------
john-brawn-arm wrote:

Should this be using the CostKind passed in as an argument? (Though I notice elsewhere in the function it's ignoring the argument and just using RecipThroughput)

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


More information about the llvm-commits mailing list