diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index e7020d36998..a36ac6e7474 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -187,7 +187,8 @@ public: /// not greater than 64, otherwise, just return the given uint64_t number. /// @brief Get the constant's value if possible. uint64_t getLimitedValue(uint64_t Limit) { - return (Val.getActiveBits() > 64) ? Limit : Val.getZExtValue(); + return (Val.getActiveBits() > 64 || Val.getZExtValue() > Limit) ? + Limit : Val.getZExtValue(); } /// @returns the value for an integer constant of the given type that has all