For div/mod only sign extend if both arguments are signed.
Only sign extend the operands for division or modulus if
both of them are signed. Previously only the individual
operand signedness was being considered.
(cherry picked from commit d074a37a2d)
This commit is contained in:
parent
fc24624fa2
commit
b9ea0036de
12
elab_expr.cc
12
elab_expr.cc
|
|
@ -419,10 +419,8 @@ NetExpr* PEBinary::elaborate_expr_base_bits_(Design*des,
|
|||
// If either of the arguments is unsigned, then process both
|
||||
// of them as unsigned. This only impacts the padding that is
|
||||
// done to get the operands to the expr_wid.
|
||||
if (! lp->has_sign())
|
||||
rp->cast_signed(false);
|
||||
if (! rp->has_sign())
|
||||
lp->cast_signed(false);
|
||||
if (! lp->has_sign()) rp->cast_signed(false);
|
||||
if (! rp->has_sign()) lp->cast_signed(false);
|
||||
|
||||
if (expr_wid > 0) {
|
||||
if (type_is_vectorable(lp->expr_type()))
|
||||
|
|
@ -453,6 +451,12 @@ NetExpr* PEBinary::elaborate_expr_base_div_(Design*des,
|
|||
}
|
||||
}
|
||||
|
||||
// If either of the arguments is unsigned, then process both
|
||||
// of them as unsigned. This only impacts the padding that is
|
||||
// done to get the operands to the expr_wid.
|
||||
if (! lp->has_sign()) rp->cast_signed(false);
|
||||
if (! rp->has_sign()) lp->cast_signed(false);
|
||||
|
||||
/* The original elaboration of the left and right expressions
|
||||
already tried to elaborate to the expr_wid. If the
|
||||
expressions are not that width by now, then they need to be
|
||||
|
|
|
|||
Loading…
Reference in New Issue