mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-25 20:59:51 +00:00
Reuse the logic in getEdgeProbability within getHotSucc in order to
correctly handle blocks whose successor weights sum to more than UINT32_MAX. This is slightly less efficient, but the entire thing is already linear on the number of successors. Calling it within any hot routine is a mistake, and indeed no one is calling it. It also simplifies the code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144527 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2770c14185
commit
c4e1562825
@ -59,6 +59,7 @@ public:
|
||||
bool isEdgeHot(MachineBasicBlock *Src, MachineBasicBlock *Dst) const;
|
||||
|
||||
// Return a hot successor for the block BB or null if there isn't one.
|
||||
// NB: This routine's complexity is linear on the number of successors.
|
||||
MachineBasicBlock *getHotSucc(MachineBasicBlock *MBB) const;
|
||||
|
||||
// Return a probability as a fraction between 0 (0% probability) and
|
||||
|
@ -76,26 +76,18 @@ bool MachineBranchProbabilityInfo::isEdgeHot(MachineBasicBlock *Src,
|
||||
|
||||
MachineBasicBlock *
|
||||
MachineBranchProbabilityInfo::getHotSucc(MachineBasicBlock *MBB) const {
|
||||
uint32_t Sum = 0;
|
||||
uint32_t MaxWeight = 0;
|
||||
MachineBasicBlock *MaxSucc = 0;
|
||||
|
||||
for (MachineBasicBlock::const_succ_iterator I = MBB->succ_begin(),
|
||||
E = MBB->succ_end(); I != E; ++I) {
|
||||
MachineBasicBlock *Succ = *I;
|
||||
uint32_t Weight = getEdgeWeight(MBB, Succ);
|
||||
uint32_t PrevSum = Sum;
|
||||
|
||||
Sum += Weight;
|
||||
assert(Sum > PrevSum); (void) PrevSum;
|
||||
|
||||
uint32_t Weight = getEdgeWeight(MBB, *I);
|
||||
if (Weight > MaxWeight) {
|
||||
MaxWeight = Weight;
|
||||
MaxSucc = Succ;
|
||||
MaxSucc = *I;
|
||||
}
|
||||
}
|
||||
|
||||
if (BranchProbability(MaxWeight, Sum) >= BranchProbability(4, 5))
|
||||
if (getEdgeProbability(MBB, MaxSucc) >= BranchProbability(4, 5))
|
||||
return MaxSucc;
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user