opt_muxtree: Update port_off and port_idx even for constant bits
authorgatecat <gatecat@ds0.me>
Fri, 11 Jun 2021 10:11:12 +0000 (11:11 +0100)
committergatecat <gatecat@ds0.me>
Fri, 11 Jun 2021 11:06:35 +0000 (12:06 +0100)
Signed-off-by: gatecat <gatecat@ds0.me>
passes/opt/opt_muxtree.cc

index 8ef54cdda0d2390d423c13651be66f2dc0e9501f..100b1b4954ed29b464f5bdb5d37c75e97dace7bb 100644 (file)
@@ -372,29 +372,28 @@ struct OptMuxtreeWorker
                int port_idx = 0, port_off = 0;
                vector<int> bits = sig2bits(sig, false);
                for (int i = 0; i < GetSize(bits); i++) {
-                       if (bits[i] < 0)
-                               continue;
-                       if (knowledge.known_inactive.at(bits[i])) {
-                               sig[i] = State::S0;
-                               did_something = true;
-                       } else
-                       if (knowledge.known_active.at(bits[i])) {
-                               sig[i] = State::S1;
-                               did_something = true;
-                       }
-                       if (width) {
-                               if (ctrl_bits.count(bits[i])) {
-                                       sig[i] = ctrl_bits.at(bits[i]) == port_idx ? State::S1 : State::S0;
+                       if (bits[i] >= 0) {
+                               if (knowledge.known_inactive.at(bits[i])) {
+                                       sig[i] = State::S0;
+                                       did_something = true;
+                               } else
+                               if (knowledge.known_active.at(bits[i])) {
+                                       sig[i] = State::S1;
                                        did_something = true;
                                }
-                               if (++port_off == width)
-                                       port_idx++, port_off=0;
-                       } else {
                                if (ctrl_bits.count(bits[i])) {
-                                       sig[i] = State::S0;
+                                       if (width) {
+                                               sig[i] = ctrl_bits.at(bits[i]) == port_idx ? State::S1 : State::S0;
+                                       } else {
+                                               sig[i] = State::S0;
+                                       }
                                        did_something = true;
                                }
                        }
+                       if (width) {
+                               if (++port_off == width)
+                                       port_idx++, port_off=0;
+                       }
                }
 
                if (did_something) {