Skip to content

Commit 47f3341

Browse files
committed
RequirementMachine: Delete loops that don't have rules in empty context
When a rule is replaced by a rewrite path, if the rule is in context then every step of the replacement step is necessarily always in context. The only way new rules in empty context can be introduced by a replacement is if the original rewrite step being replaced had no context. Therefore, loops that do not contain rules in empty context will never provide any additional information during homotopy reduction.
1 parent 1bf6102 commit 47f3341

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/AST/RequirementMachine/HomotopyReduction.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,18 @@ findRuleToDelete(const llvm::DenseSet<unsigned> *redundantConformances,
384384
RewritePath &replacementPath) {
385385
SmallVector<std::pair<unsigned, unsigned>, 2> redundancyCandidates;
386386
for (unsigned loopID : indices(Loops)) {
387-
const auto &loop = Loops[loopID];
387+
auto &loop = Loops[loopID];
388388
if (loop.isDeleted())
389389
continue;
390390

391+
bool foundAny = false;
391392
for (unsigned ruleID : loop.findRulesAppearingOnceInEmptyContext(*this)) {
392393
redundancyCandidates.emplace_back(loopID, ruleID);
394+
foundAny = true;
393395
}
396+
397+
if (!foundAny)
398+
loop.markDeleted();
394399
}
395400

396401
Optional<std::pair<unsigned, unsigned>> found;

0 commit comments

Comments
 (0)