mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 01:54:01 +02:00
Allow mismatched widths in operands of shifts in DFG
Fixes #3872. Testing this is a bit tricky, as the front-end fixes up the operand widths in shifts to match, and we need V3Const to introduce a mismatched one by reducing `4'd2 ** x` (with x being 2 2-bit wide signal) to `4'd1 << x`, but t_dfg_peephole runs with V3Const disabled exactly because it makes it hard to write tests. Rather than fixing this one case in V3Const (which we should do systematically at some point), I fixed DFG to accept these just in case V3Const generates more of them. The assertions were there only because of paranoia (as I thought these were not possible inputs), the code otherwise works.
This commit is contained in:
@@ -1400,26 +1400,17 @@ class V3DfgPeephole final : public DfgVisitor {
|
||||
}
|
||||
|
||||
void visit(DfgShiftL* vtxp) override {
|
||||
UASSERT_OBJ(vtxp->dtypep() == vtxp->lhsp()->dtypep(), vtxp, "Mismatched width");
|
||||
|
||||
if (foldBinary(vtxp)) return;
|
||||
|
||||
optimizeShiftRHS(vtxp);
|
||||
}
|
||||
|
||||
void visit(DfgShiftR* vtxp) override {
|
||||
UASSERT_OBJ(vtxp->dtypep() == vtxp->lhsp()->dtypep(), vtxp, "Mismatched width");
|
||||
|
||||
if (foldBinary(vtxp)) return;
|
||||
|
||||
optimizeShiftRHS(vtxp);
|
||||
}
|
||||
|
||||
void visit(DfgShiftRS* vtxp) override {
|
||||
UASSERT_OBJ(vtxp->dtypep() == vtxp->lhsp()->dtypep(), vtxp, "Mismatched width");
|
||||
|
||||
if (foldBinary(vtxp)) return;
|
||||
|
||||
optimizeShiftRHS(vtxp);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user