target/ppc: bcdsub fix sign when result is zero

When the result of bcdsub is equal to zero, the result sign may be
set to negative in some cases, and this does not follow the Power ISA
specifications as to decimal integer arithmetic instructions.

Signed-off-by: Yasmin Beatriz <yasmins@linux.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Yasmin Beatriz 2018-07-16 19:03:12 +00:00 committed by David Gibson
parent 86c0cab11a
commit 56e0e961ec
1 changed files with 3 additions and 0 deletions

View File

@ -2747,6 +2747,9 @@ uint32_t helper_bcdadd(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
result.u8[BCD_DIG_BYTE(0)] = bcd_preferred_sgn(sgna, ps);
zero = bcd_sub_mag(&result, a, b, &invalid, &overflow);
cr = (sgna > 0) ? CRF_GT : CRF_LT;
} else if (bcd_cmp_mag(a, b) == 0) {
result.u8[BCD_DIG_BYTE(0)] = bcd_preferred_sgn(0, ps);
zero = bcd_sub_mag(&result, b, a, &invalid, &overflow);
} else {
result.u8[BCD_DIG_BYTE(0)] = bcd_preferred_sgn(sgnb, ps);
zero = bcd_sub_mag(&result, b, a, &invalid, &overflow);