opt_ffinv: Harden against simple ff/inv loop.
authorMarcelina Kościelnicka <mwk@0x04.net>
Tue, 7 Jun 2022 02:26:25 +0000 (04:26 +0200)
committerMarcelina Kościelnicka <mwk@0x04.net>
Tue, 7 Jun 2022 06:20:06 +0000 (08:20 +0200)
passes/opt/opt_ffinv.cc

index fd76dd2be3ea9ad9d646b232656644a752b57158..fe5b59fa5c6401b1b9a331a9730f17c2258836f1 100644 (file)
@@ -72,6 +72,8 @@ struct OptFfInvWorker
                for (auto &port: q_ports) {
                        if (port.cell == ff.cell && port.port == ID::Q)
                                continue;
+                       if (port.cell == d_inv)
+                               return false;
                        if (port.port != ID::A)
                                return false;
                        if (!port.cell->type.in(ID($not), ID($_NOT_), ID($lut)))
@@ -148,6 +150,8 @@ struct OptFfInvWorker
                for (auto &port: q_ports) {
                        if (port.cell == ff.cell && port.port == ID::Q)
                                continue;
+                       if (port.cell == d_lut)
+                               return false;
                        if (port.port != ID::A)
                                return false;
                        if (port.cell->type.in(ID($not), ID($_NOT_))) {