diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-06-04 16:24:09 +0000 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-06-04 16:24:09 +0000 |
commit | df621bdfc86e8f1891a39a33edf263ac17058500 (patch) | |
tree | 93c7d31d93b702719013c7616a93bf6c4167a1c9 /llvm/lib/Analysis/LazyValueInfo.cpp | |
parent | af11a4376c1123b5d0f343645c66e8c5d2c7b14a (diff) | |
download | bcm5719-llvm-df621bdfc86e8f1891a39a33edf263ac17058500.tar.gz bcm5719-llvm-df621bdfc86e8f1891a39a33edf263ac17058500.zip |
[LVI][CVP] Add support for urem, srem and sdiv
The underlying ConstantRange functionality has been added in D60952,
D61207 and D61238, this just exposes it for LVI.
I'm switching the code from using a whitelist to a blacklist, as
we're down to one unsupported operation here (xor) and writing it
this way seems more obvious :)
Differential Revision: https://reviews.llvm.org/D62822
llvm-svn: 362519
Diffstat (limited to 'llvm/lib/Analysis/LazyValueInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/LazyValueInfo.cpp | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp index 280dd3ea604..53e9f49a571 100644 --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -1082,31 +1082,18 @@ bool LazyValueInfoImpl::solveBlockValueBinaryOp(ValueLatticeElement &BBLV, assert(BO->getOperand(0)->getType()->isSized() && "all operands to binary operators are sized"); - - // Filter out operators we don't know how to reason about before attempting to - // recurse on our operand(s). This can cut a long search short if we know - // we're not going to be able to get any useful information anyways. - switch (BO->getOpcode()) { - case Instruction::Add: - case Instruction::Sub: - case Instruction::Mul: - case Instruction::UDiv: - case Instruction::Shl: - case Instruction::LShr: - case Instruction::AShr: - case Instruction::And: - case Instruction::Or: - return solveBlockValueBinaryOpImpl(BBLV, BO, BB, - [BO](const ConstantRange &CR1, const ConstantRange &CR2) { - return CR1.binaryOp(BO->getOpcode(), CR2); - }); - default: - // Unhandled instructions are overdefined. + if (BO->getOpcode() == Instruction::Xor) { + // Xor is the only operation not supported by ConstantRange::binaryOp(). LLVM_DEBUG(dbgs() << " compute BB '" << BB->getName() << "' - overdefined (unknown binary operator).\n"); BBLV = ValueLatticeElement::getOverdefined(); return true; - }; + } + + return solveBlockValueBinaryOpImpl(BBLV, BO, BB, + [BO](const ConstantRange &CR1, const ConstantRange &CR2) { + return CR1.binaryOp(BO->getOpcode(), CR2); + }); } bool LazyValueInfoImpl::solveBlockValueOverflowIntrinsic( |