When all inputs to a $reduce_or (resp. $reduce_and) are 0 (resp 1), opt_reduce would remove them all leaving a zero width input to the cell. This can sometimes be poorly handled by other passes as in #4610, so this PR checks for that case and drives the cell by a constant.
I haven't chosen to fully replace the cell as the logic in that function would turn e.g. |{a, 1'b1, 1'b0} into |{1'b1} rather than 1'b1, so this is in keeping for the 1'b0 case. opt_expr easily eliminates this cell due to the constant input.
When all inputs to a
$reduce_or
(resp.$reduce_and
) are0
(resp1
),opt_reduce
would remove them all leaving a zero width input to the cell. This can sometimes be poorly handled by other passes as in #4610, so this PR checks for that case and drives the cell by a constant.I haven't chosen to fully replace the cell as the logic in that function would turn e.g.
|{a, 1'b1, 1'b0}
into|{1'b1}
rather than1'b1
, so this is in keeping for the1'b0
case.opt_expr
easily eliminates this cell due to the constant input.