powerpc: fix e500 SPE float rounding inexactness detection
authorJoseph Myers <joseph@codesourcery.com>
Mon, 4 Nov 2013 16:53:14 +0000 (16:53 +0000)
committerScott Wood <scottwood@freescale.com>
Wed, 8 Jan 2014 00:33:48 +0000 (18:33 -0600)
commit28414a6def9dc00dcd0d0f3eea6911fda9a4a4e1
treeb47cad129a84f13e93086144c29b615012daeebe
parent640e922501103aaf2e0abb4cf4de5d49fa8342f7
powerpc: fix e500 SPE float rounding inexactness detection

The e500 SPE floating-point emulation code for the rounding modes
rounding to positive or negative infinity (which may not be
implemented in hardware) tries to avoid emulating rounding if the
result was inexact.  However, it tests inexactness using the sticky
bit with the cumulative result of previous operations, rather than
with the non-sticky bits relating to the operation that generated the
interrupt.  Furthermore, when a vector operation generates the
interrupt, it's possible that only one of the low and high parts is
inexact, and so only that part should have rounding emulated.  This
results in incorrect rounding of exact results in these modes when the
sticky bit is set from a previous operation.

(I'm not sure why the rounding interrupts are generated at all when
the result is exact, but empirically the hardware does generate them.)

This patch checks for inexactness using the correct bits of SPEFSCR,
and ensures that rounding only occurs when the relevant part of the
result was actually inexact.

Signed-off-by: Joseph Myers <joseph@codesourcery.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
arch/powerpc/math-emu/math_efp.c