summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-06-08 18:04:52 +0000
committerChad Rosier <mcrosier@apple.com>2012-06-08 18:04:52 +0000
commit3d464d8068c33e86bbf99498541d7ef6583c15a2 (patch)
tree99e4b782febdaa7665722ce6b83a1ad29fdfe911
parent596af1b02ee1e3e019467e8a7cb368511ada2cb2 (diff)
downloadbcm5719-llvm-3d464d8068c33e86bbf99498541d7ef6583c15a2.tar.gz
bcm5719-llvm-3d464d8068c33e86bbf99498541d7ef6583c15a2.zip
Fix a crash in APInt::lshr when shiftAmt > BitWidth.
Patch by James Benton <jbenton@vmware.com>. llvm-svn: 158213
-rw-r--r--llvm/lib/Support/APInt.cpp2
-rw-r--r--llvm/test/CodeGen/Generic/2012-06-08-APIntCrash.ll8
2 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index 9b81fe776a6..6a74883803c 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/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/llvm/test/CodeGen/Generic/2012-06-08-APIntCrash.ll b/llvm/test/CodeGen/Generic/2012-06-08-APIntCrash.ll
new file mode 100644
index 00000000000..bb285a20734
--- /dev/null
+++ b/llvm/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, <i32 0, i32 0, i32 0, i32 -1, i32 0, i32 0, i32 0, i32 -1>
+ ret <8 x i32> %2;
+}
OpenPOWER on IntegriCloud