1
0
mirror of https://github.com/antonblanchard/microwatt.git synced 2026-03-08 03:29:30 +00:00

FPU: Only apply zero subtraction result sign rule when result is exactly zero

The rule in the ISA about the sign of the result of a subtraction when
the magnitude of the result is zero only applies when the operands are
equal in magnitude but opposite in sign, i.e. when the result is exactly
zero.  Add a check using FPSCR[FI] to exclude the cases where the exact
result is non-zero but gets truncated to zero by rounding.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
This commit is contained in:
Paul Mackerras
2025-12-08 14:15:24 +11:00
parent 8a204f1058
commit f252dba43d

View File

@@ -3189,7 +3189,7 @@ begin
v.writing_fpr := '1';
v.update_fprf := '1';
end if;
if r.is_subtract = '1' and v.result_class = ZERO then
if r.is_subtract = '1' and v.result_class = ZERO and v.fpscr(FPSCR_FI) = '0' then
rsign := r.round_mode(0) and r.round_mode(1);
end if;
if r.negate = '1' and v.result_class /= NAN then