From f5c54e590536c7208caf35122a78f4ef239163dc Mon Sep 17 00:00:00 2001 From: Akash Levy Date: Mon, 6 Jul 2026 13:28:54 -0700 Subject: [PATCH] opt_prienc: give each round-robin req candidate its own fingerprint budget The max_pairs budget was a single running counter shared across all req_wire iterations, so once a start-candidate-heavy first req size exhausted it, every later req size broke on its first start candidate and was silently skipped. Reset the budget per req_wire so all req sizes get a fair chance. (Completeness only; fingerprint_rr still validates every match, so this never affected correctness.) Co-authored-by: Cursor --- passes/opt/opt_prienc.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/passes/opt/opt_prienc.cc b/passes/opt/opt_prienc.cc index e7c4a966c..7231db45e 100644 --- a/passes/opt/opt_prienc.cc +++ b/passes/opt/opt_prienc.cc @@ -782,7 +782,6 @@ struct OptPriEncWorker { std::sort(req_cands.begin(), req_cands.end(), [](Wire* a, Wire* b) { return a->width > b->width; }); - int pairs = 0; bool matched = false; for (Wire* req_wire : req_cands) { if (matched) break; @@ -791,6 +790,10 @@ struct OptPriEncWorker { pool req_bits; for (auto bit : req_sig) if (bit.wire) req_bits.insert(bit); + // Per-req_wire fingerprint budget: a start-candidate-heavy + // first req size must not exhaust a shared budget and starve + // later (narrower) req sizes. + int pairs = 0; for (Wire* start_wire : start_cands) { if (start_wire == req_wire) continue; if (++pairs > max_pairs) break;