[llvm] d40dcb0 - [LICM] Collect more scalar promotion stats (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 07:08:03 PDT 2022


Author: Nikita Popov
Date: 2022-09-30T16:07:52+02:00
New Revision: d40dcb0b8d106ac381e71b289f7fd6c3ae159201

URL: https://github.com/llvm/llvm-project/commit/d40dcb0b8d106ac381e71b289f7fd6c3ae159201
DIFF: https://github.com/llvm/llvm-project/commit/d40dcb0b8d106ac381e71b289f7fd6c3ae159201.diff

LOG: [LICM] Collect more scalar promotion stats (NFC)

Collect more statistics for scalar promotion. In particular,
keep track of how many promotion candidates there were, and
whether it is a load or a load/store promotion.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/LICM.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 7f3dc6c51a817..5aa63ce5d2165 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -99,7 +99,9 @@ STATISTIC(NumSunk, "Number of instructions sunk out of loop");
 STATISTIC(NumHoisted, "Number of instructions hoisted out of loop");
 STATISTIC(NumMovedLoads, "Number of load insts hoisted or sunk");
 STATISTIC(NumMovedCalls, "Number of call insts hoisted or sunk");
-STATISTIC(NumPromoted, "Number of memory locations promoted to registers");
+STATISTIC(NumPromotionCandidates, "Number of promotion candidates");
+STATISTIC(NumLoadPromoted, "Number of load-only promotions");
+STATISTIC(NumLoadStorePromoted, "Number of load and store promotions");
 
 /// Memory promotion is enabled by default.
 static cl::opt<bool>
@@ -1948,6 +1950,7 @@ bool llvm::promoteLoopAccessesToScalars(
     for (Value *Ptr : PointerMustAliases)
       dbgs() << "  " << *Ptr << "\n";
   });
+  ++NumPromotionCandidates;
 
   Value *SomePtr = *PointerMustAliases.begin();
   BasicBlock *Preheader = CurLoop->getLoopPreheader();
@@ -2158,19 +2161,21 @@ bool llvm::promoteLoopAccessesToScalars(
     return false;
 
   // Lets do the promotion!
-  if (StoreSafety == StoreSafe)
+  if (StoreSafety == StoreSafe) {
     LLVM_DEBUG(dbgs() << "LICM: Promoting load/store of the value: " << *SomePtr
                       << '\n');
-  else
+    ++NumLoadStorePromoted;
+  } else {
     LLVM_DEBUG(dbgs() << "LICM: Promoting load of the value: " << *SomePtr
                       << '\n');
+    ++NumLoadPromoted;
+  }
 
   ORE->emit([&]() {
     return OptimizationRemark(DEBUG_TYPE, "PromoteLoopAccessesToScalar",
                               LoopUses[0])
            << "Moving accesses to memory location out of the loop";
   });
-  ++NumPromoted;
 
   // Look at all the loop uses, and try to merge their locations.
   std::vector<const DILocation *> LoopUsesLocs;


        


More information about the llvm-commits mailing list