From 139caf991ca4168d5abbd5d573c4d884affc34ed Mon Sep 17 00:00:00 2001 From: Akash Levy Date: Wed, 24 Jun 2026 23:52:30 -0700 Subject: [PATCH] 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 --- passes/silimate/opt_compact_prefix.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/passes/silimate/opt_compact_prefix.cc b/passes/silimate/opt_compact_prefix.cc index 20fafeda6..fdc902a64 100644 --- a/passes/silimate/opt_compact_prefix.cc +++ b/passes/silimate/opt_compact_prefix.cc @@ -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"); } }