diff options
author | Dan Gohman <gohman@apple.com> | 2008-03-03 23:35:36 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-03-03 23:35:36 +0000 |
commit | bb271ff9fe1b92e8c0fdb54334f92803b344ee6a (patch) | |
tree | be1c02499d809ee2b3d9d543ff6a80ab91ae6cde /lib | |
parent | 3370dd70aebf6b3c92d84c20245078c00290dffa (diff) |
More APInt-ification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47868 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index ba202c5f22..6f8f4818d2 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1518,17 +1518,13 @@ unsigned SelectionDAG::ComputeNumSignBits(SDOperand Op, unsigned Depth) const{ return VTBits-Tmp; case ISD::Constant: { - uint64_t Val = cast<ConstantSDNode>(Op)->getValue(); - // If negative, invert the bits, then look at it. - if (Val & MVT::getIntVTSignBit(VT)) - Val = ~Val; + const APInt &Val = cast<ConstantSDNode>(Op)->getAPIntValue(); + // If negative, return # leading ones. + if (Val.isNegative()) + return Val.countLeadingOnes(); - // Shift the bits so they are the leading bits in the int64_t. - Val <<= 64-VTBits; - - // Return # leading zeros. We use 'min' here in case Val was zero before - // shifting. We don't want to return '64' as for an i32 "0". - return std::min(VTBits, CountLeadingZeros_64(Val)); + // Return # leading zeros. + return Val.countLeadingZeros(); } case ISD::SIGN_EXTEND: |