]> granicus.if.org Git - llvm/commitdiff
[Constants] Use APInt::isNullValue/isOneValue/uge to simplify some code and take...
authorCraig Topper <craig.topper@gmail.com>
Wed, 7 Jun 2017 00:58:02 +0000 (00:58 +0000)
committerCraig Topper <craig.topper@gmail.com>
Wed, 7 Jun 2017 00:58:02 +0000 (00:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304855 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Constants.h
lib/IR/Constants.cpp

index 40a8d1eb27d06dc53573f97e6ecae4bbb2b9317f..bb5e1931393b820abd3ae816ec49d6312a7f80c2 100644 (file)
@@ -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,
index 8b0ff66334a7e006d3c7539db9f33cb474fc1c95..84a57e593dc16cc494921fb787f009d7e2b4ba43 100644 (file)
@@ -127,7 +127,7 @@ bool Constant::isOneValue() const {
 
   // Check for FP which are bitcasted from 1 integers
   if (const ConstantFP *CFP = dyn_cast<ConstantFP>(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<ConstantVector>(this))