3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-07-15 11:45:41 +00:00

opt_compact_prefix: scope per-sweep clean to module, warn on non-convergence

Address review feedback on the fixpoint loop:
- Scope the per-sweep cleanup to the module under rewrite via
  Pass::call_on_module(..., "clean -purge") instead of running clean over
  the whole design selection. This avoids O(N^2) work across modules and
  keeps untouched modules' dangling cells until their own sweep, matching
  the original single-call behavior.
- Emit a log_warning if a module fails to reach a fixpoint within
  max_sweeps, so silent truncation of compaction is visible.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Akash Levy 2026-06-24 23:52:30 -07:00
parent da947b72d8
commit 139caf991c

View file

@ -1555,14 +1555,20 @@ struct OptCompactPrefixPass : public Pass
if (worker.forward_rewrites + worker.reverse_rewrites +
worker.modulo_rewrites == 0)
break;
if (sweep == max_sweeps - 1)
log_warning("opt_compact_prefix: fixpoint not reached for module %s "
"after %d sweeps; some compaction opportunities may remain.\n",
log_id(module), max_sweeps);
// Tag the cells emitted by this sweep so the next sweep skips
// them, then drop the now-dangling old cone so the masked
// sibling region becomes visible.
// sibling region becomes visible. Scope the clean to the module
// under rewrite so untouched modules keep their dangling cells
// until their own sweep, matching the original single-call run.
for (auto c : module->cells())
if (!before.count(c))
c->set_bool_attribute(ID(opt_compact_prefix_emitted));
Yosys::run_pass("clean -purge");
Pass::call_on_module(design, module, "clean -purge");
}
}