Known = KnownBits::computeForAddCarry(Known, Known2, Carry);
break;
}
- case ISD::SREM:
- if (ConstantSDNode *Rem = isConstOrConstSplat(Op.getOperand(1))) {
- const APInt &RA = Rem->getAPIntValue().abs();
- if (RA.isPowerOf2()) {
- 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?");
- }
- }
+ case ISD::SREM: {
+ Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
+ Known2 = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1);
+ Known = KnownBits::srem(Known, Known2);
break;
+ }
case ISD::UREM: {
Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
Known2 = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1);