* x86 denormal flag handling
@ 2025-01-31 2:03 Michael Morrell
2025-01-31 10:28 ` Peter Maydell
0 siblings, 1 reply; 2+ messages in thread
From: Michael Morrell @ 2025-01-31 2:03 UTC (permalink / raw)
To: qemu-devel@nongnu.org
[-- Attachment #1: Type: text/plain, Size: 952 bytes --]
I've been following the recent changes to better support denormal handling and I don't think they are doing the right thing for x86.
I tried a simple program to convert a denormal float value (0x1.0p-127) to a double. With the default of DAZ being 0 in MXCSR, x86 sets DE, but QEMU doesn't. This is the opposite behavior of AARCH64 which sets their denormal input flag when it flushes a denormal input to 0.
Here's what I tried:
#include <stdio.h>
#include <immintrin.h>
volatile float f = 0x1.0p-127;
int main()
{
double d = f;
printf("Converting a denormal float to a double %s the DE bit in MXCSR\n",
_mm_getcsr() & _MM_EXCEPT_DENORM ? "sets" : "does not set");
return 0;
}
When run on a native machine, it prints:
Converting a denormal float to a double sets the DE bit in MXCSR
But when run using QEMU, it prints:
Converting a denormal float to a double does not set the DE bit in MXCSR
[-- Attachment #2: Type: text/html, Size: 3509 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: x86 denormal flag handling
2025-01-31 2:03 x86 denormal flag handling Michael Morrell
@ 2025-01-31 10:28 ` Peter Maydell
0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2025-01-31 10:28 UTC (permalink / raw)
To: Michael Morrell; +Cc: qemu-devel@nongnu.org
On Fri, 31 Jan 2025 at 02:03, Michael Morrell <mmorrell@tachyum.com> wrote:
>
> I’ve been following the recent changes to better support denormal handling and I don’t think they are doing the right thing for x86.
>
>
>
> I tried a simple program to convert a denormal float value (0x1.0p-127) to a double. With the default of DAZ being 0 in MXCSR, x86 sets DE, but QEMU doesn’t. This is the opposite behavior of AARCH64 which sets their denormal input flag when it flushes a denormal input to 0.
Yes. None of the changes to fix denormal handling have
actually landed in git yet, so what you see at the moment
is still the behaviour QEMU has had for years, where it
doesn't either detect "this denormal input was used without
being flushed" or set the MXCSR DE flag with the correct
semantics.
I have a work in progress branch at
https://git.linaro.org/people/peter.maydell/qemu-arm.git/log/?h=feat-afp
which has the new handling and also at the end the target/i386
changes to get the DE flag right. If you build a QEMU with
those patches then it produces the right result with your
test program.
thanks
-- PMM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-31 10:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-31 2:03 x86 denormal flag handling Michael Morrell
2025-01-31 10:28 ` Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).