From c68553cb7fc943a0b9d230348776f2d4800c8311 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 7 Jun 2017 00:58:02 +0000 Subject: [PATCH] [Constants] Use APInt::isNullValue/isOneValue/uge to simplify some code and take advantage of APInt optimizations. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304855 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Constants.h | 6 +++--- lib/IR/Constants.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/llvm/IR/Constants.h b/include/llvm/IR/Constants.h index 40a8d1eb27d..bb5e1931393 100644 --- a/include/llvm/IR/Constants.h +++ b/include/llvm/IR/Constants.h @@ -194,7 +194,7 @@ public: /// common code. It also correctly performs the comparison without the /// potential for an assertion from getZExtValue(). bool isZero() const { - return Val == 0; + return Val.isNullValue(); } /// This is just a convenience method to make client code smaller for a @@ -202,7 +202,7 @@ public: /// potential for an assertion from getZExtValue(). /// @brief Determine if the value is one. bool isOne() const { - return Val == 1; + return Val.isOneValue(); } /// This function will return true iff every bit in this constant is set @@ -243,7 +243,7 @@ public: /// @returns true iff this constant is greater or equal to the given number. /// @brief Determine if the value is greater or equal to the given number. bool uge(uint64_t Num) const { - return Val.getActiveBits() > 64 || Val.getZExtValue() >= Num; + return Val.uge(Num); } /// getLimitedValue - If the value is smaller than the specified limit, diff --git a/lib/IR/Constants.cpp b/lib/IR/Constants.cpp index 8b0ff66334a..84a57e593dc 100644 --- a/lib/IR/Constants.cpp +++ b/lib/IR/Constants.cpp @@ -127,7 +127,7 @@ bool Constant::isOneValue() const { // Check for FP which are bitcasted from 1 integers if (const ConstantFP *CFP = dyn_cast(this)) - return CFP->getValueAPF().bitcastToAPInt() == 1; + return CFP->getValueAPF().bitcastToAPInt().isOneValue(); // Check for constant vectors which are splats of 1 values. if (const ConstantVector *CV = dyn_cast(this)) -- 2.50.1