summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/ADT/APInt.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 1799b21b183..3c16b3841ef 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -333,12 +333,14 @@ public:
/// @brief Check if this APInt has an N-bits unsigned integer value.
bool isIntN(uint32_t N) const {
assert(N && "N == 0 ???");
- if (isSingleWord()) {
+ if (N >= getBitWidth())
+ return true;
+
+ if (isSingleWord())
return VAL == (VAL & (~0ULL >> (64 - N)));
- } else {
- APInt Tmp(N, getNumWords(), pVal);
- return Tmp == (*this);
- }
+ APInt Tmp(N, getNumWords(), pVal);
+ Tmp.zext(getBitWidth());
+ return Tmp == (*this);
}
/// @brief Check if this APInt has an N-bits signed integer value.
OpenPOWER on IntegriCloud