summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/ADT/APInt.h6
-rw-r--r--llvm/unittests/ADT/APIntTest.cpp4
2 files changed, 4 insertions, 6 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 5f87765a52d..5b298199371 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -847,9 +847,8 @@ public:
///
/// \returns *this after shifting left by ShiftAmt
APInt &operator<<=(unsigned ShiftAmt) {
- assert(ShiftAmt <= BitWidth && "Invalid shift amount");
if (isSingleWord()) {
- if (ShiftAmt == BitWidth)
+ if (ShiftAmt >= BitWidth)
VAL = 0;
else
VAL <<= ShiftAmt;
@@ -894,9 +893,8 @@ public:
/// Logical right-shift this APInt by ShiftAmt in place.
void lshrInPlace(unsigned ShiftAmt) {
- assert(ShiftAmt <= BitWidth && "Invalid shift amount");
if (isSingleWord()) {
- if (ShiftAmt == BitWidth)
+ if (ShiftAmt >= BitWidth)
VAL = 0;
else
VAL >>= ShiftAmt;
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp
index 7d451836ad9..0f1d2d6d8f9 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -2021,7 +2021,7 @@ TEST(APIntTest, LogicalRightShift) {
// Ensure we handle large shifts of multi-word.
const APInt neg_one(128, static_cast<uint64_t>(-1), true);
- EXPECT_EQ(0, neg_one.lshr(128));
+ EXPECT_EQ(0, neg_one.lshr(257));
}
TEST(APIntTest, LeftShift) {
@@ -2054,7 +2054,7 @@ TEST(APIntTest, LeftShift) {
// Ensure we handle large shifts of multi-word.
const APInt neg_one(128, static_cast<uint64_t>(-1), true);
- EXPECT_EQ(0, neg_one.shl(128));
+ EXPECT_EQ(0, neg_one.shl(257));
}
} // end anonymous namespace
OpenPOWER on IntegriCloud