From b784440857d6b71f46ae8784cc3767962e4edcaa Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 22 Dec 2018 08:58:37 +0000 Subject: [PATCH] proc_clean: remove any empty cases at the end of the switch. Previously, only completely empty switches were removed. --- passes/proc/proc_clean.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/passes/proc/proc_clean.cc b/passes/proc/proc_clean.cc index b9e43d1db..477d1ac60 100644 --- a/passes/proc/proc_clean.cc +++ b/passes/proc/proc_clean.cc @@ -77,18 +77,14 @@ void proc_clean_switch(RTLIL::SwitchRule *sw, RTLIL::CaseRule *parent, bool &did } else { - bool all_cases_are_empty = true; for (auto cs : sw->cases) { - if (cs->actions.size() != 0 || cs->switches.size() != 0) - all_cases_are_empty = false; if (max_depth != 0) proc_clean_case(cs, did_something, count, max_depth-1); } - if (all_cases_are_empty) { + while (!sw->cases.empty() && (sw->cases.back()->actions.empty() && sw->cases.back()->switches.empty())) { did_something = true; - for (auto cs : sw->cases) - delete cs; - sw->cases.clear(); + delete sw->cases.back(); + sw->cases.pop_back(); } } } -- 2.30.2