summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/APIntTest.cpp
diff options
context:
space:
mode:
authorTim Shen <timshen91@gmail.com>2018-02-16 01:44:36 +0000
committerTim Shen <timshen91@gmail.com>2018-02-16 01:44:36 +0000
commit89337750a0286ac970738ac22a8462d82008b09f (patch)
tree53c022d3515c555a21e64beea4c972802096470c /llvm/unittests/ADT/APIntTest.cpp
parent3dc6de619a7a5778c1338187d3181ac5613b3959 (diff)
downloadbcm5719-llvm-89337750a0286ac970738ac22a8462d82008b09f.tar.gz
bcm5719-llvm-89337750a0286ac970738ac22a8462d82008b09f.zip
[APInt] Fix extractBits to correctly handle Result.isSingleWord() case.
Summary: extractBits assumes that `!this->isSingleWord() implies !Result.isSingleWord()`, which may not necessarily be true. Handle both cases. Reviewers: RKSimon Subscribers: sanjoy, llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D43363 llvm-svn: 325311
Diffstat (limited to 'llvm/unittests/ADT/APIntTest.cpp')
-rw-r--r--llvm/unittests/ADT/APIntTest.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp
index 05fad386064..331b3997071 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -1768,6 +1768,13 @@ TEST(APIntTest, extractBits) {
i257.extractBits(128, 1).getSExtValue());
EXPECT_EQ(static_cast<int64_t>(0xFFFFFFFFFF80007Full),
i257.extractBits(129, 1).getSExtValue());
+
+ EXPECT_EQ(APInt(48, 0),
+ APInt(144, "281474976710655", 10).extractBits(48, 48));
+ EXPECT_EQ(APInt(48, 0x0000ffffffffffffull),
+ APInt(144, "281474976710655", 10).extractBits(48, 0));
+ EXPECT_EQ(APInt(48, 0x00007fffffffffffull),
+ APInt(144, "281474976710655", 10).extractBits(48, 1));
}
TEST(APIntTest, getLowBitsSet) {
OpenPOWER on IntegriCloud