From a1a9147267e46ae90e956274df552e0421162379 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Tue, 17 Feb 2026 11:17:52 +0000 Subject: [PATCH] Optimize straight line code in Dfg always (#7084) --- src/V3DfgSynthesize.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/V3DfgSynthesize.cpp b/src/V3DfgSynthesize.cpp index 4d61af374..dd7a05292 100644 --- a/src/V3DfgSynthesize.cpp +++ b/src/V3DfgSynthesize.cpp @@ -1922,16 +1922,22 @@ static void dfgSelectLogicForSynthesis(DfgGraph& dfg) { }); } - // Synthesize all continuous assignments and simple blocks driving exactly - // one variable. This is approximately the old default behaviour of Dfg. + // Choose some simple special cases to always synthesize for (DfgVertex& vtx : dfg.opVertices()) { DfgLogic* const logicp = vtx.cast(); if (!logicp) continue; + // Blocks corresponding to continuous assignments if (logicp->nodep()->keyword() == VAlwaysKwd::CONT_ASSIGN) { worklist.push_front(*logicp); continue; } const CfgGraph& cfg = logicp->cfg(); + // Straight line code with no branches + if (cfg.nBlocks() == 1) { + worklist.push_front(*logicp); + continue; + } + // Simple blocks driving exactly 1 variable, e.g if (rst) a = b else a = c; if (!logicp->hasMultipleSinks() && cfg.nBlocks() <= 4 && cfg.nEdges() <= 4) { worklist.push_front(*logicp); }