mirror of
https://github.com/verilator/verilator.git
synced 2026-09-07 18:06:07 +02:00
Optimize $countones constant in Dfg
This commit is contained in:
@@ -138,6 +138,7 @@ template <> const DfgDataType& resultDType<DfgXor> (const DfgVertex* lhsp
|
||||
|
||||
// Unary constant folding
|
||||
template<typename Vertex> void foldOp(V3Number& out, const V3Number& src);
|
||||
template <> void foldOp<DfgCountOnes> (V3Number& out, const V3Number& src) { out.opCountOnes(src); }
|
||||
template <> void foldOp<DfgExtend> (V3Number& out, const V3Number& src) { out.opAssign(src); }
|
||||
template <> void foldOp<DfgExtendS> (V3Number& out, const V3Number& src) { out.opExtendS(src, src.width()); }
|
||||
template <> void foldOp<DfgLogNot> (V3Number& out, const V3Number& src) { out.opLogNot(src); }
|
||||
@@ -1195,6 +1196,10 @@ class V3DfgPeephole final : public DfgVisitor {
|
||||
// DfgVertexUnary
|
||||
//=========================================================================
|
||||
|
||||
void visit(DfgCountOnes* const vtxp) override {
|
||||
if (foldUnary(vtxp)) return;
|
||||
}
|
||||
|
||||
void visit(DfgExtend* const vtxp) override {
|
||||
if (foldUnary(vtxp)) return;
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ module t (
|
||||
//verilator lint_on WIDTH
|
||||
`signal(FOLD_UNARY_Extend, tmp_FOLD_UNARY_Extend);
|
||||
`signal(FOLD_UNARY_ExtendS, tmp_FOLD_UNARY_ExtendS);
|
||||
`signal(FOLD_UNARY_CountOnes, $countones(const_a));
|
||||
`signal(FOLD_UNARY_OneHot, $onehot(const_a));
|
||||
`signal(FOLD_UNARY_OneHot0, $onehot0(const_a));
|
||||
`signal(FOLD_UNARY_OneHot_A, $onehot(const_a[0]));
|
||||
|
||||
Reference in New Issue
Block a user