[llvm-commits] [llvm] r158213 - in /llvm/trunk: lib/Support/APInt.cpp test/CodeGen/Generic/2012-06-08-APIntCrash.ll

Chad Rosier mcrosier at apple.com
Fri Jun 8 11:04:52 PDT 2012


Author: mcrosier
Date: Fri Jun  8 13:04:52 2012
New Revision: 158213

URL: http://llvm.org/viewvc/llvm-project?rev=158213&view=rev
Log:
Fix a crash in APInt::lshr when shiftAmt > BitWidth.
Patch by James Benton <jbenton at vmware.com>.

Added:
    llvm/trunk/test/CodeGen/Generic/2012-06-08-APIntCrash.ll
Modified:
    llvm/trunk/lib/Support/APInt.cpp

Modified: llvm/trunk/lib/Support/APInt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=158213&r1=158212&r2=158213&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APInt.cpp (original)
+++ llvm/trunk/lib/Support/APInt.cpp Fri Jun  8 13:04:52 2012
@@ -1135,7 +1135,7 @@
   // 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

Added: llvm/trunk/test/CodeGen/Generic/2012-06-08-APIntCrash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/2012-06-08-APIntCrash.ll?rev=158213&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Generic/2012-06-08-APIntCrash.ll (added)
+++ llvm/trunk/test/CodeGen/Generic/2012-06-08-APIntCrash.ll Fri Jun  8 13:04:52 2012
@@ -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;
+}





More information about the llvm-commits mailing list