From c324895cbcb102d7b47c270333312c066a1fb019 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 1 Sep 2023 19:49:57 -0400 Subject: [PATCH] Internals: Remove unnecessary cloneTree. --- src/V3Const.cpp | 1 + src/V3LinkInc.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 856a13b57..0771629b4 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -1809,6 +1809,7 @@ private: VL_DO_DANGLING(nodep->deleteTree(), nodep); } void replaceConcatMerge(AstConcat* nodep) { + // {llp OP lrp, rlp OP rrp} => {llp, rlp} OP {lrp, rrp}, where OP = AND/OR/XOR AstNodeBiop* const lp = VN_AS(nodep->lhsp(), NodeBiop); AstNodeBiop* const rp = VN_AS(nodep->rhsp(), NodeBiop); AstNodeExpr* const llp = lp->lhsp()->cloneTree(false); diff --git a/src/V3LinkInc.cpp b/src/V3LinkInc.cpp index eeb339af1..3a6eb7eaf 100644 --- a/src/V3LinkInc.cpp +++ b/src/V3LinkInc.cpp @@ -263,7 +263,7 @@ private: return; } AstNodeExpr* const readp = nodep->rhsp(); - AstNodeExpr* const writep = nodep->thsp(); + AstNodeExpr* const writep = nodep->thsp()->unlinkFrBack(); AstConst* const constp = VN_AS(nodep->lhsp(), Const); UASSERT_OBJ(nodep, constp, "Expecting CONST"); @@ -295,8 +295,8 @@ private: = new AstAssign{fl, new AstVarRef{fl, varp, VAccess::WRITE}, operp}; insertNextToStmt(nodep, assignp); // Immediately after incrementing - assign it to the original variable - assignp->addNextHere(new AstAssign{fl, writep->cloneTree(true), - new AstVarRef{fl, varp, VAccess::READ}}); + assignp->addNextHere( + new AstAssign{fl, writep, new AstVarRef{fl, varp, VAccess::READ}}); } else { // PostAdd/PostSub operations // Assign the original variable to the temporary one @@ -304,7 +304,7 @@ private: readp->cloneTree(true)}; insertNextToStmt(nodep, assignp); // Increment the original variable by one - assignp->addNextHere(new AstAssign{fl, writep->cloneTree(true), operp}); + assignp->addNextHere(new AstAssign{fl, writep, operp}); } // Replace the node with the temporary