[llvm] [VPlan] Speed up VPSlotTracker by using ModuleSlotTracker (PR #139881)

Igor Kirillov via llvm-commits llvm-commits at lists.llvm.org
Fri May 16 05:04:03 PDT 2025


================
@@ -382,14 +383,25 @@ class VPSlotTracker {
   /// Number to assign to the next VPValue without underlying value.
   unsigned NextSlot = 0;
 
+  /// Cache slot indexes to avoid recomputing them on each printAsOperand call.
+  std::unique_ptr<ModuleSlotTracker> MST;
+
   void assignName(const VPValue *V);
   void assignNames(const VPlan &Plan);
   void assignNames(const VPBasicBlock *VPBB);
 
 public:
   VPSlotTracker(const VPlan *Plan = nullptr) {
-    if (Plan)
+    if (Plan) {
+      // This check is required to support unit tests with incomplete IR.
+      if (Function *F =
+              Plan->getScalarHeader()->getIRBasicBlock()->getParent()) {
+        Module *M = F->getParent();
+        MST = std::make_unique<ModuleSlotTracker>(M);
----------------
igogo-x86 wrote:

Okay, made it genuinely lazy

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


More information about the llvm-commits mailing list