From 7d0ea0d64f4e5845d78d9dc6c1757e909b0c4ada Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Tue, 19 Aug 2025 05:41:08 +0000 Subject: [PATCH] Refactor call to sorted_pmux_in to avoid copying the connection dictionary --- passes/opt/opt_merge.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/passes/opt/opt_merge.cc b/passes/opt/opt_merge.cc index 5ca19bc2f..f9ee7ba40 100644 --- a/passes/opt/opt_merge.cc +++ b/passes/opt/opt_merge.cc @@ -44,11 +44,8 @@ struct OptMergeWorker CellTypes ct; int total_count; - static vector> sorted_pmux_in(const dict &conn) + static vector> sorted_pmux_in(const SigSpec& sig_s, const SigSpec& sig_b) { - SigSpec sig_s = conn.at(ID::S); - SigSpec sig_b = conn.at(ID::B); - int s_width = GetSize(sig_s); int width = GetSize(sig_b) / s_width; @@ -104,11 +101,9 @@ struct OptMergeWorker a.sort_and_unify(); h = a.hash_into(h); } else if (cell->type == ID($pmux)) { - dict conn = cell->connections(); - assign_map.apply(conn.at(ID::A)); - assign_map.apply(conn.at(ID::B)); - assign_map.apply(conn.at(ID::S)); - for (const auto& [s_bit, b_chunk] : sorted_pmux_in(conn)) { + SigSpec sig_s = assign_map(cell->getPort(ID::S)); + SigSpec sig_b = assign_map(cell->getPort(ID::B)); + for (const auto& [s_bit, b_chunk] : sorted_pmux_in(sig_s, sig_b)) { h = s_bit.hash_into(h); h = b_chunk.hash_into(h); }