On 8/5/19 11:03 AM, Peter Maydell wrote: > The x86 architecture requires that all conversions from floating > point to integer which raise the 'invalid' exception (infinities of > both signs, NaN, and all values which don't fit in the destination > integer) return what the x86 spec calls the "indefinite integer > value", which is 0x8000_0000 for 32-bits or 0x8000_0000_0000_0000 for > 64-bits. The softfloat functions return the more usual behaviour of > positive overflows returning the maximum value that fits in the > destination integer format and negative overflows returning the > minimum value that fits. > > Wrap the softfloat functions in x86-specific versions which > detect the 'invalid' condition and return the indefinite integer. > > Note that we don't use these wrappers for the 3DNow! pf2id and pf2iw > instructions, which do return the minimum value that fits in > an int32 if the input float is a large negative number. > > Fixes: https://bugs.launchpad.net/qemu/+bug/1815423 > Signed-off-by: Peter Maydell <peter.mayd...@linaro.org> > --- > I've tested that this fixes the LP:1815423 test case. If anybody > has an x86 VM image to hand that has node.js installed it would > also be useful to test the operations in > https://bugs.launchpad.net/qemu/+bug/1832281 > (I don't have such a VM.) > > The other approach here would be to make the softfloat functions be > flexible enough to allow this behaviour -- from my reading of IEEE754 > I think the exact returned result for 'invalid' inputs for float to > int conversions is not specified. > > target/i386/ops_sse.h | 88 +++++++++++++++++++++++++++++-------------- > 1 file changed, 60 insertions(+), 28 deletions(-)
I guess this is exactly what we already do in fpu_helper.c. Reviewed-by: Richard Henderson <richard.hender...@linaro.org> r~