[llvm] r273722 - [APInt] Don't shift into the sign bit
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 24 13:51:48 PDT 2016
Author: majnemer
Date: Fri Jun 24 15:51:47 2016
New Revision: 273722
URL: http://llvm.org/viewvc/llvm-project?rev=273722&view=rev
Log:
[APInt] Don't shift into the sign bit
This fixes PR28294.
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=273722&r1=273721&r2=273722&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APInt.cpp (original)
+++ llvm/trunk/lib/Support/APInt.cpp Fri Jun 24 15:51:47 2016
@@ -555,8 +555,8 @@ bool APInt::ult(const APInt& RHS) const
bool APInt::slt(const APInt& RHS) const {
assert(BitWidth == RHS.BitWidth && "Bit widths must be same for comparison");
if (isSingleWord()) {
- int64_t lhsSext = (int64_t(VAL) << (64-BitWidth)) >> (64-BitWidth);
- int64_t rhsSext = (int64_t(RHS.VAL) << (64-BitWidth)) >> (64-BitWidth);
+ int64_t lhsSext = SignExtend64(VAL, BitWidth);
+ int64_t rhsSext = SignExtend64(RHS.VAL, BitWidth);
return lhsSext < rhsSext;
}
More information about the llvm-commits
mailing list