summaryrefslogtreecommitdiff
path: root/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-08-13 23:12:35 +0000
committerDan Gohman <gohman@apple.com>2008-08-13 23:12:35 +0000
commita60832b0187642d01fd726dc766cd62587f6add0 (patch)
treefa65f83dbdff0f7079cc1fe1f45241fbcb59e784 /lib/Analysis/ValueTracking.cpp
parent289983123ba4170c8a27e9638935818f8142bc89 (diff)
downloadllvm-a60832b0187642d01fd726dc766cd62587f6add0.tar.gz
llvm-a60832b0187642d01fd726dc766cd62587f6add0.tar.bz2
llvm-a60832b0187642d01fd726dc766cd62587f6add0.tar.xz
Fix a bogus srem rule - a negative value srem'd by a power-of-2
can have a non-negative result; for example, -16%16 is 0. Also, clarify the related comments. This fixes PR2670. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54767 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ValueTracking.cpp')
-rw-r--r--lib/Analysis/ValueTracking.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index e35f0d0fce..3a04f5eb86 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/lib/Analysis/ValueTracking.cpp
@@ -369,15 +369,13 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask,
ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, KnownOne2, TD,
Depth+1);
- // The sign of a remainder is equal to the sign of the first
- // operand (zero being positive).
+ // If the sign bit of the first operand is zero, the sign bit of
+ // the result is zero. If the first operand has no one bits below
+ // the second operand's single 1 bit, its sign will be zero.
if (KnownZero2[BitWidth-1] || ((KnownZero2 & LowBits) == LowBits))
KnownZero2 |= ~LowBits;
- else if (KnownOne2[BitWidth-1])
- KnownOne2 |= ~LowBits;
KnownZero |= KnownZero2 & Mask;
- KnownOne |= KnownOne2 & Mask;
assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?");
}