summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-04-25 04:38:27 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-04-25 04:38:27 +0000
commit58aa6072058b4dd086c503362c3fa467568c4cfe (patch)
tree0c0c4a9cc8991f2c35b9f3198cbf76484068f8d7 /lib
parentf47649f7f96bbbf3b79b428b885114777a8175aa (diff)
downloadllvm-58aa6072058b4dd086c503362c3fa467568c4cfe.tar.gz
llvm-58aa6072058b4dd086c503362c3fa467568c4cfe.tar.bz2
llvm-58aa6072058b4dd086c503362c3fa467568c4cfe.tar.xz
blockfreq: Scale LoopData::Scale on the way down
Rather than scaling loop headers and then scaling all the loop members by the header frequency, scale `LoopData::Scale` itself, and scale the loop members by it. It's much more obvious what's going on this way, and doesn't cost any extra multiplies. <rdar://problem/14292693> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207189 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/BlockFrequencyInfoImpl.cpp35
1 files changed, 12 insertions, 23 deletions
diff --git a/lib/Analysis/BlockFrequencyInfoImpl.cpp b/lib/Analysis/BlockFrequencyInfoImpl.cpp
index 6327959580..6349b78074 100644
--- a/lib/Analysis/BlockFrequencyInfoImpl.cpp
+++ b/lib/Analysis/BlockFrequencyInfoImpl.cpp
@@ -805,40 +805,29 @@ static void convertFloatingToInteger(BlockFrequencyInfoImplBase &BFI,
}
}
-static void scaleBlockData(BlockFrequencyInfoImplBase &BFI,
- const BlockNode &Node, const LoopData &Loop) {
- Float F = Loop.Mass.toFloat() * Loop.Scale;
-
- Float &Current = BFI.Freqs[Node.Index].Floating;
- Float Updated = Current * F;
-
- DEBUG(dbgs() << " - " << BFI.getBlockName(Node) << ": " << Current << " => "
- << Updated << "\n");
-
- Current = Updated;
-}
-
/// \brief Unwrap a loop package.
///
/// Visits all the members of a loop, adjusting their BlockData according to
/// the loop's pseudo-node.
static void unwrapLoop(BlockFrequencyInfoImplBase &BFI, LoopData &Loop) {
- BlockNode Head = Loop.getHeader();
- DEBUG(dbgs() << "unwrap-loop-package: " << BFI.getBlockName(Head)
+ DEBUG(dbgs() << "unwrap-loop-package: " << BFI.getBlockName(Loop.getHeader())
<< ": mass = " << Loop.Mass << ", scale = " << Loop.Scale
<< "\n");
- scaleBlockData(BFI, Head, Loop);
+ Loop.Scale *= Loop.Mass.toFloat();
+ Loop.IsPackaged = false;
+ DEBUG(dbgs() << " => combined-scale = " << Loop.Scale << "\n");
// Propagate the head scale through the loop. Since members are visited in
// RPO, the head scale will be updated by the loop scale first, and then the
// final head scale will be used for updated the rest of the members.
- for (const BlockNode &M : Loop.members()) {
- const FrequencyData &HeadData = BFI.Freqs[Head.Index];
- FrequencyData &Freqs = BFI.Freqs[M.Index];
- Float NewFreq = Freqs.Floating * HeadData.Floating;
- DEBUG(dbgs() << " - " << BFI.getBlockName(M) << ": " << Freqs.Floating
- << " => " << NewFreq << "\n");
- Freqs.Floating = NewFreq;
+ for (const BlockNode &N : Loop.Nodes) {
+ const auto &Working = BFI.Working[N.Index];
+ Float &F = Working.isAPackage() ? BFI.getLoopPackage(N).Scale
+ : BFI.Freqs[N.Index].Floating;
+ Float New = Loop.Scale * F;
+ DEBUG(dbgs() << " - " << BFI.getBlockName(N) << ": " << F << " => " << New
+ << "\n");
+ F = New;
}
}