Only init modwalker once.

This commit is contained in:
nella
2026-08-05 12:57:56 +02:00
committed by nella
parent eff7e1f360
commit fae99416d4
+14 -4
View File
@@ -150,6 +150,16 @@ struct OptDffWorker
SatEffortBudget sat_budget; SatEffortBudget sat_budget;
bool sat_warned = false; bool sat_warned = false;
// modwalker is expensive to build, so share one lazily between constbits and eqbits
std::unique_ptr<ModWalker> modwalker_ptr;
ModWalker &get_modwalker()
{
if (!modwalker_ptr)
modwalker_ptr = std::make_unique<ModWalker>(module->design, module);
return *modwalker_ptr;
}
bool warn_if_budget_spent() bool warn_if_budget_spent()
{ {
if (!sat_budget.spent()) if (!sat_budget.spent())
@@ -996,13 +1006,13 @@ struct OptDffWorker
bool run_constbits() bool run_constbits()
{ {
// Find FFs that are provably constant // Find FFs that are provably constant
ModWalker modwalker(module->design, module); ModWalker &modwalker = get_modwalker();
dict<Cell *, pool<int>> const_bits; dict<Cell *, pool<int>> const_bits;
bool did_something = false; bool did_something = false;
// Fold constant D/AD inputs into the tested value directly bits whose remaining inputs are // fold constant D/AD inputs into the tested value first
// wires become SAT proof obligations // bits whose remaining inputs are wires become SAT proof obligations
std::vector<ConstObligation> obligations; std::vector<ConstObligation> obligations;
for (auto cell : module->selected_cells()) { for (auto cell : module->selected_cells()) {
@@ -1562,7 +1572,7 @@ struct OptDffWorker
if (classes.empty()) if (classes.empty())
return false; return false;
ModWalker modwalker(module->design, module); ModWalker &modwalker = get_modwalker();
// Simulation prepass // Simulation prepass
classes = filter_classes_sim(classes, bits, ff_for_cell, modwalker); classes = filter_classes_sim(classes, bits, ff_for_cell, modwalker);