From 5f1c01788ea6755edd190f6c140d82565904b9d1 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Fri, 24 Jun 2016 20:51:47 +0000 Subject: [APInt] Don't shift into the sign bit This fixes PR28294. llvm-svn: 273722 --- llvm/lib/Support/APInt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Support') diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index cd7b9a9980d..348f807c91a 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -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; } -- cgit v1.2.3