diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/EarlyCSE.cpp | 11 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 8 |
2 files changed, 8 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp index c453c843bfc..2e00d676f15 100644 --- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp +++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp @@ -555,15 +555,8 @@ bool EarlyCSE::processNode(DomTreeNode *Node) { } if (match(Inst, m_Intrinsic<Intrinsic::experimental_guard>())) { - Value *Cond = cast<CallInst>(Inst)->getArgOperand(0); - - if (match(Cond, m_One())) { - // Elide guards on true, since operationally they're no-ops. In the - // future we can consider more sophisticated tradeoffs here with - // consideration to potential for check widening, but for now we keep - // things simple. - Inst->eraseFromParent(); - } else if (auto *CondI = dyn_cast<Instruction>(Cond)) { + if (auto *CondI = + dyn_cast<Instruction>(cast<CallInst>(Inst)->getArgOperand(0))) { // The condition we're on guarding here is true for all dominated // locations. if (SimpleValue::canHandle(CondI)) diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 82961a678be..5af3712a3ab 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -321,8 +321,12 @@ bool llvm::isInstructionTriviallyDead(Instruction *I, II->getIntrinsicID() == Intrinsic::lifetime_end) return isa<UndefValue>(II->getArgOperand(1)); - // Assumptions are dead if their condition is trivially true. - if (II->getIntrinsicID() == Intrinsic::assume) { + // Assumptions are dead if their condition is trivially true. Guards on + // true are operationally no-ops. In the future we can consider more + // sophisticated tradeoffs for guards considering potential for check + // widening, but for now we keep things simple. + if (II->getIntrinsicID() == Intrinsic::assume || + II->getIntrinsicID() == Intrinsic::experimental_guard) { if (ConstantInt *Cond = dyn_cast<ConstantInt>(II->getArgOperand(0))) return !Cond->isZero(); |

