From bcd90d340112a0bfe89347e9e7825153325f37e5 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 26 Dec 2010 15:20:57 -0500 Subject: [PATCH] Constify LSB subtractions immediately, no functional change intended --- src/V3WidthSel.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index 0e3e3e205..0609d8aca 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -100,6 +100,13 @@ private: // have to deal with signed math and related 32bit sign extension problems if (rhs == 0) { return lhsp; + } else if (lhsp->castConst()) { + // Optional vs just making add/sub below, but saves constification some work + V3Number num (lhsp->fileline(), lhsp->width()); + num.opSub(lhsp->castConst()->num(), V3Number(lhsp->fileline(), 32, rhs)); + num.isSigned(lhsp->isSigned()); + 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,