]> err.no Git - linux-2.6/commitdiff
[POWERPC] Fix rounding bug in emulation for double float operating
authorLiu Yu <b13201@freescale.com>
Mon, 10 Dec 2007 05:00:52 +0000 (13:00 +0800)
committerKumar Gala <galak@kernel.crashing.org>
Fri, 14 Dec 2007 04:59:00 +0000 (22:59 -0600)
This patch fixes rounding bug in emulation for double float operating on PowerPC platform.

When pack double float operand, it need to truncate the tail due to the limited precision.
If the truncated part is not zero, the last bit of work bit (totally 3 bits) need to '|' 1.

This patch is completed in _FP_FRAC_SRS_2(X,N,sz) (arch/powerpc/math-emu/op-2.h).
Originally the code leftwards rotates the operand to just keep the truncated part,
then check whether it is zero. However, the number it rotates is not correct when
N is not smaller than _FP_W_TYPE_SIZE, and it will cause the work bit '|' 1 in the improper case.

This patch fixes this issue.

Signed-off-by: Liu Yu <b13201@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/math-emu/op-2.h

index b9b06b4c6ea16f144cd7fa0b814770f3b272e085..7d6f17cc29295450ce7b729b176f5267b9638bbe 100644 (file)
@@ -59,7 +59,8 @@
     else                                                               \
       {                                                                        \
        X##_f0 = (X##_f1 >> ((N) - _FP_W_TYPE_SIZE) |                   \
-                 (((X##_f1 << (sz - (N))) | X##_f0) != 0));            \
+                 (((X##_f1 << (2 * _FP_W_TYPE_SIZE - (N))) |           \
+                  X##_f0) != 0));                                      \
        X##_f1 = 0;                                                     \
       }                                                                        \
   } while (0)