mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
[DAG] computeKnownBits - Replace ISD::SREM handling with KnownBits::srem to reduce code duplication
This commit is contained in:
parent
ba9ef76ad5
commit
6d3173c2b6
@ -3249,30 +3249,12 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
|
|||||||
Known = KnownBits::computeForAddCarry(Known, Known2, Carry);
|
Known = KnownBits::computeForAddCarry(Known, Known2, Carry);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ISD::SREM:
|
case ISD::SREM: {
|
||||||
if (ConstantSDNode *Rem = isConstOrConstSplat(Op.getOperand(1))) {
|
Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
|
||||||
const APInt &RA = Rem->getAPIntValue().abs();
|
Known2 = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1);
|
||||||
if (RA.isPowerOf2()) {
|
Known = KnownBits::srem(Known, Known2);
|
||||||
APInt LowBits = RA - 1;
|
|
||||||
Known2 = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
|
|
||||||
|
|
||||||
// The low bits of the first operand are unchanged by the srem.
|
|
||||||
Known.Zero = Known2.Zero & LowBits;
|
|
||||||
Known.One = Known2.One & LowBits;
|
|
||||||
|
|
||||||
// If the first operand is non-negative or has all low bits zero, then
|
|
||||||
// the upper bits are all zero.
|
|
||||||
if (Known2.isNonNegative() || LowBits.isSubsetOf(Known2.Zero))
|
|
||||||
Known.Zero |= ~LowBits;
|
|
||||||
|
|
||||||
// If the first operand is negative and not all low bits are zero, then
|
|
||||||
// the upper bits are all one.
|
|
||||||
if (Known2.isNegative() && LowBits.intersects(Known2.One))
|
|
||||||
Known.One |= ~LowBits;
|
|
||||||
assert((Known.Zero & Known.One) == 0&&"Bits known to be one AND zero?");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ISD::UREM: {
|
case ISD::UREM: {
|
||||||
Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
|
Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
|
||||||
Known2 = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1);
|
Known2 = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user