From 226ac14afb74b67007d133e3bb16ca05642b4caa Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Thu, 23 Dec 2010 23:56:24 +0000 Subject: When determining if we can fold (x >> C1) << C2, the bits that we need to verify are zero are not the low bits of x, but the bits that WILL be the low bits after the operation completes. llvm-svn: 122529 --- llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp index e3232a491b7..a0c5ef5338f 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp @@ -168,8 +168,9 @@ 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, NumBits))) + APInt::getLowBitsSet(TypeWidth, NumBits) << LowBits)) return true; } -- cgit v1.2.3