mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-24 23:19:03 +00:00
Change APInt comparison with uint64_t.
Summary: This patch changes the way APInt is compared with a value of type uint64_t. Before the uint64_t value was truncated to the size of APInt before comparison. Now the comparison takes into account full 64-bit precision. Test Plan: Unit tests added. No regressions. Self-hosted check-all done as well. Reviewers: chandlerc, dexonsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10655 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241204 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1038,7 +1038,9 @@ public:
|
||||
/// the validity of the less-than relationship.
|
||||
///
|
||||
/// \returns true if *this < RHS when considered unsigned.
|
||||
bool ult(uint64_t RHS) const { return ult(APInt(getBitWidth(), RHS)); }
|
||||
bool ult(uint64_t RHS) const {
|
||||
return getActiveBits() > 64 ? false : getZExtValue() < RHS;
|
||||
}
|
||||
|
||||
/// \brief Signed less than comparison
|
||||
///
|
||||
@@ -1054,7 +1056,9 @@ public:
|
||||
/// the validity of the less-than relationship.
|
||||
///
|
||||
/// \returns true if *this < RHS when considered signed.
|
||||
bool slt(uint64_t RHS) const { return slt(APInt(getBitWidth(), RHS)); }
|
||||
bool slt(int64_t RHS) const {
|
||||
return getMinSignedBits() > 64 ? isNegative() : getSExtValue() < RHS;
|
||||
}
|
||||
|
||||
/// \brief Unsigned less or equal comparison
|
||||
///
|
||||
@@ -1102,7 +1106,9 @@ public:
|
||||
/// the validity of the greater-than relationship.
|
||||
///
|
||||
/// \returns true if *this > RHS when considered unsigned.
|
||||
bool ugt(uint64_t RHS) const { return ugt(APInt(getBitWidth(), RHS)); }
|
||||
bool ugt(uint64_t RHS) const {
|
||||
return getActiveBits() > 64 ? true : getZExtValue() > RHS;
|
||||
}
|
||||
|
||||
/// \brief Signed greather than comparison
|
||||
///
|
||||
@@ -1118,7 +1124,9 @@ public:
|
||||
/// the validity of the greater-than relationship.
|
||||
///
|
||||
/// \returns true if *this > RHS when considered signed.
|
||||
bool sgt(uint64_t RHS) const { return sgt(APInt(getBitWidth(), RHS)); }
|
||||
bool sgt(int64_t RHS) const {
|
||||
return getMinSignedBits() > 64 ? !isNegative() : getSExtValue() > RHS;
|
||||
}
|
||||
|
||||
/// \brief Unsigned greater or equal comparison
|
||||
///
|
||||
@@ -1150,7 +1158,7 @@ public:
|
||||
/// the validity of the greater-or-equal relationship.
|
||||
///
|
||||
/// \returns true if *this >= RHS when considered signed.
|
||||
bool sge(uint64_t RHS) const { return !slt(RHS); }
|
||||
bool sge(int64_t RHS) const { return !slt(RHS); }
|
||||
|
||||
/// This operation tests if there are any pairs of corresponding bits
|
||||
/// between this APInt and RHS that are both set.
|
||||
|
||||
Reference in New Issue
Block a user