[Sorry if this is a dup.  Wasn't sure if the list was subscribers-only.]

Running the libjava testsuite for -mabi=64 on a x86_64-linux-gnu-x-mips64
QEMU causes the emulator to exit with an FPE.  The problem is that we use
lldiv for ddiv, and lldiv is undefined for both divisions by zero and for
divisions whose result is not representable.  We special-case divisions
in the first case, but we don't special-case -0x8000000000000000 / -1.

(div is OK because we use 64-bit division and truncate the result.)

I've tested this with Divide_1 on x86_64-linux-gnu- and i686-pc-linux-gnu-
hosted QEMUs.  Please install if OK.

Richard

Index: target-mips/op_helper.c
===================================================================
RCS file: /sources/qemu/qemu/target-mips/op_helper.c,v
retrieving revision 1.74
diff -u -r1.74 op_helper.c
--- target-mips/op_helper.c	18 Nov 2007 14:33:24 -0000	1.74
+++ target-mips/op_helper.c	19 Dec 2007 17:31:23 -0000
@@ -230,9 +237,16 @@
 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;
+        }
     }
 }
 

Reply via email to