Skip to content

[NFC] Simplify DenseMapInfo<SimpleValue>::isEqual in CSE #35254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions lib/SILOptimizer/Transforms/CSE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,20 +510,7 @@ bool llvm::DenseMapInfo<SimpleValue>::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<SingleValueInstruction>(lhs))
return false;
return OwnershipFixupContext::canFixUpOwnershipForRAUW(
cast<SingleValueInstruction>(lhs), cast<SingleValueInstruction>(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 {
Expand Down Expand Up @@ -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<SingleValueInstruction>(Inst))
continue;
if (!OwnershipFixupContext::canFixUpOwnershipForRAUW(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

cast<SingleValueInstruction>(Inst),
cast<SingleValueInstruction>(AvailInst)))
continue;
// Replace SingleValueInstruction using OSSA RAUW here
nextI = FixupCtx.replaceAllUsesAndEraseFixingOwnership(
cast<SingleValueInstruction>(Inst),
cast<SingleValueInstruction>(AvailInst));
Expand Down