[llvm] 8eda8f8 - [LVI][NFC] Factor solveBlockValueSaturatingIntrinsic() out of solveBlockValueIntrinsic()
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 23 08:17:54 PDT 2019
Author: Roman Lebedev
Date: 2019-10-23T18:17:33+03:00
New Revision: 8eda8f8ce85eddf24ff4dbf9783771d6b15db27c
URL: https://github.com/llvm/llvm-project/commit/8eda8f8ce85eddf24ff4dbf9783771d6b15db27c
DIFF: https://github.com/llvm/llvm-project/commit/8eda8f8ce85eddf24ff4dbf9783771d6b15db27c.diff
LOG: [LVI][NFC] Factor solveBlockValueSaturatingIntrinsic() out of solveBlockValueIntrinsic()
Now that there's SaturatingInst class, this is cleaner.
Added:
Modified:
llvm/lib/Analysis/LazyValueInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index 73d4070efcf5..f1e7c62c0a99 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,29 +1120,41 @@ 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");
More information about the llvm-commits
mailing list