[llvm] r211559 - Support: Return ScaledNumbers::MaxScale from getQuotient()
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Jun 23 17:26:08 PDT 2014
Author: dexonsmith
Date: Mon Jun 23 19:26:08 2014
New Revision: 211559
URL: http://llvm.org/viewvc/llvm-project?rev=211559&view=rev
Log:
Support: Return ScaledNumbers::MaxScale from getQuotient()
Return MaxScale now that it's available.
Modified:
llvm/trunk/include/llvm/Support/ScaledNumber.h
llvm/trunk/unittests/Support/ScaledNumberTest.cpp
Modified: llvm/trunk/include/llvm/Support/ScaledNumber.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ScaledNumber.h?rev=211559&r1=211558&r2=211559&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ScaledNumber.h (original)
+++ llvm/trunk/include/llvm/Support/ScaledNumber.h Mon Jun 23 19:26:08 2014
@@ -148,7 +148,7 @@ std::pair<uint32_t, int16_t> divide32(ui
///
/// 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(
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);
Modified: llvm/trunk/unittests/Support/ScaledNumberTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ScaledNumberTest.cpp?rev=211559&r1=211558&r2=211559&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/ScaledNumberTest.cpp (original)
+++ llvm/trunk/unittests/Support/ScaledNumberTest.cpp Mon Jun 23 19:26:08 2014
@@ -137,8 +137,8 @@ TEST(ScaledNumberHelpersTest, getQuotien
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, getQuotien
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));
More information about the llvm-commits
mailing list