qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Morrell <mmorrell@tachyum.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: x86 denormal flag handling
Date: Fri, 31 Jan 2025 02:03:12 +0000	[thread overview]
Message-ID: <96e999333e9b49fcb60f051a29d41c83@tachyum.com> (raw)

[-- 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 --]

             reply	other threads:[~2025-01-31  2:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-31  2:03 Michael Morrell [this message]
2025-01-31 10:28 ` x86 denormal flag handling Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=96e999333e9b49fcb60f051a29d41c83@tachyum.com \
    --to=mmorrell@tachyum.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).