diff --git a/lib/Transforms/Scalar/MergeICmps.cpp b/lib/Transforms/Scalar/MergeICmps.cpp index d3132e793d4..f90a9937db5 100644 --- a/lib/Transforms/Scalar/MergeICmps.cpp +++ b/lib/Transforms/Scalar/MergeICmps.cpp @@ -256,11 +256,10 @@ bool BCECmpBlock::canSinkBCECmpInst(const Instruction *Inst, } // Make sure this instruction does not use any of the BCE cmp block // instructions as operand. - for (auto BI : BlockInsts) { - if (is_contained(Inst->operands(), BI)) - return false; - } - return true; + return llvm::none_of(Inst->operands(), [&](const Value *Op) { + const Instruction *OpI = dyn_cast(Op); + return OpI && BlockInsts.contains(OpI); + }); } void BCECmpBlock::split(BasicBlock *NewParent, AliasAnalysis &AA) const {