Optimize straight line code in Dfg always (#7084)

This commit is contained in:
Geza Lore 2026-02-17 11:17:52 +00:00 committed by GitHub
parent 5834f22944
commit a1a9147267
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 2 deletions

View File

@ -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<DfgLogic>();
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);
}