Sad, but there are still problems with FACOS(1) when the rounding mode is not the default = "round to nearest". It's impossible to get always exactly zero when you substract the rounded value of ASIN(1) from the non-rounded constant Pi/2. The result of ASIN(1) depends on the rounding mode, but Pi/2 does not.
That was the reason why I once forced a rounding mode (to zero) to fix this problem. The current solution is already perfect for the default rounding to nearest now. But for other user requested global rounding modes it's required to force "round to nearest" now in order to always get zero for FACOS(1) (or we would need different constants for Pi/2 for other modes).
The strange thing is that at the moment it only seems to be necessary for the Jit to force "round to nearest" for FACOS. The non-Jit code seems to ignore the user requested rounding mode. That could really be a general non-Jit bug ??
The new Jit code:
Code:
case 0x1c: /* FACOS */
#if USE_X86_FPUCW
if (regs.fpcr & 0x30) { /* not round to nearest? */
mov_l_ri (S1, (regs.fpcr & 0xC0)); /* use round to nearest */
fldcw_m_indexed (S1, uae_p32(x86_fpucw));
facos_rr (dreg, sreg);
mov_l_rm (S1, uae_p32(®s.fpcr));
and_l_ri (S1, 0xf0); /* restore control word */
fldcw_m_indexed (S1, uae_p32(x86_fpucw));
break;
}
#endif
facos_rr (dreg, sreg);
break;
I just wonder whether the code for restoring the control word could be simplified at several locations by replacing the
Code:
mov_l_rm (S1, uae_p32(®s.fpcr));
and_l_ri (S1, 0xf0); /* restore control word */
by just one instruction
Code:
mov_l_ri (S1, (regs.fpcr & 0xF0));