Skip to content

Commit

Permalink
Revert "BlockFrequency: Saturate at 1 instead of 0 when multiplying a…
Browse files Browse the repository at this point in the history
… frequency with a branch probability."

This reverts commit r184584. Breaks PPC selfhost.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184590 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
d0k committed Jun 21, 2013
1 parent 5a18572 commit b47acea
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 95 deletions.
8 changes: 0 additions & 8 deletions include/llvm/Support/BlockFrequency.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,12 @@ class BlockFrequency {
public:
BlockFrequency(uint64_t Freq = 0) : Frequency(Freq) { }

/// \brief Returns the frequency of the entry block of the function.
static uint64_t getEntryFrequency() { return ENTRY_FREQ; }

/// \brief Returns the frequency as a fixpoint number scaled by the entry
/// frequency.
uint64_t getFrequency() const { return Frequency; }

/// \brief Multiplies with a branch probability. The computation will never
/// overflow. If the result is equal to zero but the input wasn't this method
/// will return a frequency of one.
BlockFrequency &operator*=(const BranchProbability &Prob);
const BlockFrequency operator*(const BranchProbability &Prob) const;

/// \brief Adds another block frequency using saturating arithmetic.
BlockFrequency &operator+=(const BlockFrequency &Freq);
const BlockFrequency operator+(const BlockFrequency &Freq) const;

Expand Down
12 changes: 2 additions & 10 deletions lib/Support/BlockFrequency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ uint64_t div96bit(uint64_t W[2], uint32_t D) {


BlockFrequency &BlockFrequency::operator*=(const BranchProbability &Prob) {
if (Frequency == 0)
return *this;

uint32_t n = Prob.getNumerator();
uint32_t d = Prob.getDenominator();

Expand All @@ -87,15 +84,10 @@ BlockFrequency &BlockFrequency::operator*=(const BranchProbability &Prob) {
// 64-bit.
mult96bit(Frequency, n, W);
Frequency = div96bit(W, d);
} else {
// Fast case.
Frequency = mulRes / d;
return *this;
}

// Limit the result to 1; 0 is a sentinel value. This keeps BlockFrequencyInfo
// from getting stuck at zero frequencies just because a value became too
// small to be represented as a BlockFrequency.
Frequency = (n == 0 || Frequency != 0) ? Frequency : 1;
Frequency = mulRes / d;
return *this;
}

Expand Down
65 changes: 0 additions & 65 deletions test/Analysis/BlockFrequencyInfo/singularity.ll

This file was deleted.

13 changes: 1 addition & 12 deletions unittests/Support/BlockFrequencyTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,11 @@ using namespace llvm;

namespace {

TEST(BlockFrequencyTest, ZeroToZero) {
BlockFrequency Freq(0);
BranchProbability Prob(UINT32_MAX - 1, UINT32_MAX);
Freq *= Prob;
EXPECT_EQ(Freq.getFrequency(), 0u);

Freq = 1;
Freq *= BranchProbability::getZero();
EXPECT_EQ(Freq.getFrequency(), 0u);
}

TEST(BlockFrequencyTest, OneToZero) {
BlockFrequency Freq(1);
BranchProbability Prob(UINT32_MAX - 1, UINT32_MAX);
Freq *= Prob;
EXPECT_EQ(Freq.getFrequency(), 1u);
EXPECT_EQ(Freq.getFrequency(), 0u);
}

TEST(BlockFrequencyTest, OneToOne) {
Expand Down

0 comments on commit b47acea

Please sign in to comment.