From 5a5ac124e1efaf208671f01c46edb15f29ed2a0b Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 27 May 2015 18:44:32 +0000 Subject: Vendor import of llvm trunk r238337: https://llvm.org/svn/llvm-project/llvm/trunk@238337 --- include/llvm/Support/ScaledNumber.h | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'include/llvm/Support/ScaledNumber.h') diff --git a/include/llvm/Support/ScaledNumber.h b/include/llvm/Support/ScaledNumber.h index a1c4c80c356fe..0a4262b7eec5d 100644 --- a/include/llvm/Support/ScaledNumber.h +++ b/include/llvm/Support/ScaledNumber.h @@ -514,7 +514,7 @@ public: : Digits(Digits), Scale(Scale) {} private: - ScaledNumber(const std::pair &X) + ScaledNumber(const std::pair &X) : Digits(X.first), Scale(X.second) {} public: @@ -670,14 +670,7 @@ public: return ScaledNumbers::compare(Digits, Scale, X.Digits, X.Scale); } int compareTo(uint64_t N) const { - ScaledNumber Scaled = get(N); - int Compare = compare(Scaled); - if (Width == 64 || Compare != 0) - return Compare; - - // Check for precision loss. We know *this == RoundTrip. - uint64_t RoundTrip = Scaled.template toInt(); - return N == RoundTrip ? 0 : RoundTrip < N ? -1 : 1; + return ScaledNumbers::compare(Digits, Scale, N, 0); } int compareTo(int64_t N) const { return N < 0 ? 1 : compareTo(uint64_t(N)); } @@ -732,10 +725,20 @@ SCALED_NUMBER_BOP(+, += ) SCALED_NUMBER_BOP(-, -= ) SCALED_NUMBER_BOP(*, *= ) SCALED_NUMBER_BOP(/, /= ) -SCALED_NUMBER_BOP(<<, <<= ) -SCALED_NUMBER_BOP(>>, >>= ) #undef SCALED_NUMBER_BOP +template +ScaledNumber operator<<(const ScaledNumber &L, + int16_t Shift) { + return ScaledNumber(L) <<= Shift; +} + +template +ScaledNumber operator>>(const ScaledNumber &L, + int16_t Shift) { + return ScaledNumber(L) >>= Shift; +} + template raw_ostream &operator<<(raw_ostream &OS, const ScaledNumber &X) { return X.print(OS, 10); -- cgit v1.2.3