mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 01:54:01 +02:00
* Tests: Add a test to reproduce #3824 * Fix #3824 of wrong bitOpTree optimization. Consider constant 1 in an Or-tree made by shift-out.
This commit is contained in:
+7
-3
@@ -560,9 +560,13 @@ class ConstBitOpTreeVisitor final : public VNVisitor {
|
||||
if (leafInfo.lsb() <= leafInfo.msb()) {
|
||||
m_bitPolarities.emplace_back(leafInfo, isXorTree() || leafInfo.polarity(),
|
||||
leafInfo.lsb());
|
||||
} else if (isAndTree() && leafInfo.polarity()) {
|
||||
// If there is a constant 0 term in an And tree, we must include it. Fudge
|
||||
// this by adding a bit with both polarities, which will simplify to zero
|
||||
} else if ((isAndTree() && leafInfo.polarity())
|
||||
|| (isOrTree() && !leafInfo.polarity())) {
|
||||
// If there is a constant 0 term in an And tree or 1 term in an Or tree, we
|
||||
// must include it. Fudge this by adding a bit with both polarities, which
|
||||
// will simplify to zero or one respectively.
|
||||
// Note that Xor tree does not need this kind of care, polarity of Xor tree
|
||||
// is already cared when visitin AstNot. Taking xor with 1'b0 is nop.
|
||||
m_bitPolarities.emplace_back(leafInfo, true, 0);
|
||||
m_bitPolarities.emplace_back(leafInfo, false, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user