From: Yunsup Lee Date: Mon, 30 Jan 2012 22:38:23 +0000 (-0800) Subject: fix divide by zero bugs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b5f4f0ef3139b103d7406c897cb67224625f4c2b;p=riscv-isa-sim.git fix divide by zero bugs --- diff --git a/riscv/insns/divuw.h b/riscv/insns/divuw.h index 0ceb040..2cf0511 100644 --- a/riscv/insns/divuw.h +++ b/riscv/insns/divuw.h @@ -1,5 +1,5 @@ require_xpr64; -if(RS2 == 0) +if(zext32(RS2) == 0) RD = UINT64_MAX; else RD = sext32(zext32(RS1) / zext32(RS2)); diff --git a/riscv/insns/divw.h b/riscv/insns/divw.h index 51c3d80..84f42a9 100644 --- a/riscv/insns/divw.h +++ b/riscv/insns/divw.h @@ -1,5 +1,5 @@ require_xpr64; -if(RS2 == 0) +if(int32_t(RS2) == 0) RD = UINT64_MAX; else if(int32_t(RS1) == INT32_MIN && int32_t(RS2) == -1) RD = RS1; diff --git a/riscv/insns/remuw.h b/riscv/insns/remuw.h index 8234af3..1cc015d 100644 --- a/riscv/insns/remuw.h +++ b/riscv/insns/remuw.h @@ -1,5 +1,5 @@ require_xpr64; -if(RS2 == 0) +if(zext_xprlen(RS2) == 0) RD = RS1; else RD = sext32(zext_xprlen(RS1) % zext_xprlen(RS2)); diff --git a/riscv/insns/remw.h b/riscv/insns/remw.h index 93c3858..1093533 100644 --- a/riscv/insns/remw.h +++ b/riscv/insns/remw.h @@ -1,5 +1,5 @@ require_xpr64; -if(RS2 == 0) +if(int32_t(RS2) == 0) RD = RS1; else if(int32_t(RS1) == INT32_MIN && int32_t(RS2) == -1) RD = 0;