JIT64: Fix fmul rounding issues

Thanks to magumagu's softfp experiments, we know a lot more about the Wii's
strange floating point unit than we used to. In particular, when doing a
single-precision floating point multiply (fmulsx), it rounds the right hand
side's mantissa so as to lose the low 28 bits (of the 53-bit mantissa).

Emulating this behavior in Dolphin fixes a bunch of issues with games that
require extremely precise emulation of floating point hardware, especially
game replays. Fortunately, we can do this with rather little CPU cost; just ~5
extra instructions per multiply, instead of the vast load of a pure-software
float implementation.

This doesn't make floating-point behavior at all perfect. I still suspect
fmadd rounding might not be quite right, since the Wii uses fused instructions
and Dolphin doesn't, and NaN/infinity/exception handling is probably off in
various ways... but it's definitely way better than before.

This appears to fix replays in Mario Kart Wii, Mario Kart Double Dash, and
Super Smash Brothers Brawl. I wouldn't be surprised if it fixes a bunch of
other stuff too.

The changes to instructions other than fmulsx may not be strictly necessary,
but I included them for completeness, since it feels wrong to fix some
instructions but not others, since some games we didn't test might rely on
them.
OK, just wanted to make sure. Thanks!

LGTM. Please get flacs to review this since he worked on ppcfp stuff in the
past.


On Wed, Aug 20, 2014 at 7:21 AM, Fiora <notifications@github.com> wrote:

> In Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp:
>
> > @@ -111,24 +129,25 @@ void Jit64::fmaddXX(UGeckoInstruction inst)
> >  	int d = inst.FD;
> >
> >  	fpr.Lock(a, b, c, d);
> > -	MOVSD(XMM0, fpr.R(a));
> > +	MOVSD(XMM0, fpr.R(c));
> > +	Force25BitPrecision(XMM0, XMM1);
>
> I think XMM0/XMM1 are the two free registers? They're not listed in the
> reg cache's available register list, and Paired uses them in various
> instructions
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/dolphin-emu/dolphin/pull/834/files#r16459113>.
>



-- 
Pierre "delroth" Bourdon <delroth@gmail.com>
Software Engineer @ Zürich, Switzerland
http://code.delroth.net/