mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
Add test cases for BlockFrequency.
llvm-svn: 136244
This commit is contained in:
parent
ee0970dabc
commit
4e897c8ac3
56
unittests/Support/BlockFrequencyTest.cpp
Normal file
56
unittests/Support/BlockFrequencyTest.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include "llvm/Support/BlockFrequency.h"
|
||||
#include "llvm/Support/BranchProbability.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include <climits>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
|
||||
TEST(BlockFrequencyTest, OneToZero) {
|
||||
BlockFrequency Freq(1);
|
||||
BranchProbability Prob(UINT32_MAX - 1, UINT32_MAX);
|
||||
Freq *= Prob;
|
||||
EXPECT_EQ(Freq.getFrequency(), 0u);
|
||||
}
|
||||
|
||||
TEST(BlockFrequencyTest, OneToOne) {
|
||||
BlockFrequency Freq(1);
|
||||
BranchProbability Prob(UINT32_MAX, UINT32_MAX);
|
||||
Freq *= Prob;
|
||||
EXPECT_EQ(Freq.getFrequency(), 1u);
|
||||
}
|
||||
|
||||
TEST(BlockFrequencyTest, ThreeToOne) {
|
||||
BlockFrequency Freq(3);
|
||||
BranchProbability Prob(3000000, 9000000);
|
||||
Freq *= Prob;
|
||||
EXPECT_EQ(Freq.getFrequency(), 1u);
|
||||
}
|
||||
|
||||
TEST(BlockFrequencyTest, MaxToHalfMax) {
|
||||
BlockFrequency Freq(UINT64_MAX);
|
||||
BranchProbability Prob(UINT32_MAX / 2, UINT32_MAX);
|
||||
Freq *= Prob;
|
||||
EXPECT_EQ(Freq.getFrequency(), 9223372034707292159LLu);
|
||||
}
|
||||
|
||||
TEST(BlockFrequencyTest, BigToBig) {
|
||||
const uint64_t Big = 387246523487234346LL;
|
||||
const uint32_t P = 123456789;
|
||||
BlockFrequency Freq(Big);
|
||||
BranchProbability Prob(P, P);
|
||||
Freq *= Prob;
|
||||
EXPECT_EQ(Freq.getFrequency(), Big);
|
||||
}
|
||||
|
||||
TEST(BlockFrequencyTest, MaxToMax) {
|
||||
BlockFrequency Freq(UINT64_MAX);
|
||||
BranchProbability Prob(UINT32_MAX, UINT32_MAX);
|
||||
Freq *= Prob;
|
||||
EXPECT_EQ(Freq.getFrequency(), UINT64_MAX);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user