aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2020-11-05 14:29:13 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2020-11-05 14:30:59 +0000
commite237d56b43ebfbb9847648ff82aa17c3d7607481 (patch)
tree659e12414e35ba361b567993559d4386c70fec6e /llvm/lib/Analysis/ValueTracking.cpp
parent72c65b698e3af6d1826dad43cb57d4ec06844fcc (diff)
downloadllvm-e237d56b43ebfbb9847648ff82aa17c3d7607481.zip
llvm-e237d56b43ebfbb9847648ff82aa17c3d7607481.tar.gz
llvm-e237d56b43ebfbb9847648ff82aa17c3d7607481.tar.bz2
[KnownBits] Move ValueTracking/SelectionDAG UREM KnownBits handling to KnownBits::urem. NFCI.
Both these have the same implementation - so move them to a single KnownBits copy. GlobalISel will be able to use this as well with minimal effort.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp22
1 files changed, 2 insertions, 20 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 07113e18..632a5ea 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1327,29 +1327,11 @@ static void computeKnownBitsFromOperator(const Operator *I,
Known.makeNonNegative();
break;
- case Instruction::URem: {
- if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) {
- const APInt &RA = Rem->getValue();
- if (RA.isPowerOf2()) {
- APInt LowBits = (RA - 1);
- computeKnownBits(I->getOperand(0), Known, Depth + 1, Q);
- Known.Zero |= ~LowBits;
- Known.One &= LowBits;
- break;
- }
- }
-
- // Since the result is less than or equal to either operand, any leading
- // zero bits in either operand must also exist in the result.
+ case Instruction::URem:
computeKnownBits(I->getOperand(0), Known, Depth + 1, Q);
computeKnownBits(I->getOperand(1), Known2, Depth + 1, Q);
-
- unsigned Leaders =
- std::max(Known.countMinLeadingZeros(), Known2.countMinLeadingZeros());
- Known.resetAll();
- Known.Zero.setHighBits(Leaders);
+ Known = KnownBits::urem(Known, Known2);
break;
- }
case Instruction::Alloca:
Known.Zero.setLowBits(Log2(cast<AllocaInst>(I)->getAlign()));
break;