forked from OSchip/llvm-project
[SelectionDAG] Use KnownBits::countMinSignBits() to simplify the end of ComputeNumSignBits.
This matches what is done in ValueTracking.cpp Reviewed By: RKSimon, foad Differential Revision: https://reviews.llvm.org/D116423
This commit is contained in:
parent
d00e438cfe
commit
243b7aaf51
|
@ -4294,21 +4294,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
|
||||||
// Finally, if we can prove that the top bits of the result are 0's or 1's,
|
// Finally, if we can prove that the top bits of the result are 0's or 1's,
|
||||||
// use this information.
|
// use this information.
|
||||||
KnownBits Known = computeKnownBits(Op, DemandedElts, Depth);
|
KnownBits Known = computeKnownBits(Op, DemandedElts, Depth);
|
||||||
|
return std::max(FirstAnswer, Known.countMinSignBits());
|
||||||
APInt Mask;
|
|
||||||
if (Known.isNonNegative()) { // sign bit is 0
|
|
||||||
Mask = Known.Zero;
|
|
||||||
} else if (Known.isNegative()) { // sign bit is 1;
|
|
||||||
Mask = Known.One;
|
|
||||||
} else {
|
|
||||||
// Nothing known.
|
|
||||||
return FirstAnswer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Okay, we know that the sign bit in Mask is set. Use CLO to determine
|
|
||||||
// the number of identical bits in the top of the input value.
|
|
||||||
Mask <<= Mask.getBitWidth()-VTBits;
|
|
||||||
return std::max(FirstAnswer, Mask.countLeadingOnes());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned SelectionDAG::ComputeMinSignedBits(SDValue Op, unsigned Depth) const {
|
unsigned SelectionDAG::ComputeMinSignedBits(SDValue Op, unsigned Depth) const {
|
||||||
|
|
Loading…
Reference in New Issue