diff --git a/Changes b/Changes index 2b0bb2d6f..ef975dbac 100644 --- a/Changes +++ b/Changes @@ -28,6 +28,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Fix disable iff in assertions. Closes #1404. [Peter Monsson] +**** Fix huge case statement performance. Closes #1644. [Julien Margetts] + * Verilator 4.024 2019-12-08 diff --git a/src/V3Case.cpp b/src/V3Case.cpp index a9189621c..43ec3ec39 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -210,7 +210,12 @@ private: return false; } } - if (m_caseItems <= 3) return false; // Not worth simplifying + if (m_caseItems <= 3 + // Avoid e.g. priority expanders from going crazy in expansion + || (m_caseWidth >= 8 && (m_caseItems <= (m_caseWidth + 1)))) { + return false; // Not worth simplifying + } + // Convert valueItem from AstCaseItem* to the expression // Not done earlier, as we may now have a NULL because it's just a ";" NOP branch for (uint32_t i=0; i<(1UL<