diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index 15652a2b71b..07e22fc9828 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -759,6 +759,14 @@ public: /// @brief Compute the square root APInt sqrt() const; + + /// If *this is < 0 then return -(*this), otherwise *this; + /// @brief Get the absolute value; + APInt abs() const { + if (isNegative()) + return -(*this); + return *this; + } }; inline bool operator==(uint64_t V1, const APInt& V2) {