proc_prune: fix handling of exactly identical assigns.

Before this commit, in a process like:
   process $proc$bug.v:8$3
     assign $foo \bar
     switch \sel
       case 1'1
         assign $foo 1'1
         assign $foo 1'1
       case
         assign $foo 1'0
     end
   end
both of the "assign $foo 1'1" would incorrectly be removed.

Fixes #1243.
This commit is contained in:
whitequark 2019-08-08 05:28:01 +00:00
parent 3414ee1e3f
commit 0b09a347dc
1 changed files with 7 additions and 9 deletions

View File

@ -65,8 +65,7 @@ struct PruneWorker
pool<RTLIL::SigBit> sw_assigned = do_switch((*it), assigned, affected); pool<RTLIL::SigBit> sw_assigned = do_switch((*it), assigned, affected);
assigned.insert(sw_assigned.begin(), sw_assigned.end()); assigned.insert(sw_assigned.begin(), sw_assigned.end());
} }
pool<RTLIL::SigSig> remove; for (auto it = cs->actions.rbegin(); it != cs->actions.rend(); ) {
for (auto it = cs->actions.rbegin(); it != cs->actions.rend(); ++it) {
RTLIL::SigSpec lhs = sigmap(it->first); RTLIL::SigSpec lhs = sigmap(it->first);
bool redundant = true; bool redundant = true;
for (auto &bit : lhs) { for (auto &bit : lhs) {
@ -75,9 +74,10 @@ struct PruneWorker
break; break;
} }
} }
bool remove = false;
if (redundant) { if (redundant) {
removed_count++; removed_count++;
remove.insert(*it); remove = true;
} else { } else {
if (root) { if (root) {
bool promotable = true; bool promotable = true;
@ -99,7 +99,7 @@ struct PruneWorker
} }
promoted_count++; promoted_count++;
module->connect(conn); module->connect(conn);
remove.insert(*it); remove = true;
} }
} }
for (auto &bit : lhs) for (auto &bit : lhs)
@ -109,11 +109,9 @@ struct PruneWorker
if (bit.wire) if (bit.wire)
affected.insert(bit); affected.insert(bit);
} }
} if (remove)
for (auto it = cs->actions.begin(); it != cs->actions.end(); ) { cs->actions.erase((it++).base() - 1);
if (remove[*it]) { else it++;
it = cs->actions.erase(it);
} else it++;
} }
return assigned; return assigned;
} }