Fix exponential expansion in V3Gate (#7550)

Unfortunate constellation of combinational assignments could be inlined
by V3Gate yielding an exponential expansion (added test used to consume
4GB+ memory and generate 3GB+ code).
This commit is contained in:
Geza Lore
2026-05-07 22:01:08 -05:00
committed by GitHub
parent db8b6ce26d
commit 7c5069c7df
5 changed files with 80 additions and 13 deletions
+7 -1
View File
@@ -693,7 +693,9 @@ class GateInline final {
for (V3GraphEdge& edge : vVtxp->outEdges()) {
const GateLogicVertex* const dstVtxp = edge.top()->as<GateLogicVertex>();
// Ignore slow code, or if the destination is not used
if (!dstVtxp->slow() && !dstVtxp->outEmpty()) n += edge.weight();
if (dstVtxp->slow()) continue;
if (dstVtxp->outEmpty() && !dstVtxp->consumed()) continue;
n += edge.weight();
if (n > 1) break;
}
if (n > 1) continue;
@@ -1308,6 +1310,10 @@ void V3Gate::gateAll(AstNetlist* netlistp) {
graphp->removeRedundantEdgesSum(&V3GraphEdge::followAlwaysTrue);
if (dumpGraphLevel() >= 6) graphp->dumpDotFilePrefixed("gate_simp");
// Remove unused logic
GateUnused::apply(*graphp);
if (dumpGraphLevel() >= 3) graphp->dumpDotFilePrefixed("gate_unused");
// Inline variables
GateInline::apply(*graphp);
if (dumpGraphLevel() >= 6) graphp->dumpDotFilePrefixed("gate_inline");