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.
This commit is contained in:
Cary R 2009-04-06 17:11:14 -07:00 committed by Stephen Williams
parent 46350da5f0
commit d074a37a2d
1 changed files with 8 additions and 4 deletions

View File

@ -419,10 +419,8 @@ NetExpr* PEBinary::elaborate_expr_base_bits_(Design*des,
// If either of the arguments is unsigned, then process both // If either of the arguments is unsigned, then process both
// of them as unsigned. This only impacts the padding that is // of them as unsigned. This only impacts the padding that is
// done to get the operands to the expr_wid. // done to get the operands to the expr_wid.
if (! lp->has_sign()) if (! lp->has_sign()) rp->cast_signed(false);
rp->cast_signed(false); if (! rp->has_sign()) lp->cast_signed(false);
if (! rp->has_sign())
lp->cast_signed(false);
if (expr_wid > 0) { if (expr_wid > 0) {
if (type_is_vectorable(lp->expr_type())) 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 /* The original elaboration of the left and right expressions
already tried to elaborate to the expr_wid. If the already tried to elaborate to the expr_wid. If the
expressions are not that width by now, then they need to be expressions are not that width by now, then they need to be