[llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h
Reid Spencer
reid at x10sys.com
Sun Feb 25 17:21:16 PST 2007
Changes in directory llvm/include/llvm/ADT:
APInt.h updated: 1.19 -> 1.20
---
Log message:
Add an isNegative method to determine if the APInt's value is negative.
This is much less expensive than a test against zero.
---
Diffs of the changes: (+7 -0)
APInt.h | 7 +++++++
1 files changed, 7 insertions(+)
Index: llvm/include/llvm/ADT/APInt.h
diff -u llvm/include/llvm/ADT/APInt.h:1.19 llvm/include/llvm/ADT/APInt.h:1.20
--- llvm/include/llvm/ADT/APInt.h:1.19 Sun Feb 25 13:26:01 2007
+++ llvm/include/llvm/ADT/APInt.h Sun Feb 25 19:20:59 2007
@@ -352,6 +352,13 @@
return !slt(RHS);
}
+ /// This just tests the high bit of this APInt to determine if it is negative.
+ /// @returns true if this APInt is negative, false otherwise
+ /// @brief Determine sign of this APInt.
+ bool isNegative() {
+ return (*this)[BitWidth - 1];
+ }
+
/// Arithmetic right-shift this APInt by shiftAmt.
/// @brief Arithmetic right-shift function.
APInt ashr(uint32_t shiftAmt) const;
More information about the llvm-commits
mailing list