[llvm] r184042 - APInt: Add a fast case for isAllOnesValue.
Benjamin Kramer
benny.kra at googlemail.com
Sat Jun 15 04:32:10 PDT 2013
Author: d0k
Date: Sat Jun 15 06:32:09 2013
New Revision: 184042
URL: http://llvm.org/viewvc/llvm-project?rev=184042&view=rev
Log:
APInt: Add a fast case for isAllOnesValue.
Modified:
llvm/trunk/include/llvm/ADT/APInt.h
Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=184042&r1=184041&r2=184042&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Sat Jun 15 06:32:09 2013
@@ -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.
///
More information about the llvm-commits
mailing list