[llvm] 4d5c3ad - [APInt] Add some procedural APInt::byteSwap unit tests
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 15 03:59:44 PST 2020
Author: Simon Pilgrim
Date: 2020-02-15T11:58:10Z
New Revision: 4d5c3ade0b26ae3189e4601ce539844f54722ed8
URL: https://github.com/llvm/llvm-project/commit/4d5c3ade0b26ae3189e4601ce539844f54722ed8
DIFF: https://github.com/llvm/llvm-project/commit/4d5c3ade0b26ae3189e4601ce539844f54722ed8.diff
LOG: [APInt] Add some procedural APInt::byteSwap unit tests
rGf0181cc7bac3 added specific tests up to i64, this adds a general loop to test some basic byte moves for larger APInts.
Added:
Modified:
llvm/unittests/ADT/APIntTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp
index c3a9bda3c817..34efbc524f94 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -1821,6 +1821,15 @@ TEST(APIntTest, byteSwap) {
EXPECT_EQ(0x117700ff, APInt(32, 0xff007711).byteSwap());
EXPECT_EQ(0x050403020100ULL, APInt(48, 0x000102030405ULL).byteSwap());
EXPECT_EQ(0xff050403020100aaULL, APInt(64, 0xaa000102030405ffULL).byteSwap());
+
+ for (unsigned N : {16, 32, 48, 64, 80, 96, 112, 128, 256, 1024, 1040}) {
+ for (unsigned I = 0; I < N; I += 8) {
+ APInt X = APInt::getBitsSet(N, I, I + 8);
+ APInt Y = APInt::getBitsSet(N, N - I - 8, N - I);
+ EXPECT_EQ(Y, X.byteSwap());
+ EXPECT_EQ(X, Y.byteSwap());
+ }
+ }
}
TEST(APIntTest, reverseBits) {
More information about the llvm-commits
mailing list