Reduce max RSS usage (#3483)
By constant folding nodes earlier in V3Expand, we can save some max RSS on large designs.
This commit is contained in:
parent
cb60663d49
commit
cfb6fd8b34
|
|
@ -3583,7 +3583,11 @@ public:
|
|||
}
|
||||
virtual ~ConstVisitor() override {
|
||||
if (m_doCpp) {
|
||||
V3Stats::addStat("Optimizations, Const bit op reduction", m_statBitOpReduction);
|
||||
if (m_globalPass) {
|
||||
V3Stats::addStat("Optimizations, Const bit op reduction", m_statBitOpReduction);
|
||||
} else {
|
||||
V3Stats::addStatSum("Optimizations, Const bit op reduction", m_statBitOpReduction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3676,6 +3680,12 @@ AstNode* V3Const::constifyEdit(AstNode* nodep) {
|
|||
return nodep;
|
||||
}
|
||||
|
||||
AstNode* V3Const::constifyEditCpp(AstNode* nodep) {
|
||||
ConstVisitor visitor{ConstVisitor::PROC_CPP, /* globalPass: */ false};
|
||||
nodep = visitor.mainAcceptEdit(nodep);
|
||||
return nodep;
|
||||
}
|
||||
|
||||
void V3Const::constifyAllLive(AstNetlist* nodep) {
|
||||
// Only call from Verilator.cpp, as it uses user#'s
|
||||
// This only pushes constants up, doesn't make any other edits
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ public:
|
|||
static void constifyCpp(AstNetlist* nodep);
|
||||
// Only the current node and lower
|
||||
// Return new node that may have replaced nodep
|
||||
static AstNode* constifyEditCpp(AstNode* nodep);
|
||||
// Only the current node and lower
|
||||
// Return new node that may have replaced nodep
|
||||
static AstNode* constifyEdit(AstNode* nodep);
|
||||
// Only the current node and lower, with special SenTree optimization
|
||||
// Return new node that may have replaced nodep
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include "V3Expand.h"
|
||||
#include "V3Stats.h"
|
||||
#include "V3Ast.h"
|
||||
#include "V3Const.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
|
@ -160,6 +161,7 @@ private:
|
|||
new AstShiftL{fl, llowp,
|
||||
new AstConst{fl, static_cast<uint32_t>(loffset)},
|
||||
VL_EDATASIZE}}};
|
||||
newp = V3Const::constifyEditCpp(newp);
|
||||
} else {
|
||||
newp = llowp;
|
||||
}
|
||||
|
|
@ -520,8 +522,9 @@ private:
|
|||
cleanmask.setMask(VL_BITBIT_E(destp->widthMin()));
|
||||
newp = new AstAnd{lfl, newp, new AstConst{lfl, cleanmask}};
|
||||
}
|
||||
|
||||
addWordAssign(nodep, w, destp, new AstOr{lfl, oldvalp, newp});
|
||||
AstNode* const orp
|
||||
= V3Const::constifyEditCpp(new AstOr{lfl, oldvalp, newp});
|
||||
addWordAssign(nodep, w, destp, orp);
|
||||
}
|
||||
}
|
||||
VL_DO_DANGLING(rhsp->deleteTree(), rhsp);
|
||||
|
|
@ -541,7 +544,8 @@ private:
|
|||
AstNode* const shifted = new AstShiftL{
|
||||
lfl, rhsp, new AstConst{lfl, static_cast<uint32_t>(lsb)}, destp->width()};
|
||||
AstNode* const cleaned = new AstAnd{lfl, shifted, new AstConst{lfl, cleanmask}};
|
||||
AstNode* const newp = new AstAssign{nfl, destp, new AstOr{lfl, oldvalp, cleaned}};
|
||||
AstNode* const orp = V3Const::constifyEditCpp(new AstOr{lfl, oldvalp, cleaned});
|
||||
AstNode* newp = new AstAssign{nfl, destp, orp};
|
||||
insertBefore(nodep, newp);
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue