Skip to content

Commit

Permalink
[APInt] In slt/sgt(uint64_t), only call getMinSignedBits if the APInt…
Browse files Browse the repository at this point in the history
… is not a single word.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300824 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
topperc committed Apr 20, 2017
1 parent 63d7ef8 commit 6366ebb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/llvm/ADT/APInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,8 @@ class LLVM_NODISCARD APInt {
///
/// \returns true if *this < RHS when considered signed.
bool slt(int64_t RHS) const {
return getMinSignedBits() > 64 ? isNegative() : getSExtValue() < RHS;
return (!isSingleWord() && getMinSignedBits() > 64) ? isNegative()
: getSExtValue() < RHS;
}

/// \brief Unsigned less or equal comparison
Expand Down Expand Up @@ -1173,7 +1174,8 @@ class LLVM_NODISCARD APInt {
///
/// \returns true if *this > RHS when considered signed.
bool sgt(int64_t RHS) const {
return getMinSignedBits() > 64 ? !isNegative() : getSExtValue() > RHS;
return (!isSingleWord() && getMinSignedBits() > 64) ? !isNegative()
: getSExtValue() > RHS;
}

/// \brief Unsigned greater or equal comparison
Expand Down

0 comments on commit 6366ebb

Please sign in to comment.