aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/APInt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r--llvm/lib/Support/APInt.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index 9a22ccb..67ea57c 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -345,7 +345,7 @@ void APInt::flipAllBitsSlowCase() {
/// In the slow case, we know the result is large.
APInt APInt::concatSlowCase(const APInt &NewLSB) const {
unsigned NewWidth = getBitWidth() + NewLSB.getBitWidth();
- APInt Result = NewLSB.zext(NewWidth);
+ APInt Result = NewLSB.zextOrSelf(NewWidth);
Result.insertBits(*this, NewLSB.getBitWidth());
return Result;
}
@@ -360,9 +360,13 @@ void APInt::flipBit(unsigned bitPosition) {
void APInt::insertBits(const APInt &subBits, unsigned bitPosition) {
unsigned subBitWidth = subBits.getBitWidth();
- assert(0 < subBitWidth && (subBitWidth + bitPosition) <= BitWidth &&
+ assert(subBitWidth >= 0 && (subBitWidth + bitPosition) <= BitWidth &&
"Illegal bit insertion");
+ // inserting no bits is a noop.
+ if (subBitWidth == 0)
+ return;
+
// Insertion is a direct copy.
if (subBitWidth == BitWidth) {
*this = subBits;