diff options
author | Dan Gohman <gohman@apple.com> | 2008-05-06 00:51:48 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-05-06 00:51:48 +0000 |
commit | 23e1df8b8d1d1fc8b9a20b80a47b0a2fdffe7f84 (patch) | |
tree | 2ff862ab8fa864b1dd691eef2ccf243d58a676ba /lib | |
parent | 703bfe69092e8da79fbef2fc5ca07b805ad9f753 (diff) | |
download | external_llvm-23e1df8b8d1d1fc8b9a20b80a47b0a2fdffe7f84.tar.gz external_llvm-23e1df8b8d1d1fc8b9a20b80a47b0a2fdffe7f84.tar.bz2 external_llvm-23e1df8b8d1d1fc8b9a20b80a47b0a2fdffe7f84.zip |
Correct the value of LowBits in srem and urem handling in
ComputeMaskedBits.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50692 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 6 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 12 |
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 26d5548617..3e75f7b305 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1560,7 +1560,7 @@ void SelectionDAG::ComputeMaskedBits(SDOperand Op, const APInt &Mask, if (ConstantSDNode *Rem = dyn_cast<ConstantSDNode>(Op.getOperand(1))) { APInt RA = Rem->getAPIntValue(); if (RA.isPowerOf2() || (-RA).isPowerOf2()) { - APInt LowBits = RA.isStrictlyPositive() ? ((RA - 1) | RA) : ~RA; + APInt LowBits = RA.isStrictlyPositive() ? (RA - 1) : ~RA; APInt Mask2 = LowBits | APInt::getSignBit(BitWidth); ComputeMaskedBits(Op.getOperand(0), Mask2,KnownZero2,KnownOne2,Depth+1); @@ -1581,8 +1581,8 @@ void SelectionDAG::ComputeMaskedBits(SDOperand Op, const APInt &Mask, case ISD::UREM: { if (ConstantSDNode *Rem = dyn_cast<ConstantSDNode>(Op.getOperand(1))) { APInt RA = Rem->getAPIntValue(); - if (RA.isStrictlyPositive() && RA.isPowerOf2()) { - APInt LowBits = (RA - 1) | RA; + if (RA.isPowerOf2()) { + APInt LowBits = (RA - 1); APInt Mask2 = LowBits & Mask; KnownZero |= ~LowBits & Mask; ComputeMaskedBits(Op.getOperand(0), Mask2, KnownZero, KnownOne,Depth+1); diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 6b1da0d256..461d5fc780 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -965,7 +965,7 @@ void InstCombiner::ComputeMaskedBits(Value *V, const APInt &Mask, if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) { APInt RA = Rem->getValue(); if (RA.isPowerOf2() || (-RA).isPowerOf2()) { - APInt LowBits = RA.isStrictlyPositive() ? ((RA - 1) | RA) : ~RA; + APInt LowBits = RA.isStrictlyPositive() ? (RA - 1) : ~RA; APInt Mask2 = LowBits | APInt::getSignBit(BitWidth); ComputeMaskedBits(I->getOperand(0), Mask2,KnownZero2,KnownOne2,Depth+1); @@ -986,8 +986,8 @@ void InstCombiner::ComputeMaskedBits(Value *V, const APInt &Mask, case Instruction::URem: { if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) { APInt RA = Rem->getValue(); - if (RA.isStrictlyPositive() && RA.isPowerOf2()) { - APInt LowBits = (RA - 1) | RA; + if (RA.isPowerOf2()) { + APInt LowBits = (RA - 1); APInt Mask2 = LowBits & Mask; KnownZero |= ~LowBits & Mask; ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero, KnownOne,Depth+1); @@ -1728,7 +1728,7 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, APInt DemandedMask, if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) { APInt RA = Rem->getValue(); if (RA.isPowerOf2() || (-RA).isPowerOf2()) { - APInt LowBits = RA.isStrictlyPositive() ? (RA - 1) | RA : ~RA; + APInt LowBits = RA.isStrictlyPositive() ? (RA - 1) : ~RA; APInt Mask2 = LowBits | APInt::getSignBit(BitWidth); if (SimplifyDemandedBits(I->getOperand(0), Mask2, LHSKnownZero, LHSKnownOne, Depth+1)) @@ -1749,8 +1749,8 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, APInt DemandedMask, case Instruction::URem: { if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) { APInt RA = Rem->getValue(); - if (RA.isStrictlyPositive() && RA.isPowerOf2()) { - APInt LowBits = (RA - 1) | RA; + if (RA.isPowerOf2()) { + APInt LowBits = (RA - 1); APInt Mask2 = LowBits & DemandedMask; KnownZero |= ~LowBits & DemandedMask; if (SimplifyDemandedBits(I->getOperand(0), Mask2, |