diff --git a/passes/opt/wreduce.cc b/passes/opt/wreduce.cc index 9450cb329..59015707d 100644 --- a/passes/opt/wreduce.cc +++ b/passes/opt/wreduce.cc @@ -524,8 +524,11 @@ struct WreduceWorker unified_toposort.analyze_loops = false; unified_toposort.sort(); - // Process cells and wires together in unified topological order - for (auto name : unified_toposort.sorted) { + // Process cells and wires together in unified topological order (both forwards and backwards) + std::vector sorted_cells_and_wires_both_ways; + sorted_cells_and_wires_both_ways.insert(sorted_cells_and_wires_both_ways.end(), unified_toposort.sorted.begin(), unified_toposort.sorted.end()); + sorted_cells_and_wires_both_ways.insert(sorted_cells_and_wires_both_ways.end(), unified_toposort.sorted.rbegin(), unified_toposort.sorted.rend()); + for (auto name : sorted_cells_and_wires_both_ways) { Cell *c = module->cell(name); Wire *w = module->wire(name); diff --git a/tests/alumacc/macc_infer_n_unmap.ys b/tests/alumacc/macc_infer_n_unmap.ys index b05a5fe34..569511b64 100644 --- a/tests/alumacc/macc_infer_n_unmap.ys +++ b/tests/alumacc/macc_infer_n_unmap.ys @@ -11,7 +11,7 @@ prep design -save gold alumacc opt_clean -select -assert-count 2 t:$macc_v2 +select -assert-count 1 t:$macc_v2 maccmap -unmap design -copy-from gold -as gold gate equiv_make gold gate equiv