summaryrefslogtreecommitdiffstats
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
commit9f81bb0f768375d5a3b5d0fdbb5ded854b89f02a (patch)
treef1fcf546657de2a81a59f6cc1b3055c5ccf4200e
parent9ddfaf2be68726cba175938b0c2ec8cd5ae855a6 (diff)
downloadbcm5719-llvm-9f81bb0f768375d5a3b5d0fdbb5ded854b89f02a.tar.gz
bcm5719-llvm-9f81bb0f768375d5a3b5d0fdbb5ded854b89f02a.zip
APInt: Add a fast case for isAllOnesValue.
llvm-svn: 184042
-rw-r--r--llvm/include/llvm/ADT/APInt.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index e5797b8be23..625a6dbfd6e 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/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.
///
OpenPOWER on IntegriCloud