[llvm] r300813 - Revert r300811 "[APInt] Add back the asserts that check that the APInt shift methods aren't called with values larger than BitWidth."
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 19 19:46:22 PDT 2017
Author: ctopper
Date: Wed Apr 19 21:46:21 2017
New Revision: 300813
URL: http://llvm.org/viewvc/llvm-project?rev=300813&view=rev
Log:
Revert r300811 "[APInt] Add back the asserts that check that the APInt shift methods aren't called with values larger than BitWidth."
This is failing a self host debug build.
Modified:
llvm/trunk/include/llvm/ADT/APInt.h
llvm/trunk/unittests/ADT/APIntTest.cpp
Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=300813&r1=300812&r2=300813&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Wed Apr 19 21:46:21 2017
@@ -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;
Modified: llvm/trunk/unittests/ADT/APIntTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/APIntTest.cpp?rev=300813&r1=300812&r2=300813&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/APIntTest.cpp (original)
+++ llvm/trunk/unittests/ADT/APIntTest.cpp Wed Apr 19 21:46:21 2017
@@ -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
More information about the llvm-commits
mailing list