From 62e877ebf018fc7b81379c578c6e10be422aa871 Mon Sep 17 00:00:00 2001 From: Yutetsu TAKATSUKASA Date: Sat, 20 Feb 2021 23:16:55 +0900 Subject: [PATCH] Add transformation of '^(const ^ a)' -> '(^const) ^ (^a)' (#2800) * Add transformation of '^(const ^ a)' -> '(^const) ^ (^a)' * Use TREEOP instead of TREEOPC --- src/V3Const.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 2d3f7e364..54e2e3785 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -2476,6 +2476,7 @@ private: TREEOPV("AstRedAnd{$lhsp.castExtend, $lhsp->width() > VN_CAST($lhsp,,Extend)->lhsp()->width()}", "replaceZero(nodep)"); // &{0,...} => 0 Prevents compiler limited range error TREEOPV("AstRedOr {$lhsp.castExtend}", "AstRedOr {$lhsp->castExtend()->lhsp()}"); TREEOPV("AstRedXor{$lhsp.castExtend}", "AstRedXor{$lhsp->castExtend()->lhsp()}"); + TREEOP ("AstRedXor{$lhsp.castXor, VN_IS(VN_CAST($lhsp,,Xor)->lhsp(),,Const)}", "AstXor{AstRedXor{$lhsp->castXor()->lhsp()}, AstRedXor{$lhsp->castXor()->rhsp()}}"); // ^(const ^ a) => (^const)^(^a) TREEOPV("AstOneHot{$lhsp.width1}", "replaceWLhs(nodep)"); TREEOPV("AstOneHot0{$lhsp.width1}", "replaceNum(nodep,1)"); // Binary AND/OR is faster than logical and/or (usually)