Really check that the bits that will become zero are actually already zero

before eliminating the operation that zeros them. This fixes rdar://8739316.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121353 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2010-12-09 02:52:17 +00:00
parent 1a48c032bd
commit d8e0c0438a
2 changed files with 26 additions and 3 deletions

View File

@@ -168,9 +168,8 @@ static bool CanEvaluateShifted(Value *V, unsigned NumBits, bool isLeftShift,
// We can always turn lshr(c1)+shl(c2) -> lshr(c3)+and(c4), but it isn't
// profitable unless we know the and'd out bits are already zero.
if (CI->getZExtValue() > NumBits) {
unsigned LowBits = CI->getZExtValue() - NumBits;
if (MaskedValueIsZero(I->getOperand(0),
APInt::getLowBitsSet(TypeWidth, LowBits) << NumBits))
APInt::getLowBitsSet(TypeWidth, NumBits)))
return true;
}