summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-03-31 22:23:42 +0000
committerCraig Topper <craig.topper@gmail.com>2017-03-31 22:23:42 +0000
commit47fd2de304d459736d313f74b17d5d2890518d08 (patch)
tree0f5596955bd495e0649d9284acabdc854dc37f29 /llvm/unittests/ADT
parentbf24cb7189abcb8b0b404de2c5f8c2c6b2223658 (diff)
downloadbcm5719-llvm-47fd2de304d459736d313f74b17d5d2890518d08.tar.gz
bcm5719-llvm-47fd2de304d459736d313f74b17d5d2890518d08.zip
[APInt] Fix bugs in isShiftedMask to match behavior of the similar function in MathExtras.h
This removes a parameter from the routine that was responsible for a lot of the issue. It was a bit count that had to be set to the BitWidth of the APInt and would get passed to getLowBitsSet. This guaranteed the call to getLowBitsSet would create an all ones value. This was then compared to (V | (V-1)). So the only shifted masks we detected had to have the MSB set. The one in tree user is a transform in InstCombine that never fires due to earlier transforms covering the case better. I've submitted a patch to remove it completely, but for now I've just adapted it to the new interface for isShiftedMask. llvm-svn: 299273
Diffstat (limited to 'llvm/unittests/ADT')
-rw-r--r--llvm/unittests/ADT/APIntTest.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp
index 51c6347cbe8..bf7d8d83339 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -1576,26 +1576,26 @@ TEST(APIntTest, isMask) {
}
TEST(APIntTest, isShiftedMask) {
- EXPECT_FALSE(APIntOps::isShiftedMask(32, APInt(32, 0x01010101)));
- EXPECT_TRUE(APIntOps::isShiftedMask(32, APInt(32, 0xf0000000)));
- EXPECT_TRUE(APIntOps::isShiftedMask(32, APInt(32, 0xffff0000)));
- EXPECT_FALSE(APIntOps::isShiftedMask(32, APInt(32, 0xff << 1))); // BUG
+ EXPECT_FALSE(APIntOps::isShiftedMask(APInt(32, 0x01010101)));
+ EXPECT_TRUE(APIntOps::isShiftedMask(APInt(32, 0xf0000000)));
+ EXPECT_TRUE(APIntOps::isShiftedMask(APInt(32, 0xffff0000)));
+ EXPECT_TRUE(APIntOps::isShiftedMask(APInt(32, 0xff << 1)));
for (int N : { 1, 2, 3, 4, 7, 8, 16, 32, 64, 127, 128, 129, 256 }) {
- EXPECT_TRUE(APIntOps::isShiftedMask(N, APInt(N, 0))); // BUG
+ EXPECT_FALSE(APIntOps::isShiftedMask(APInt(N, 0)));
APInt One(N, 1);
for (int I = 1; I < N; ++I) {
APInt MaskVal = One.shl(I) - 1;
- EXPECT_FALSE(APIntOps::isShiftedMask(N, MaskVal)); // BUG
+ EXPECT_TRUE(APIntOps::isShiftedMask(MaskVal));
}
for (int I = 1; I < N - 1; ++I) {
APInt MaskVal = One.shl(I);
- EXPECT_FALSE(APIntOps::isShiftedMask(N, MaskVal)); // BUG
+ EXPECT_TRUE(APIntOps::isShiftedMask(MaskVal));
}
for (int I = 1; I < N; ++I) {
APInt MaskVal = APInt::getHighBitsSet(N, I);
- EXPECT_TRUE(APIntOps::isShiftedMask(N, MaskVal));
+ EXPECT_TRUE(APIntOps::isShiftedMask(MaskVal));
}
}
}
OpenPOWER on IntegriCloud