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
diff --git a/unittests/Support/BlockFrequencyTest.cpp b/unittests/Support/BlockFrequencyTest.cpp
index ac3cedf..df25642 100644
--- a/unittests/Support/BlockFrequencyTest.cpp
+++ b/unittests/Support/BlockFrequencyTest.cpp
@@ -71,6 +71,15 @@
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);
}
}