]> granicus.if.org Git - llvm/commitdiff
[ValueTracking] Remove unnecessary temporary APInt from computeNumSignBitsVectorConstant.
authorCraig Topper <craig.topper@intel.com>
Sat, 21 Oct 2017 16:35:41 +0000 (16:35 +0000)
committerCraig Topper <craig.topper@intel.com>
Sat, 21 Oct 2017 16:35:41 +0000 (16:35 +0000)
We can just use getNumSignBits instead of inverting negative numbers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316266 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ValueTracking.cpp

index 244bc7d66160c4824b52450a0f4b4b21df7b95e7..182377d39c0c43237d220037fd49b5a78a17814d 100644 (file)
@@ -2097,11 +2097,7 @@ static unsigned computeNumSignBitsVectorConstant(const Value *V,
     if (!Elt)
       return 0;
 
-    // If the sign bit is 1, flip the bits, so we always count leading zeros.
-    APInt EltVal = Elt->getValue();
-    if (EltVal.isNegative())
-      EltVal = ~EltVal;
-    MinSignBits = std::min(MinSignBits, EltVal.countLeadingZeros());
+    MinSignBits = std::min(MinSignBits, Elt->getValue().getNumSignBits());
   }
 
   return MinSignBits;