Fix skipping optimization for unpacked data types (#8031)

Signed-off-by: Kornel Uriasz <kuriasz@antmicro.com>
This commit is contained in:
Kornel Uriasz 2026-08-04 07:48:15 +02:00 committed by GitHub
parent 925a6640d1
commit 15b75c7c68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 52 additions and 0 deletions

View File

@ -438,6 +438,7 @@ class ConstBitOpTreeVisitor final : public VNVisitorConst {
// Traverse down to see AstConst or AstVarRef
LeafInfo findLeaf(AstNode* nodep, bool expectConst) {
if (!nodep->dtypep()->skipRefp()->isIntegralOrPacked()) return LeafInfo{};
LeafInfo info{m_lsb};
{
VL_RESTORER(m_leafp);

View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# 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-FileCopyrightText: 2026 Wilson Snyder
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('simulator')
test.compile()
test.execute()
test.passes()

View File

@ -0,0 +1,33 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain.
// SPDX-FileCopyrightText: 2026 Antmicro
// SPDX-License-Identifier: CC0-1.0
// This test purpose is to make sure we do not drop if conditional
// expression when trying to optimise bit operations.
module t;
class Cls;
endclass;
class subCls;
bit val = 1'b1;
Cls c;
function void check_valid();
// "c == null" shall be preserved
if (val && c == null) begin
$stop();
end
endfunction
endclass;
subCls sc;
initial begin
sc = new;
sc.c = new;
sc.check_valid();
$finish;
end
endmodule