diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp index 9b81fe776a6..6a74883803c 100644 --- a/lib/Support/APInt.cpp +++ b/lib/Support/APInt.cpp @@ -1135,7 +1135,7 @@ APInt APInt::lshr(unsigned shiftAmt) const { // If all the bits were shifted out, the result is 0. This avoids issues // with shifting by the size of the integer type, which produces undefined // results. We define these "undefined results" to always be 0. - if (shiftAmt == BitWidth) + if (shiftAmt >= BitWidth) return APInt(BitWidth, 0); // If none of the bits are shifted out, the result is *this. This avoids diff --git a/test/CodeGen/Generic/2012-06-08-APIntCrash.ll b/test/CodeGen/Generic/2012-06-08-APIntCrash.ll new file mode 100644 index 00000000000..bb285a20734 --- /dev/null +++ b/test/CodeGen/Generic/2012-06-08-APIntCrash.ll @@ -0,0 +1,8 @@ +; RUN: llc < %s + +define <8 x i32> @test1(<8 x i32>* %ptr) +{ + %1 = load <8 x i32>* %ptr, align 32 + %2 = and <8 x i32> %1, + ret <8 x i32> %2; +}