Implement comparison operators for BranchProbability in a way that can't overflow INT64_MAX.

Add a test case for the edge case that triggers this. Thanks to Chandler for bringing this to my attention.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142794 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer
2011-10-24 13:50:56 +00:00
parent de1c9bb450
commit 13b10731ab
2 changed files with 27 additions and 10 deletions

View File

@ -71,6 +71,15 @@ TEST(BlockFrequencyTest, ProbabilityCompare) {
EXPECT_TRUE(B > C);
EXPECT_FALSE(B <= C);
EXPECT_TRUE(B >= C);
BranchProbability BigZero(0, UINT32_MAX);
BranchProbability BigOne(UINT32_MAX, UINT32_MAX);
EXPECT_FALSE(BigZero == BigOne);
EXPECT_TRUE(BigZero != BigOne);
EXPECT_TRUE(BigZero < BigOne);
EXPECT_FALSE(BigZero > BigOne);
EXPECT_TRUE(BigZero <= BigOne);
EXPECT_FALSE(BigZero >= BigOne);
}
}