[llvm-commits] [llvm] r166803 - /llvm/trunk/include/llvm/ADT/APInt.h

Derek Schuff dschuff at google.com
Fri Oct 26 12:52:27 PDT 2012


Author: dschuff
Date: Fri Oct 26 14:52:27 2012
New Revision: 166803

URL: http://llvm.org/viewvc/llvm-project?rev=166803&view=rev
Log:
Stop APInt::shl from generating llvm.trap

APInt::shl generated llvm.trap to guard against shifts greater than bit-width.
This was already checked with an assert, and there was a special case for
shifts equal to bit-width. Modify this check to catch shifts greater than or
equal to bit-width, so llvm.trap isn't generated.

Patch contributed by JF Bastien

Modified:
    llvm/trunk/include/llvm/ADT/APInt.h

Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=166803&r1=166802&r2=166803&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Fri Oct 26 14:52:27 2012
@@ -760,7 +760,7 @@
   APInt shl(unsigned shiftAmt) const {
     assert(shiftAmt <= BitWidth && "Invalid shift amount");
     if (isSingleWord()) {
-      if (shiftAmt == BitWidth)
+      if (shiftAmt >= BitWidth)
         return APInt(BitWidth, 0); // avoid undefined shift results
       return APInt(BitWidth, VAL << shiftAmt);
     }





More information about the llvm-commits mailing list