summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-06-15 11:32:09 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-06-15 11:32:09 +0000
commit8dcff889825c7f38dab27a349b7a21f186a5ff9e (patch)
tree6b1448494de100bb378ebfefa62df0726de5f43c
parent1750632ee13c51e6191c513b163c5f41e0dab4eb (diff)
downloadllvm-8dcff889825c7f38dab27a349b7a21f186a5ff9e.tar.gz
llvm-8dcff889825c7f38dab27a349b7a21f186a5ff9e.tar.bz2
llvm-8dcff889825c7f38dab27a349b7a21f186a5ff9e.tar.xz
APInt: Add a fast case for isAllOnesValue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184042 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ADT/APInt.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h
index e5797b8be2..625a6dbfd6 100644
--- a/include/llvm/ADT/APInt.h
+++ b/include/llvm/ADT/APInt.h
@@ -337,13 +337,17 @@ public:
/// \brief Determine if all bits are set
///
/// This checks to see if the value has all bits of the APInt are set or not.
- bool isAllOnesValue() const { return countPopulation() == BitWidth; }
+ bool isAllOnesValue() const {
+ if (isSingleWord())
+ return VAL == ~integerPart(0) >> (APINT_BITS_PER_WORD - BitWidth);
+ return countPopulationSlowCase() == BitWidth;
+ }
/// \brief Determine if this is the largest unsigned value.
///
/// This checks to see if the value of this APInt is the maximum unsigned
/// value for the APInt's bit width.
- bool isMaxValue() const { return countPopulation() == BitWidth; }
+ bool isMaxValue() const { return isAllOnesValue(); }
/// \brief Determine if this is the largest signed value.
///