summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-03-03 23:35:36 +0000
committerDan Gohman <gohman@apple.com>2008-03-03 23:35:36 +0000
commit10f34077f16763ccc8adebf5f120264d37dcd042 (patch)
treefed01f211806b1295a2805f7f9a889eb8ecc0f83 /llvm/lib/CodeGen
parent0e238dc8132ff7ccd69c15d976908acbcd7f569e (diff)
downloadbcm5719-llvm-10f34077f16763ccc8adebf5f120264d37dcd042.tar.gz
bcm5719-llvm-10f34077f16763ccc8adebf5f120264d37dcd042.zip
More APInt-ification.
llvm-svn: 47868
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index ba202c5f22f..6f8f4818d2f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/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:
OpenPOWER on IntegriCloud