diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2020-11-05 14:55:42 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2020-11-05 14:58:33 +0000 |
commit | 6729b6de1f5b753251b4f31fd6349912d07d34ef (patch) | |
tree | 82d815dca37b27eb72c99d2a0317e6a6afa07b79 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 26a8e8502b5943cc13177bea48841491dadfef9b (diff) | |
download | llvm-6729b6de1f5b753251b4f31fd6349912d07d34ef.zip llvm-6729b6de1f5b753251b4f31fd6349912d07d34ef.tar.gz llvm-6729b6de1f5b753251b4f31fd6349912d07d34ef.tar.bz2 |
[KnownBits] Move ValueTracking SREM KnownBits handling to KnownBits::srem. NFCI.
Move the ValueTracking implementation to KnownBits, the SelectionDAG version is more limited so I'm intending to replace that as a separate commit.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 632a5ea..44cf4f8 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -1294,39 +1294,11 @@ static void computeKnownBitsFromOperator(const Operator *I, break; } case Instruction::SRem: - if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) { - APInt RA = Rem->getValue().abs(); - if (RA.isPowerOf2()) { - APInt LowBits = RA - 1; - computeKnownBits(I->getOperand(0), Known2, Depth + 1, Q); - - // The low bits of the first operand are unchanged by the srem. - Known.Zero = Known2.Zero & LowBits; - Known.One = Known2.One & LowBits; - - // If the first operand is non-negative or has all low bits zero, then - // the upper bits are all zero. - if (Known2.isNonNegative() || LowBits.isSubsetOf(Known2.Zero)) - Known.Zero |= ~LowBits; - - // If the first operand is negative and not all low bits are zero, then - // the upper bits are all one. - if (Known2.isNegative() && LowBits.intersects(Known2.One)) - Known.One |= ~LowBits; - - assert((Known.Zero & Known.One) == 0 && "Bits known to be one AND zero?"); - break; - } - } - - // The sign bit is the LHS's sign bit, except when the result of the - // remainder is zero. - computeKnownBits(I->getOperand(0), Known2, Depth + 1, Q); - // If it's known zero, our sign bit is also zero. - if (Known2.isNonNegative()) - Known.makeNonNegative(); - + computeKnownBits(I->getOperand(0), Known, Depth + 1, Q); + computeKnownBits(I->getOperand(1), Known2, Depth + 1, Q); + Known = KnownBits::srem(Known, Known2); break; + case Instruction::URem: computeKnownBits(I->getOperand(0), Known, Depth + 1, Q); computeKnownBits(I->getOperand(1), Known2, Depth + 1, Q); |