qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

x86 denormal flag handling


From: Michael Morrell
Subject: x86 denormal flag handling
Date: Fri, 31 Jan 2025 02:03:12 +0000

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]