diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2019-10-23 18:05:05 +0300 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2019-10-23 18:17:33 +0300 |
commit | 8eda8f8ce85eddf24ff4dbf9783771d6b15db27c (patch) | |
tree | 32768b7e03fca316bbd5802867c6b6d5c8b91e49 /llvm/lib/Analysis/LazyValueInfo.cpp | |
parent | 1f665046fbf3b9d47a229714f689cd941f6f1216 (diff) | |
download | bcm5719-llvm-8eda8f8ce85eddf24ff4dbf9783771d6b15db27c.tar.gz bcm5719-llvm-8eda8f8ce85eddf24ff4dbf9783771d6b15db27c.zip |
[LVI][NFC] Factor solveBlockValueSaturatingIntrinsic() out of solveBlockValueIntrinsic()
Now that there's SaturatingInst class, this is cleaner.
Diffstat (limited to 'llvm/lib/Analysis/LazyValueInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/LazyValueInfo.cpp | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp index 73d4070efcf..f1e7c62c0a9 100644 --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -432,6 +432,8 @@ namespace { BasicBlock *BB); bool solveBlockValueOverflowIntrinsic( ValueLatticeElement &BBLV, WithOverflowInst *WO, BasicBlock *BB); + bool solveBlockValueSaturatingIntrinsic(ValueLatticeElement &BBLV, + SaturatingInst *SI, BasicBlock *BB); bool solveBlockValueIntrinsic(ValueLatticeElement &BBLV, IntrinsicInst *II, BasicBlock *BB); bool solveBlockValueExtractValue(ValueLatticeElement &BBLV, @@ -1118,30 +1120,42 @@ bool LazyValueInfoImpl::solveBlockValueOverflowIntrinsic( }); } -bool LazyValueInfoImpl::solveBlockValueIntrinsic( - ValueLatticeElement &BBLV, IntrinsicInst *II, BasicBlock *BB) { - switch (II->getIntrinsicID()) { +bool LazyValueInfoImpl::solveBlockValueSaturatingIntrinsic( + ValueLatticeElement &BBLV, SaturatingInst *SI, BasicBlock *BB) { + switch (SI->getIntrinsicID()) { case Intrinsic::uadd_sat: - return solveBlockValueBinaryOpImpl(BBLV, II, BB, - [](const ConstantRange &CR1, const ConstantRange &CR2) { + return solveBlockValueBinaryOpImpl( + BBLV, SI, BB, [](const ConstantRange &CR1, const ConstantRange &CR2) { return CR1.uadd_sat(CR2); }); case Intrinsic::usub_sat: - return solveBlockValueBinaryOpImpl(BBLV, II, BB, - [](const ConstantRange &CR1, const ConstantRange &CR2) { + return solveBlockValueBinaryOpImpl( + BBLV, SI, BB, [](const ConstantRange &CR1, const ConstantRange &CR2) { return CR1.usub_sat(CR2); }); case Intrinsic::sadd_sat: - return solveBlockValueBinaryOpImpl(BBLV, II, BB, - [](const ConstantRange &CR1, const ConstantRange &CR2) { + return solveBlockValueBinaryOpImpl( + BBLV, SI, BB, [](const ConstantRange &CR1, const ConstantRange &CR2) { return CR1.sadd_sat(CR2); }); case Intrinsic::ssub_sat: - return solveBlockValueBinaryOpImpl(BBLV, II, BB, - [](const ConstantRange &CR1, const ConstantRange &CR2) { + return solveBlockValueBinaryOpImpl( + BBLV, SI, BB, [](const ConstantRange &CR1, const ConstantRange &CR2) { return CR1.ssub_sat(CR2); }); default: + llvm_unreachable("All llvm.sat intrinsic are handled."); + } +} + +bool LazyValueInfoImpl::solveBlockValueIntrinsic(ValueLatticeElement &BBLV, + IntrinsicInst *II, + BasicBlock *BB) { + if (auto *SI = dyn_cast<SaturatingInst>(II)) + return solveBlockValueSaturatingIntrinsic(BBLV, SI, BB); + + switch (II->getIntrinsicID()) { + default: LLVM_DEBUG(dbgs() << " compute BB '" << BB->getName() << "' - overdefined (unknown intrinsic).\n"); BBLV = ValueLatticeElement::getOverdefined(); |