From 840e26b69a3cbd98872176577f49ea12e56b2bb9 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Mon, 17 Oct 2022 14:36:32 +0100 Subject: [PATCH] Fix incorrect return in DFG decomposition Fixes #3676 --- src/V3DfgDecomposition.cpp | 4 ++-- test_regress/t/t_dfg_3676.pl | 16 ++++++++++++++++ test_regress/t/t_dfg_3676.v | 24 ++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100755 test_regress/t/t_dfg_3676.pl create mode 100644 test_regress/t/t_dfg_3676.v diff --git a/src/V3DfgDecomposition.cpp b/src/V3DfgDecomposition.cpp index 86b6cb46f..d12e9946e 100644 --- a/src/V3DfgDecomposition.cpp +++ b/src/V3DfgDecomposition.cpp @@ -405,14 +405,14 @@ class ExtractCyclicComponents final { if (!varp->hasSinks() && varp->arity() == 0) { VL_DO_DANGLING(varp->unlinkDelete(dfg), varp); } - return; + continue; } if (DfgVarArray* const varp = vtxp->cast()) { varp->packSources(); if (!varp->hasSinks() && varp->arity() == 0) { VL_DO_DANGLING(varp->unlinkDelete(dfg), varp); } - return; + continue; } } } diff --git a/test_regress/t/t_dfg_3676.pl b/test_regress/t/t_dfg_3676.pl new file mode 100755 index 000000000..84ae125be --- /dev/null +++ b/test_regress/t/t_dfg_3676.pl @@ -0,0 +1,16 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2022 by Geza Lore. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(vlt => 1); + +compile(); + +ok(1); +1; diff --git a/test_regress/t/t_dfg_3676.v b/test_regress/t/t_dfg_3676.v new file mode 100644 index 000000000..8f01e471a --- /dev/null +++ b/test_regress/t/t_dfg_3676.v @@ -0,0 +1,24 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2022 by Geza Lore. +// SPDX-License-Identifier: CC0-1.0 + +// verilator lint_off UNOPTFLAT + +module t( + input wire [3:0] i, + output wire [2:0][3:0] o +); + + wire [2:0][3:0] v; + + // This circular logic used to trip up DFG decomposition + + assign v[0] = i; + assign v[1][0] = v[0][1] | v[0][0]; + + assign o[1][2] = v[0][2]; + assign o[2][1:0] = {v[1][0] , o[1][0]}; + +endmodule