Skip to content

Commit 0e4c398

Browse files
committed
RequirementMachine: Tweak completion loop condition
1 parent 69672cc commit 0e4c398

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/AST/RequirementMachine/KnuthBendix.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,14 @@ RewriteSystem::computeConfluentCompletion(unsigned maxRuleCount,
244244
// adding new rules in the property map's concrete type unification procedure.
245245
Complete = 1;
246246

247-
bool again = false;
247+
unsigned ruleCount;
248248

249249
std::vector<CriticalPair> resolvedCriticalPairs;
250250
std::vector<RewriteLoop> resolvedLoops;
251251

252252
do {
253+
ruleCount = Rules.size();
254+
253255
// For every rule, looking for other rules that overlap with this rule.
254256
for (unsigned i = 0, e = Rules.size(); i < e; ++i) {
255257
const auto &lhs = getRule(i);
@@ -335,9 +337,10 @@ RewriteSystem::computeConfluentCompletion(unsigned maxRuleCount,
335337
}
336338
}
337339

340+
assert(ruleCount == Rules.size());
341+
338342
simplifyLeftHandSides();
339343

340-
again = false;
341344
for (const auto &pair : resolvedCriticalPairs) {
342345
// Check if we've already done too much work.
343346
if (Rules.size() > maxRuleCount)
@@ -349,8 +352,6 @@ RewriteSystem::computeConfluentCompletion(unsigned maxRuleCount,
349352
// Check if the new rule is too long.
350353
if (Rules.back().getDepth() > maxRuleLength)
351354
return std::make_pair(CompletionResult::MaxRuleLength, Rules.size() - 1);
352-
353-
again = true;
354355
}
355356

356357
for (const auto &loop : resolvedLoops) {
@@ -362,7 +363,7 @@ RewriteSystem::computeConfluentCompletion(unsigned maxRuleCount,
362363

363364
simplifyRightHandSides();
364365
simplifyLeftHandSideSubstitutions(/*map=*/nullptr);
365-
} while (again);
366+
} while (Rules.size() > ruleCount);
366367

367368
return std::make_pair(CompletionResult::Success, 0);
368369
}

0 commit comments

Comments
 (0)