From b32f9254686998ef8ee9930cf820a0a708ea7f3b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 22 Dec 2011 19:08:49 -0500 Subject: [PATCH] Internals: remove extra width sets --- src/V3EmitCInlines.cpp | 9 +++++---- src/V3Premit.cpp | 1 - src/V3WidthSel.cpp | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/V3EmitCInlines.cpp b/src/V3EmitCInlines.cpp index c4a26a8ec..02f4b237d 100644 --- a/src/V3EmitCInlines.cpp +++ b/src/V3EmitCInlines.cpp @@ -48,11 +48,12 @@ class EmitCInlines : EmitCBaseVisitor { virtual void visit(AstVar* nodep, AstNUser*) { // All wide constants load into variables, so we can just hunt for them nodep->iterateChildren(*this); - if (nodep->widthWords() >= EMITCINLINES_NUM_CONSTW ) { - if (int(m_wordWidths.size()) <= nodep->widthWords()) { - m_wordWidths.resize(nodep->widthWords()+5); + int words = nodep->widthWords(); + if (words >= EMITCINLINES_NUM_CONSTW ) { + if (int(m_wordWidths.size()) <= words) { + m_wordWidths.resize(words+5); } - ++ m_wordWidths.at(nodep->widthWords()); + ++ m_wordWidths.at(words); v3Global.needHInlines(true); } } diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index 6e426e4eb..c73e35c55 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -229,7 +229,6 @@ private: constwidthp), nodep, constzerop); - newp->widthSignedFrom(nodep); replaceHandle.relink(newp); } } diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index 63c4a6f9c..e5c7712fa 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -108,14 +108,15 @@ private: AstNode* newp = new AstConst(lhsp->fileline(), num); return newp; } else if (rhs > 0) { - // We must make sure sub gets sign of original value AstNode* newp = new AstSub(lhsp->fileline(), lhsp, new AstConst(lhsp->fileline(), AstConst::Unsized32(), rhs)); + // We must make sure sub gets sign of original value newp->numericFrom(lhsp); return newp; } else { // rhs < 0; AstNode* newp = new AstAdd(lhsp->fileline(), lhsp, new AstConst(lhsp->fileline(), AstConst::Unsized32(), -rhs)); + // We must make sure sub gets sign of original value newp->numericFrom(lhsp); return newp; }