diff --git a/src/V3Active.cpp b/src/V3Active.cpp index 06a1d7f51..0350609cc 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -571,10 +571,11 @@ private: if (nodep->access().isWriteOnly()) { vscp->user2(true); } else { - // If the variable is read before it is written, and is not in the sensitivity list, - // then this cannot be optimized into a combinational process + // If the variable is read before it is written (and is not a never-changing value), + // and is not in the sensitivity list, then this cannot be optimized into a + // combinational process // TODO: live variable analysis would be more precise - if (!vscp->user2() && !vscp->user1()) m_canBeComb = false; + if (!vscp->user2() && !vscp->varp()->valuep() && !vscp->user1()) m_canBeComb = false; } } void visit(AstAssignDly* nodep) override { diff --git a/test_regress/t/t_case_huge.pl b/test_regress/t/t_case_huge.pl index 79a6a7976..c8266ccbc 100755 --- a/test_regress/t/t_case_huge.pl +++ b/test_regress/t/t_case_huge.pl @@ -14,9 +14,12 @@ compile( verilator_flags2 => ["--stats"], ); -if ($Self->{vlt_all}) { +if ($Self->{vlt}) { file_grep($Self->{stats}, qr/Optimizations, Tables created\s+(\d+)/i, 10); - file_grep($Self->{stats}, qr/Optimizations, Combined CFuncs\s+(\d+)/i, 0); + file_grep($Self->{stats}, qr/Optimizations, Combined CFuncs\s+(\d+)/i, 8); +} elsif ($Self->{vltmt}) { + file_grep($Self->{stats}, qr/Optimizations, Tables created\s+(\d+)/i, 10); + file_grep($Self->{stats}, qr/Optimizations, Combined CFuncs\s+(\d+)/i, 9); } execute(