aboutsummaryrefslogtreecommitdiff
path: root/riscv/insns/fmax_d.h
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2017-10-19 12:18:23 -0700
committerAndrew Waterman <andrew@sifive.com>2017-10-19 12:18:23 -0700
commit27ffc270f4e08862606e3532a87556e2f16fa87b (patch)
tree9ec4bd52bef3ebd3ac138c514a69d03922a1d478 /riscv/insns/fmax_d.h
parenta91d9f7d89abd6cda6fafb7b5e7cacf4b3590c29 (diff)
downloadspike-27ffc270f4e08862606e3532a87556e2f16fa87b.zip
spike-27ffc270f4e08862606e3532a87556e2f16fa87b.tar.gz
spike-27ffc270f4e08862606e3532a87556e2f16fa87b.tar.bz2
Fix implementation of FMIN/FMAX NaN case
If rd=rs1 or rd=rs2, the NaN check examined the wrong value.
Diffstat (limited to 'riscv/insns/fmax_d.h')
-rw-r--r--riscv/insns/fmax_d.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/riscv/insns/fmax_d.h b/riscv/insns/fmax_d.h
index 3d2c6e6..11491f5 100644
--- a/riscv/insns/fmax_d.h
+++ b/riscv/insns/fmax_d.h
@@ -2,7 +2,8 @@ require_extension('D');
require_fp;
bool greater = f64_lt_quiet(f64(FRS2), f64(FRS1)) ||
(f64_eq(f64(FRS2), f64(FRS1)) && (f64(FRS2).v & F64_SIGN));
-WRITE_FRD(greater || isNaNF64UI(f64(FRS2).v) ? FRS1 : FRS2);
if (isNaNF64UI(f64(FRS1).v) && isNaNF64UI(f64(FRS2).v))
WRITE_FRD(f64(defaultNaNF64UI));
+else
+ WRITE_FRD(greater || isNaNF64UI(f64(FRS2).v) ? FRS1 : FRS2);
set_fp_exceptions;