summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/BranchProbabilityTest.cpp
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2015-10-15 14:59:40 +0000
committerManman Ren <manman.ren@gmail.com>2015-10-15 14:59:40 +0000
commit72d44b1b09664ff47454ad5b5f1d2ce86675a42f (patch)
tree71aec7ffe96c163cac9a674a34334fed82648a74 /llvm/unittests/Support/BranchProbabilityTest.cpp
parent6394ee598e8cbbc2067158afebb358effbf2594a (diff)
downloadbcm5719-llvm-72d44b1b09664ff47454ad5b5f1d2ce86675a42f.tar.gz
bcm5719-llvm-72d44b1b09664ff47454ad5b5f1d2ce86675a42f.zip
Recommit r250345, it was reverted in r250366 to investigate a bot failure.
Our internal bot is still red after r250366. llvm-svn: 250415
Diffstat (limited to 'llvm/unittests/Support/BranchProbabilityTest.cpp')
-rw-r--r--llvm/unittests/Support/BranchProbabilityTest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/llvm/unittests/Support/BranchProbabilityTest.cpp b/llvm/unittests/Support/BranchProbabilityTest.cpp
index 87a25091947..37a5c3f0dc8 100644
--- a/llvm/unittests/Support/BranchProbabilityTest.cpp
+++ b/llvm/unittests/Support/BranchProbabilityTest.cpp
@@ -287,4 +287,45 @@ TEST(BranchProbabilityTest, scaleBruteForce) {
}
}
+TEST(BranchProbabilityTest, NormalizeEdgeWeights) {
+ {
+ SmallVector<uint32_t, 2> Weights{0, 0};
+ BranchProbability::normalizeEdgeWeights(Weights.begin(), Weights.end());
+ EXPECT_EQ(1u, Weights[0]);
+ EXPECT_EQ(1u, Weights[1]);
+ }
+ {
+ SmallVector<uint32_t, 2> Weights{0, UINT32_MAX};
+ BranchProbability::normalizeEdgeWeights(Weights.begin(), Weights.end());
+ EXPECT_EQ(1u, Weights[0]);
+ EXPECT_EQ(UINT32_MAX - 1u, Weights[1]);
+ }
+ {
+ SmallVector<uint32_t, 2> Weights{1, UINT32_MAX};
+ BranchProbability::normalizeEdgeWeights(Weights.begin(), Weights.end());
+ EXPECT_EQ(1u, Weights[0]);
+ EXPECT_EQ(UINT32_MAX - 1u, Weights[1]);
+ }
+ {
+ SmallVector<uint32_t, 3> Weights{0, 0, UINT32_MAX};
+ BranchProbability::normalizeEdgeWeights(Weights.begin(), Weights.end());
+ EXPECT_EQ(1u, Weights[0]);
+ EXPECT_EQ(1u, Weights[1]);
+ EXPECT_EQ(UINT32_MAX / 2u, Weights[2]);
+ }
+ {
+ SmallVector<uint32_t, 2> Weights{UINT32_MAX, UINT32_MAX};
+ BranchProbability::normalizeEdgeWeights(Weights.begin(), Weights.end());
+ EXPECT_EQ(UINT32_MAX / 3u, Weights[0]);
+ EXPECT_EQ(UINT32_MAX / 3u, Weights[1]);
+ }
+ {
+ SmallVector<uint32_t, 3> Weights{UINT32_MAX, UINT32_MAX, UINT32_MAX};
+ BranchProbability::normalizeEdgeWeights(Weights.begin(), Weights.end());
+ EXPECT_EQ(UINT32_MAX / 4u, Weights[0]);
+ EXPECT_EQ(UINT32_MAX / 4u, Weights[1]);
+ EXPECT_EQ(UINT32_MAX / 4u, Weights[2]);
+ }
+}
+
}
OpenPOWER on IntegriCloud