Skip to content

Commit

Permalink
Avoid host FPE for overflowing division on MIPS, by Richard Sandiford.
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3856 c046a42c-6fe2-441c-8c8c-71466251a162
  • Loading branch information
ths committed Dec 25, 2007
1 parent 6d35524 commit 306ab3e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions target-mips/op_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,16 @@ void do_div (void)
void do_ddiv (void)
{
if (T1 != 0) {
lldiv_t res = lldiv((int64_t)T0, (int64_t)T1);
env->LO[0][env->current_tc] = res.quot;
env->HI[0][env->current_tc] = res.rem;
int64_t arg0 = (int64_t)T0;
int64_t arg1 = (int64_t)T1;
if (arg0 == ((int64_t)-1 << 63) && arg1 == (int64_t)-1) {
env->LO[0][env->current_tc] = arg0;
env->HI[0][env->current_tc] = 0;
} else {
lldiv_t res = lldiv(arg0, arg1);
env->LO[0][env->current_tc] = res.quot;
env->HI[0][env->current_tc] = res.rem;
}
}
}

Expand Down

0 comments on commit 306ab3e

Please sign in to comment.