[llvm] [VectorCombine] Add a cost model for shuffleToIdentity. (PR #93937)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Fri May 31 03:16:30 PDT 2024


================
@@ -1878,6 +1893,31 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
   if (NumVisited <= 1)
     return false;
 
+  LLVM_DEBUG(dbgs() << "Found a set of shuffles that can be removed:\n");
+  InstructionCost OldShuffleCost;
+  for (auto *I : VisitedShuffles) {
+    InstructionCost C = TTI.getInstructionCost(I, TTI::TCK_RecipThroughput);
+    LLVM_DEBUG(dbgs() << C << *I << "\n");
+    OldShuffleCost += C;
+  }
+  LLVM_DEBUG(dbgs() << "  total cost " << OldShuffleCost << "\n");
+  SmallVector<int, 16> ExtractMask(Ty->getNumElements());
+  std::iota(ExtractMask.begin(), ExtractMask.end(), 0);
----------------
artagnon wrote:

Doesn't the declaration automatically fill the `SmallVector` to zeros?

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


More information about the llvm-commits mailing list