]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/commitdiff
blockfreq: Separate unwrapLoops() from finalizeMetrics()
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 25 Apr 2014 04:38:17 +0000 (04:38 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 25 Apr 2014 04:38:17 +0000 (04:38 +0000)
<rdar://problem/14292693>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207185 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/BlockFrequencyInfoImpl.h
lib/Analysis/BlockFrequencyInfoImpl.cpp

index e6f08bb04e410fd82561ebf96106e45344193657..81456636308ab783ad46f96585c7f3c0cb5a2126 100644 (file)
@@ -1141,10 +1141,13 @@ public:
   /// \brief Package up a loop.
   void packageLoop(LoopData &Loop);
 
+  /// \brief Unwrap loops.
+  void unwrapLoops();
+
   /// \brief Finalize frequency metrics.
   ///
-  /// Unwraps loop packages, calculates final frequencies, and cleans up
-  /// no-longer-needed data structures.
+  /// Calculates final frequencies and cleans up no-longer-needed data
+  /// structures.
   void finalizeMetrics();
 
   /// \brief Clear all memory.
@@ -1434,6 +1437,7 @@ void BlockFrequencyInfoImpl<BT>::doFunction(const FunctionT *F,
   // the full function.
   computeMassInLoops();
   computeMassInFunction();
+  unwrapLoops();
   finalizeMetrics();
 }
 
index d58a7435a352bff2bb8336d80006e0a5dbd54d6a..6b65bf6478ed3de8ef199e261af6fd191a4e269c 100644 (file)
@@ -846,20 +846,24 @@ static void unwrapLoopPackage(BlockFrequencyInfoImplBase &BFI,
   }
 }
 
-void BlockFrequencyInfoImplBase::finalizeMetrics() {
+void BlockFrequencyInfoImplBase::unwrapLoops() {
   // Set initial frequencies from loop-local masses.
   for (size_t Index = 0; Index < Working.size(); ++Index)
     Freqs[Index].Floating = Working[Index].Mass.toFloat();
 
+  for (size_t Index = 0; Index < Working.size(); ++Index) {
+    if (Working[Index].isLoopHeader())
+      unwrapLoopPackage(*this, BlockNode(Index));
+  }
+}
+
+void BlockFrequencyInfoImplBase::finalizeMetrics() {
   // Unwrap loop packages in reverse post-order, tracking min and max
   // frequencies.
   auto Min = Float::getLargest();
   auto Max = Float::getZero();
   for (size_t Index = 0; Index < Working.size(); ++Index) {
-    if (Working[Index].isLoopHeader())
-      unwrapLoopPackage(*this, BlockNode(Index));
-
-    // Update max scale.
+    // Update min/max scale.
     Min = std::min(Min, Freqs[Index].Floating);
     Max = std::max(Max, Freqs[Index].Floating);
   }