Add a getNumSignBits() method to APInt.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126379 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Cameron Zwarich
2011-02-24 10:00:20 +00:00
parent 324a24f6aa
commit 9b6af8de58
2 changed files with 7 additions and 6 deletions

View File

@ -2088,12 +2088,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, unsigned Depth) const{
case ISD::Constant: {
const APInt &Val = cast<ConstantSDNode>(Op)->getAPIntValue();
// If negative, return # leading ones.
if (Val.isNegative())
return Val.countLeadingOnes();
// Return # leading zeros.
return Val.countLeadingZeros();
return Val.getNumSignBits();
}
case ISD::SIGN_EXTEND: