Skip to content

Commit e7b0b1b

Browse files
committed
RequirementMachine: Right-hand side simplification produces more aesthetically-pleasing 3-cells
1 parent 62c9347 commit e7b0b1b

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

lib/AST/RequirementMachine/RewriteSystem.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -345,28 +345,26 @@ void RewriteSystem::simplifyRewriteSystem() {
345345
assert(oldRuleID == ruleID);
346346
(void) oldRuleID;
347347

348-
// Produce a loop at the simplified rhs.
348+
// Produce a loop at the original lhs.
349349
RewritePath loop;
350350

351-
// (1) First, apply rhsPath in reverse to produce the original rhs.
352-
rhsPath.invert();
351+
// (1) First, apply the original rule to produce the original rhs.
352+
loop.add(RewriteStep::forRewriteRule(/*startOffset=*/0, /*endOffset=*/0,
353+
ruleID, /*inverse=*/false));
354+
355+
// (2) Next, apply rhsPath to produce the simplified rhs.
353356
loop.append(rhsPath);
354357

355-
// (2) Next, apply the original rule in reverse to produce the
356-
// original lhs.
358+
// (3) Finally, apply the new rule in reverse to produce the original lhs.
357359
loop.add(RewriteStep::forRewriteRule(/*startOffset=*/0, /*endOffset=*/0,
358-
ruleID, /*inverse=*/true));
360+
newRuleID, /*inverse=*/true));
359361

360-
// (3) Finally, apply the new rule to produce the simplified rhs.
361-
loop.add(RewriteStep::forRewriteRule(/*startOffset=*/0, /*endOffset=*/0,
362-
newRuleID, /*inverse=*/false));
362+
HomotopyGenerators.emplace_back(MutableTerm(lhs), loop);
363363

364364
if (Debug.contains(DebugFlags::Completion)) {
365365
llvm::dbgs() << "$ Right hand side simplification recorded a loop: ";
366-
loop.dump(llvm::dbgs(), rhs, *this);
366+
HomotopyGenerators.back().dump(llvm::dbgs(), *this);
367367
}
368-
369-
HomotopyGenerators.emplace_back(rhs, loop);
370368
}
371369
}
372370

0 commit comments

Comments
 (0)