Commit 306ab3e86a94b7547883ca9dac0c86122bb8622c
1 parent
6d35524c
Avoid host FPE for overflowing division on MIPS, by Richard Sandiford.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3856 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
10 additions
and
3 deletions
target-mips/op_helper.c
| @@ -230,9 +230,16 @@ void do_div (void) | @@ -230,9 +230,16 @@ void do_div (void) | ||
| 230 | void do_ddiv (void) | 230 | void do_ddiv (void) |
| 231 | { | 231 | { |
| 232 | if (T1 != 0) { | 232 | if (T1 != 0) { |
| 233 | - lldiv_t res = lldiv((int64_t)T0, (int64_t)T1); | ||
| 234 | - env->LO[0][env->current_tc] = res.quot; | ||
| 235 | - env->HI[0][env->current_tc] = res.rem; | 233 | + int64_t arg0 = (int64_t)T0; |
| 234 | + int64_t arg1 = (int64_t)T1; | ||
| 235 | + if (arg0 == ((int64_t)-1 << 63) && arg1 == (int64_t)-1) { | ||
| 236 | + env->LO[0][env->current_tc] = arg0; | ||
| 237 | + env->HI[0][env->current_tc] = 0; | ||
| 238 | + } else { | ||
| 239 | + lldiv_t res = lldiv(arg0, arg1); | ||
| 240 | + env->LO[0][env->current_tc] = res.quot; | ||
| 241 | + env->HI[0][env->current_tc] = res.rem; | ||
| 242 | + } | ||
| 236 | } | 243 | } |
| 237 | } | 244 | } |
| 238 | 245 |