[block-freq] Add a right shift to BlockFrequency that saturates at 1.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197302 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Michael Gottesman
2013-12-14 02:24:22 +00:00
parent 7cc5f793bc
commit 1b98ef1c19
3 changed files with 23 additions and 0 deletions

View File

@@ -237,4 +237,12 @@ TEST(BlockFrequencyTest, ProbabilityCompare) {
EXPECT_FALSE(BigZero >= BigOne);
}
TEST(BlockFrequencyTest, SaturatingRightShift) {
BlockFrequency Freq(0x10080ULL);
Freq >>= 2;
EXPECT_EQ(Freq.getFrequency(), 0x4020ULL);
Freq >>= 20;
EXPECT_EQ(Freq.getFrequency(), 0x1ULL);
}
}