mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
Support: Return ScaledNumbers::MaxScale from getQuotient()
Return MaxScale now that it's available. llvm-svn: 211559
This commit is contained in:
parent
6ccaf0fa23
commit
339e2238e8
@ -148,7 +148,7 @@ std::pair<uint32_t, int16_t> divide32(uint32_t Dividend, uint32_t Divisor);
|
||||
///
|
||||
/// Implemented with one 64-bit integer divide/remainder pair.
|
||||
///
|
||||
/// Returns \c (DigitsT_MAX, INT16_MAX) for divide-by-zero (0 for 0/0).
|
||||
/// Returns \c (DigitsT_MAX, MaxScale) for divide-by-zero (0 for 0/0).
|
||||
template <class DigitsT>
|
||||
std::pair<DigitsT, int16_t> getQuotient(DigitsT Dividend, DigitsT Divisor) {
|
||||
static_assert(!std::numeric_limits<DigitsT>::is_signed, "expected unsigned");
|
||||
@ -159,7 +159,7 @@ std::pair<DigitsT, int16_t> getQuotient(DigitsT Dividend, DigitsT Divisor) {
|
||||
if (!Dividend)
|
||||
return std::make_pair(0, 0);
|
||||
if (!Divisor)
|
||||
return std::make_pair(std::numeric_limits<DigitsT>::max(), INT16_MAX);
|
||||
return std::make_pair(std::numeric_limits<DigitsT>::max(), MaxScale);
|
||||
|
||||
if (getWidth<DigitsT>() == 64)
|
||||
return divide64(Dividend, Divisor);
|
||||
|
@ -137,8 +137,8 @@ TEST(ScaledNumberHelpersTest, getQuotient) {
|
||||
EXPECT_EQ(SP32(0, 0), getQuotient32(0, 0));
|
||||
EXPECT_EQ(SP32(0, 0), getQuotient32(0, 1));
|
||||
EXPECT_EQ(SP32(0, 0), getQuotient32(0, 73));
|
||||
EXPECT_EQ(SP32(UINT32_MAX, INT16_MAX), getQuotient32(1, 0));
|
||||
EXPECT_EQ(SP32(UINT32_MAX, INT16_MAX), getQuotient32(6, 0));
|
||||
EXPECT_EQ(SP32(UINT32_MAX, MaxScale), getQuotient32(1, 0));
|
||||
EXPECT_EQ(SP32(UINT32_MAX, MaxScale), getQuotient32(6, 0));
|
||||
|
||||
// Powers of two.
|
||||
EXPECT_EQ(SP32(1u << 31, -31), getQuotient32(1, 1));
|
||||
@ -171,8 +171,8 @@ TEST(ScaledNumberHelpersTest, getQuotient) {
|
||||
EXPECT_EQ(SP64(0, 0), getQuotient64(0, 0));
|
||||
EXPECT_EQ(SP64(0, 0), getQuotient64(0, 1));
|
||||
EXPECT_EQ(SP64(0, 0), getQuotient64(0, 73));
|
||||
EXPECT_EQ(SP64(UINT64_MAX, INT16_MAX), getQuotient64(1, 0));
|
||||
EXPECT_EQ(SP64(UINT64_MAX, INT16_MAX), getQuotient64(6, 0));
|
||||
EXPECT_EQ(SP64(UINT64_MAX, MaxScale), getQuotient64(1, 0));
|
||||
EXPECT_EQ(SP64(UINT64_MAX, MaxScale), getQuotient64(6, 0));
|
||||
|
||||
// Powers of two.
|
||||
EXPECT_EQ(SP64(1, 0), getQuotient64(1, 1));
|
||||
|
Loading…
Reference in New Issue
Block a user