3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-10 19:27:07 +00:00

proc_clean: remove any empty cases at the end of the switch.

Previously, only completely empty switches were removed.
This commit is contained in:
whitequark 2018-12-22 08:58:37 +00:00
parent ee8a7589e0
commit b784440857

View file

@ -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();
}
}
}