Optimize more always blocks in Dfg (#7775)

Optimize always blocks that:
- drive an unused variable (so logic can be pruned)
- write only a single variable (regardless of CFG size)
This commit is contained in:
Geza Lore
2026-07-05 09:24:01 +01:00
committed by GitHub
parent 1bab793c75
commit 2285e5b6da
3 changed files with 17 additions and 5 deletions
+7 -4
View File
@@ -2005,6 +2005,11 @@ static void dfgSelectLogicForSynthesis(DfgGraph& dfg) {
for (DfgVertex& vtx : dfg.opVertices()) {
DfgLogic* const logicp = vtx.cast<DfgLogic>();
if (!logicp) continue;
// If drives an unused variable, synthesize it so the partial logic can be removed
if (logicp->drivesUnusedVars()) {
worklist.push_front(*logicp);
continue;
}
// Blocks corresponding to continuous assignments
if (logicp->nodep()->keyword() == VAlwaysKwd::CONT_ASSIGN) {
worklist.push_front(*logicp);
@@ -2016,10 +2021,8 @@ static void dfgSelectLogicForSynthesis(DfgGraph& dfg) {
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);
}
// Blocks driving exactly 1 variable
if (!logicp->hasMultipleSinks()) worklist.push_front(*logicp);
}
// Now expand to cover all logic driving the same set of variables and mark