@@ -345,28 +345,26 @@ void RewriteSystem::simplifyRewriteSystem() {
345
345
assert (oldRuleID == ruleID);
346
346
(void ) oldRuleID;
347
347
348
- // Produce a loop at the simplified rhs .
348
+ // Produce a loop at the original lhs .
349
349
RewritePath loop;
350
350
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.
353
356
loop.append (rhsPath);
354
357
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.
357
359
loop.add (RewriteStep::forRewriteRule (/* startOffset=*/ 0 , /* endOffset=*/ 0 ,
358
- ruleID , /* inverse=*/ true ));
360
+ newRuleID , /* inverse=*/ true ));
359
361
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);
363
363
364
364
if (Debug.contains (DebugFlags::Completion)) {
365
365
llvm::dbgs () << " $ Right hand side simplification recorded a loop: " ;
366
- loop. dump (llvm::dbgs (), rhs , *this );
366
+ HomotopyGenerators. back (). dump (llvm::dbgs (), *this );
367
367
}
368
-
369
- HomotopyGenerators.emplace_back (rhs, loop);
370
368
}
371
369
}
372
370
0 commit comments