summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h11
-rw-r--r--llvm/include/llvm/CodeGen/MachineBranchProbabilityInfo.h10
-rw-r--r--llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp13
-rw-r--r--llvm/test/Analysis/BlockFrequencyInfo/bad_input.ll4
4 files changed, 10 insertions, 28 deletions
diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
index d7379b8fbea..387e9a887d9 100644
--- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
+++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
@@ -1173,6 +1173,13 @@ void BlockFrequencyInfoImpl<BT>::computeIrreducibleMass(
updateLoopWithIrreducible(*OuterLoop);
}
+namespace {
+// A helper function that converts a branch probability into weight.
+inline uint32_t getWeightFromBranchProb(const BranchProbability Prob) {
+ return Prob.getNumerator();
+}
+} // namespace
+
template <class BT>
bool
BlockFrequencyInfoImpl<BT>::propagateMassToSuccessors(LoopData *OuterLoop,
@@ -1189,10 +1196,8 @@ BlockFrequencyInfoImpl<BT>::propagateMassToSuccessors(LoopData *OuterLoop,
const BlockT *BB = getBlock(Node);
for (auto SI = Successor::child_begin(BB), SE = Successor::child_end(BB);
SI != SE; ++SI)
- // Do not dereference SI, or getEdgeWeight() is linear in the number of
- // successors.
if (!addToDist(Dist, OuterLoop, Node, getNode(*SI),
- BPI->getEdgeWeight(BB, SI)))
+ getWeightFromBranchProb(BPI->getEdgeProbability(BB, SI))))
// Irreducible backedge.
return false;
}
diff --git a/llvm/include/llvm/CodeGen/MachineBranchProbabilityInfo.h b/llvm/include/llvm/CodeGen/MachineBranchProbabilityInfo.h
index 608e8d25787..81b0524cf0a 100644
--- a/llvm/include/llvm/CodeGen/MachineBranchProbabilityInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineBranchProbabilityInfo.h
@@ -45,16 +45,6 @@ public:
AU.setPreservesAll();
}
- // Return edge weight. If we don't have any informations about it - return
- // DEFAULT_WEIGHT.
- uint32_t getEdgeWeight(const MachineBasicBlock *Src,
- const MachineBasicBlock *Dst) const;
-
- // Same thing, but using a const_succ_iterator from Src. This is faster when
- // the iterator is already available.
- uint32_t getEdgeWeight(const MachineBasicBlock *Src,
- MachineBasicBlock::const_succ_iterator Dst) const;
-
// Return edge probability.
BranchProbability getEdgeProbability(const MachineBasicBlock *Src,
const MachineBasicBlock *Dst) const;
diff --git a/llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp b/llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp
index 5478dcba261..cf6d4018cb7 100644
--- a/llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp
+++ b/llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp
@@ -28,19 +28,6 @@ char MachineBranchProbabilityInfo::ID = 0;
void MachineBranchProbabilityInfo::anchor() { }
-uint32_t MachineBranchProbabilityInfo::getEdgeWeight(
- const MachineBasicBlock *Src,
- MachineBasicBlock::const_succ_iterator Dst) const {
- return Src->getSuccProbability(Dst).getNumerator();
-}
-
-uint32_t MachineBranchProbabilityInfo::getEdgeWeight(
- const MachineBasicBlock *Src, const MachineBasicBlock *Dst) const {
- // This is a linear search. Try to use the const_succ_iterator version when
- // possible.
- return getEdgeWeight(Src, std::find(Src->succ_begin(), Src->succ_end(), Dst));
-}
-
BranchProbability MachineBranchProbabilityInfo::getEdgeProbability(
const MachineBasicBlock *Src,
MachineBasicBlock::const_succ_iterator Dst) const {
diff --git a/llvm/test/Analysis/BlockFrequencyInfo/bad_input.ll b/llvm/test/Analysis/BlockFrequencyInfo/bad_input.ll
index e5b1f500e1e..20b87e6dfcb 100644
--- a/llvm/test/Analysis/BlockFrequencyInfo/bad_input.ll
+++ b/llvm/test/Analysis/BlockFrequencyInfo/bad_input.ll
@@ -9,8 +9,8 @@ define void @branch_weight_0(i32 %a) {
entry:
br label %for.body
-; Check that we get 1,4 instead of 0,3.
-; CHECK-NEXT: for.body: float = 4.0,
+; Check that we get 1 and a huge frequency instead of 0,3.
+; CHECK-NEXT: for.body: float = 2147483647.8,
for.body:
%i = phi i32 [ 0, %entry ], [ %inc, %for.body ]
call void @g(i32 %i)
OpenPOWER on IntegriCloud