[llvm] r291002 - NewGVN: Track the maximum number of iterations GVN takes on any function, so we can pinpoint performance issues.

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 4 13:01:02 PST 2017


Author: dannyb
Date: Wed Jan  4 15:01:02 2017
New Revision: 291002

URL: http://llvm.org/viewvc/llvm-project?rev=291002&view=rev
Log:
NewGVN: Track the maximum number of iterations GVN takes on any function, so we can pinpoint performance issues.

Modified:
    llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp?rev=291002&r1=291001&r2=291002&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp Wed Jan  4 15:01:02 2017
@@ -79,6 +79,7 @@ STATISTIC(NumGVNInstrDeleted, "Number of
 STATISTIC(NumGVNBlocksDeleted, "Number of blocks deleted");
 STATISTIC(NumGVNOpsSimplified, "Number of Expressions simplified");
 STATISTIC(NumGVNPhisAllSame, "Number of PHIs whos arguments are all the same");
+STATISTIC(NumGVNMaxIterations, "Maximum Number of iterations it took to converge GVN");
 
 //===----------------------------------------------------------------------===//
 //                                GVN Pass
@@ -1528,9 +1529,11 @@ bool NewGVN::runGVN(Function &F, Dominat
 
   initializeCongruenceClasses(F);
 
+  unsigned int Iterations = 0;
   // We start out in the entry block.
   BasicBlock *LastBlock = &F.getEntryBlock();
   while (TouchedInstructions.any()) {
+    ++Iterations;
     // Walk through all the instructions in all the blocks in RPO.
     for (int InstrNum = TouchedInstructions.find_first(); InstrNum != -1;
          InstrNum = TouchedInstructions.find_next(InstrNum)) {
@@ -1577,7 +1580,7 @@ bool NewGVN::runGVN(Function &F, Dominat
       TouchedInstructions.reset(InstrNum);
     }
   }
-
+  NumGVNMaxIterations = std::max(NumGVNMaxIterations.getValue(), Iterations);
 #ifndef NDEBUG
   verifyMemoryCongruency();
 #endif




More information about the llvm-commits mailing list