Internals: Reduce the number of typechecks in graphs (#4398). No functional change intended.

This commit is contained in:
Krzysztof Bieganski 2023-09-08 13:35:52 +02:00 committed by GitHub
parent fb1fc46b06
commit 139e93d371
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -176,12 +176,12 @@ public:
void setIgnoreThisStep() { m_ignoreInStep = s_stepNum; }
virtual bool followScoreboard() const = 0;
static bool followScoreboard(const V3GraphEdge* edgep) {
const SplitEdge* const oedgep = edgep->as<SplitEdge>();
const SplitEdge* const oedgep = static_cast<const SplitEdge*>(edgep);
if (oedgep->ignoreThisStep()) return false;
return oedgep->followScoreboard();
}
static bool followCyclic(const V3GraphEdge* edgep) {
const SplitEdge* const oedgep = edgep->as<SplitEdge>();
const SplitEdge* const oedgep = static_cast<const SplitEdge*>(edgep);
return (!oedgep->ignoreThisStep());
}
string dotStyle() const override {
@ -332,7 +332,7 @@ protected:
stdp->nodep()->dumpTree("- ");
}
for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) {
SplitEdge* const oedgep = edgep->as<SplitEdge>();
SplitEdge* const oedgep = static_cast<SplitEdge*>(edgep);
oedgep->setIgnoreThisStep();
}
}
@ -487,12 +487,12 @@ protected:
if (const SplitLogicVertex* const vvertexp = vertexp->cast<SplitLogicVertex>()) {
for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep;
edgep = edgep->inNextp()) {
SplitEdge* const oedgep = edgep->as<SplitEdge>();
SplitEdge* const oedgep = static_cast<SplitEdge*>(edgep);
oedgep->setIgnoreThisStep();
}
for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep;
edgep = edgep->outNextp()) {
SplitEdge* const oedgep = edgep->as<SplitEdge>();
SplitEdge* const oedgep = static_cast<SplitEdge*>(edgep);
oedgep->setIgnoreThisStep();
}
}
@ -919,7 +919,7 @@ protected:
bool pruneMe = true;
for (V3GraphEdge* edgep = logicp->outBeginp(); edgep; edgep = edgep->outNextp()) {
const SplitEdge* const oedgep = edgep->as<const SplitEdge>();
const SplitEdge* const oedgep = static_cast<const SplitEdge*>(edgep);
if (!oedgep->ignoreThisStep()) {
// This if conditional depends on something we can't
// prune -- a variable generated in the current block.
@ -929,7 +929,8 @@ protected:
// give a hint about why...
if (debug() >= 9) {
V3GraphVertex* vxp = oedgep->top();
const SplitNodeVertex* const nvxp = vxp->as<const SplitNodeVertex>();
const SplitNodeVertex* const nvxp
= static_cast<const SplitNodeVertex*>(vxp);
UINFO(0, "Cannot prune if-node due to edge "
<< oedgep << " pointing to node " << nvxp->nodep() << endl);
nvxp->nodep()->dumpTree("- ");
@ -943,7 +944,7 @@ protected:
// This if can be split; prune dependencies on it.
for (V3GraphEdge* edgep = logicp->inBeginp(); edgep; edgep = edgep->inNextp()) {
SplitEdge* const oedgep = edgep->as<SplitEdge>();
SplitEdge* const oedgep = static_cast<SplitEdge*>(edgep);
oedgep->setIgnoreThisStep();
}
}

View File

@ -223,7 +223,7 @@ private:
UINFO(9, " Mark tri " << level << " " << vtxp << endl);
if (!vtxp->varp()) { // not a var where we stop the recursion
for (V3GraphEdge* edgep = vtxp->outBeginp(); edgep; edgep = edgep->outNextp()) {
TristateVertex* const vvertexp = edgep->top()->as<TristateVertex>();
TristateVertex* const vvertexp = static_cast<TristateVertex*>(edgep->top());
// Doesn't hurt to not check if already set, but by doing so when we
// print out the debug messages, we'll see this node at level 0 instead.
if (!vvertexp->isTristate()) {
@ -235,7 +235,7 @@ private:
// A variable is tristated. Find all of the LHS VARREFs that
// drive this signal now need tristate drivers
for (V3GraphEdge* edgep = vtxp->inBeginp(); edgep; edgep = edgep->inNextp()) {
TristateVertex* const vvertexp = edgep->fromp()->as<TristateVertex>();
TristateVertex* const vvertexp = static_cast<TristateVertex*>(edgep->fromp());
if (const AstVarRef* const refp = VN_CAST(vvertexp->nodep(), VarRef)) {
if (refp->access().isWriteOrRW()
// Doesn't hurt to not check if already set, but by doing so when we
@ -260,7 +260,7 @@ private:
UINFO(9, " Mark feedstri " << level << " " << vtxp << endl);
if (!vtxp->varp()) { // not a var where we stop the recursion
for (V3GraphEdge* edgep = vtxp->inBeginp(); edgep; edgep = edgep->inNextp()) {
TristateVertex* const vvertexp = edgep->fromp()->as<TristateVertex>();
TristateVertex* const vvertexp = static_cast<TristateVertex*>(edgep->fromp());
// Doesn't hurt to not check if already set, but by doing so when we
// print out the debug messages, we'll see this node at level 0 instead.
if (!vvertexp->feedsTri()) {