aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/APInt.cpp
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2020-02-15 12:16:14 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2020-02-15 12:16:14 +0000
commit34ad4cca7245626c3d8348c7e3dd077ff35db84e (patch)
treecc70a6423c4239fe1238d60ed67e011041038d08 /llvm/lib/Support/APInt.cpp
parent4d5c3ade0b26ae3189e4601ce539844f54722ed8 (diff)
downloadllvm-34ad4cca7245626c3d8348c7e3dd077ff35db84e.zip
llvm-34ad4cca7245626c3d8348c7e3dd077ff35db84e.tar.gz
llvm-34ad4cca7245626c3d8348c7e3dd077ff35db84e.tar.bz2
[APInt] byteSwap - simplify sub 64-bits cases to match general implementation. NFCI.
We can just byteSwap the entire uint64_t VAL and then shift down into place like we do for the multi-word case.
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r--llvm/lib/Support/APInt.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index c07fc6d..3a5fada 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -675,15 +675,11 @@ APInt APInt::byteSwap() const {
return APInt(BitWidth, ByteSwap_16(uint16_t(U.VAL)));
if (BitWidth == 32)
return APInt(BitWidth, ByteSwap_32(unsigned(U.VAL)));
- if (BitWidth == 48) {
- unsigned Tmp1 = unsigned(U.VAL >> 16);
- Tmp1 = ByteSwap_32(Tmp1);
- uint16_t Tmp2 = uint16_t(U.VAL);
- Tmp2 = ByteSwap_16(Tmp2);
- return APInt(BitWidth, (uint64_t(Tmp2) << 32) | Tmp1);
- }
- if (BitWidth == 64)
- return APInt(BitWidth, ByteSwap_64(U.VAL));
+ if (BitWidth <= 64) {
+ uint64_t Tmp1 = ByteSwap_64(U.VAL);
+ Tmp1 >>= (64 - BitWidth);
+ return APInt(BitWidth, Tmp1);
+ }
APInt Result(getNumWords() * APINT_BITS_PER_WORD, 0);
for (unsigned I = 0, N = getNumWords(); I != N; ++I)