diff --git a/lib/SILOptimizer/Transforms/CSE.cpp b/lib/SILOptimizer/Transforms/CSE.cpp index f364108b65b..0d63e3ace6a 100644 --- a/lib/SILOptimizer/Transforms/CSE.cpp +++ b/lib/SILOptimizer/Transforms/CSE.cpp @@ -510,20 +510,7 @@ bool llvm::DenseMapInfo::isEqual(SimpleValue LHS, return true; return false; }; - auto canHandleOwnershipConversion = [](const SILInstruction *lhs, - const SILInstruction *rhs) -> bool { - if (!lhs->getFunction()->hasOwnership()) - return true; - // TODO: Support MultipleValueInstructionResult in OSSA RAUW utility and - // extend it here as well - if (!isa(lhs)) - return false; - return OwnershipFixupContext::canFixUpOwnershipForRAUW( - cast(lhs), cast(rhs)); - }; - return LHSI->getKind() == RHSI->getKind() && - LHSI->isIdenticalTo(RHSI, opCmp) && - (LHSI == RHSI || canHandleOwnershipConversion(LHSI, RHSI)); + return LHSI->getKind() == RHSI->getKind() && LHSI->isIdenticalTo(RHSI, opCmp); } namespace { @@ -1032,9 +1019,15 @@ bool CSE::processNode(DominanceInfoNode *Node) { ++NumCSE; continue; } - // Replace SingleValueInstruction using OSSA RAUW here // TODO: Support MultipleValueInstructionResult in OSSA RAUW utility and // extend it here as well + if (!isa(Inst)) + continue; + if (!OwnershipFixupContext::canFixUpOwnershipForRAUW( + cast(Inst), + cast(AvailInst))) + continue; + // Replace SingleValueInstruction using OSSA RAUW here nextI = FixupCtx.replaceAllUsesAndEraseFixingOwnership( cast(Inst), cast(AvailInst));