summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2008-11-02 02:41:50 +0000
committerNick Lewycky <nicholas@mxc.ca>2008-11-02 02:41:50 +0000
commit8d8acf327b97fb0165254c7d0330b4b9be9fd761 (patch)
tree8076463688cc69f5a180ab5ab3b3931346d45927 /llvm/lib/Transforms
parentf3d9f805c79355ff3e7c46dc1cf0c0095e14bca3 (diff)
downloadbcm5719-llvm-8d8acf327b97fb0165254c7d0330b4b9be9fd761.tar.gz
bcm5719-llvm-8d8acf327b97fb0165254c7d0330b4b9be9fd761.zip
Fix demanded bits analysis with srem by negative number. Based on a patch
by Richard Osborne. llvm-svn: 58555
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 75a1ffea6b5..3210b12cbb9 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -1274,12 +1274,12 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, APInt DemandedMask,
break;
case Instruction::SRem:
if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) {
- APInt RA = Rem->getValue();
- if (RA.isPowerOf2() || (-RA).isPowerOf2()) {
+ APInt RA = Rem->getValue().abs();
+ if (RA.isPowerOf2()) {
if (DemandedMask.ule(RA)) // srem won't affect demanded bits
return UpdateValueUsesWith(I, I->getOperand(0));
- APInt LowBits = RA.isStrictlyPositive() ? (RA - 1) : ~RA;
+ APInt LowBits = RA - 1;
APInt Mask2 = LowBits | APInt::getSignBit(BitWidth);
if (SimplifyDemandedBits(I->getOperand(0), Mask2,
LHSKnownZero, LHSKnownOne, Depth+1))
OpenPOWER on IntegriCloud