Changes in directory llvm/lib/Support:
APInt.cpp updated: 1.73 -> 1.74 --- Log message: Fix (and simplify) 48-bit byte swap. Get pos/neg infinity the correct way. --- Diffs of the changes: (+8 -9) APInt.cpp | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.73 llvm/lib/Support/APInt.cpp:1.74 --- llvm/lib/Support/APInt.cpp:1.73 Mon Mar 19 16:19:02 2007 +++ llvm/lib/Support/APInt.cpp Tue Mar 20 15:42:36 2007 @@ -18,6 +18,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/MathExtras.h" #include <math.h> +#include <limits> #include <cstring> #include <cstdlib> #ifndef NDEBUG @@ -762,17 +763,15 @@ APInt APInt::byteSwap() const { assert(BitWidth >= 16 && BitWidth % 16 == 0 && "Cannot byteswap!"); if (BitWidth == 16) - return APInt(BitWidth, ByteSwap_16(VAL)); + return APInt(BitWidth, ByteSwap_16(uint16_t(VAL))); else if (BitWidth == 32) - return APInt(BitWidth, ByteSwap_32(VAL)); + return APInt(BitWidth, ByteSwap_32(uint32_t(VAL))); else if (BitWidth == 48) { - uint64_t Tmp1 = ((VAL >> 32) << 16) | (VAL & 0xFFFF); + uint32_t Tmp1 = uint32_t(VAL >> 16); Tmp1 = ByteSwap_32(Tmp1); - uint64_t Tmp2 = (VAL >> 16) & 0xFFFF; + uint16_t Tmp2 = uint16_t(VAL); Tmp2 = ByteSwap_16(Tmp2); - return - APInt(BitWidth, - (Tmp1 & 0xff) | ((Tmp1<<16) & 0xffff00000000ULL) | (Tmp2 << 16)); + return APInt(BitWidth, (uint64_t(Tmp2) << 32) | Tmp1); } else if (BitWidth == 64) return APInt(BitWidth, ByteSwap_64(VAL)); else { @@ -869,9 +868,9 @@ // Return infinity for exponent overflow if (exp > 1023) { if (!isSigned || !isNeg) - return double(1.0E300 * 1.0E300); // positive infinity + return std::numeric_limits<double>::infinity(); else - return double(-1.0E300 * 1.0E300); // negative infinity + return -std::numeric_limits<double>::infinity(); } exp += 1023; // Increment for 1023 bias _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits