qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* 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

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).