Improve opt_clean handling of unused public wires
authorClifford Wolf <clifford@clifford.at>
Wed, 26 Jun 2019 15:54:17 +0000 (17:54 +0200)
committerClifford Wolf <clifford@clifford.at>
Wed, 26 Jun 2019 15:54:17 +0000 (17:54 +0200)
Signed-off-by: Clifford Wolf <clifford@clifford.at>
passes/opt/opt_clean.cc

index 5f75288e2b00df7277a440dfe55541360c118789..a8a8e0bc7812ca472c00fb6426164758b711d964 100644 (file)
@@ -326,8 +326,8 @@ bool rmunused_module_signals(RTLIL::Module *module, bool purge_mode, bool verbos
                if (wire->port_id != 0 || wire->get_bool_attribute("\\keep") || !initval.is_fully_undef()) {
                        // do not delete anything with "keep" or module ports or initialized wires
                } else
-               if (!purge_mode && check_public_name(wire->name)) {
-                       // do not get rid of public names unless in purge mode
+               if (!purge_mode && check_public_name(wire->name) && (raw_used_signals.check_any(s1) || used_signals.check_any(s2) || s1 != s2)) {
+                       // do not get rid of public names unless in purge mode or if the wire is entirely unused, not even aliased
                } else
                if (!raw_used_signals.check_any(s1)) {
                        // delete wires that aren't used by anything directly