Skip to content

Commit

Permalink
[SelectionDAG] computeKnownBits - use ashrInPlace on known bits of IS…
Browse files Browse the repository at this point in the history
…D::SRA input. NFCI.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317087 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
RKSimon committed Nov 1, 2017
1 parent 2452271 commit 9fc9ff9
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2479,17 +2479,9 @@ void SelectionDAG::computeKnownBits(SDValue Op, KnownBits &Known,
case ISD::SRA:
if (const APInt *ShAmt = getValidShiftAmountConstant(Op)) {
computeKnownBits(Op.getOperand(0), Known, DemandedElts, Depth + 1);
Known.Zero.lshrInPlace(*ShAmt);
Known.One.lshrInPlace(*ShAmt);
// If we know the value of the sign bit, then we know it is copied across
// the high bits by the shift amount.
APInt SignMask = APInt::getSignMask(BitWidth);
SignMask.lshrInPlace(*ShAmt); // Adjust to where it is now in the mask.
if (Known.Zero.intersects(SignMask)) {
Known.Zero.setHighBits(ShAmt->getZExtValue());// New bits are known zero.
} else if (Known.One.intersects(SignMask)) {
Known.One.setHighBits(ShAmt->getZExtValue()); // New bits are known one.
}
// Sign extend known zero/one bit (else is unknown).
Known.Zero.ashrInPlace(*ShAmt);
Known.One.ashrInPlace(*ShAmt);
}
break;
case ISD::SIGN_EXTEND_INREG: {
Expand Down

0 comments on commit 9fc9ff9

Please sign in to comment.