Skip to contentSkip to conversation

MIPS FP rounding

Qemu-devel Daniel Jacobowitz 2 participants 3 messages Sep 19, 2007 – Sep 24, 2007

lore
Share & tools
lore
#0 lore raw

Thiemo, in May you added this:

-    update_fcr31();       \
+    update_fcr31();                                           \
+    if (GET_FP_CAUSE(env->fcr31) & FP_INVALID)                \
+        FST2 = 0x7fbfffff;                                    \
+    else if (GET_FP_CAUSE(env->fcr31) & FP_UNDERFLOW) {       \
+        if ((env->fcr31 & 0x3) == 0)                          \
+            FST2 &= 0x80000000ULL;                            \

+ } \

That last bit says that if underflow is detected and the rounding mode is round-to-nearest, return an signed appropriate signed zero. Why? The MIPS ISA docs say a rounded result is returned in this case, and that's what's in FST2 if that code is removed.

This shows up in the mul-subnormal-single-1.c test from GCC's ieee.exp.

Signature · 2 lines
Daniel Jacobowitz
CodeSourcery
#1 lore raw
Quoted 11 lines · Daniel Jacobowitz

Thiemo, in May you added this:

(quoted diff) +7 -1
-    update_fcr31();       \
+    update_fcr31();                                           \
+    if (GET_FP_CAUSE(env->fcr31) & FP_INVALID)                \
+        FST2 = 0x7fbfffff;                                    \
+    else if (GET_FP_CAUSE(env->fcr31) & FP_UNDERFLOW) {       \
+        if ((env->fcr31 & 0x3) == 0)                          \
+            FST2 &= 0x80000000ULL;                            \
+    }                     \
Quoted 4 lines

That last bit says that if underflow is detected and the rounding mode is round-to-nearest, return an signed appropriate signed zero. Why? The MIPS ISA docs say a rounded result is returned in this case, and that's what's in FST2 if that code is removed.

It fixed an internal testcase, I'll have to check what was going on there, probably tomorrow.

Thiemo

#2 lore raw
Quoted 2 lines · Thiemo Seufer

It fixed an internal testcase, I'll have to check what was going on there, probably tomorrow.

I don't suppose you've had a chance to look at this?

Signature · 2 lines
Daniel Jacobowitz
CodeSourcery