mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-03 19:02:35 +00:00
Add a getNumSignBits() method to APInt.
llvm-svn: 126379
This commit is contained in:
parent
e79a75febe
commit
af4779907f
@ -1193,6 +1193,12 @@ public:
|
||||
/// @brief Count the number of leading one bits.
|
||||
unsigned countLeadingOnes() const;
|
||||
|
||||
/// Computes the number of leading bits of this APInt that are equal to its
|
||||
/// sign bit.
|
||||
unsigned getNumSignBits() const {
|
||||
return isNegative() ? countLeadingOnes() : countLeadingZeros();
|
||||
}
|
||||
|
||||
/// countTrailingZeros - This function is an APInt version of the
|
||||
/// countTrailingZeros_{32,64} functions in MathExtras.h. It counts
|
||||
/// the number of zeros from the least significant bit to the first set bit.
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user