public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Michael Morrell <mmorrell@tachyum.com>
To: "libc-alpha@sourceware.org" <libc-alpha@sourceware.org>
Subject: x86 Denormal flag
Date: Sat, 19 Jun 2021 01:09:02 +0000	[thread overview]
Message-ID: <a8a1100a9d9f40f2919969fd6c629b7a@tachyum.com> (raw)

Should fetestexcept be able to test for the denormal flag in the MXCSR?

My test case is:

define _GNU_SOURCE
#include <fenv.h>
#include <stdio.h>
#include <xmmintrin.h>

volatile float two = 2.0f;
volatile float den = 0x1.0p-130;

int main()
{
    volatile float r;

    r = den / two;

    if (_mm_getcsr() & _MM_EXCEPT_DENORM)
                printf("mxcsr has DENORM bit set\n");
    if (fetestexcept(__FE_DENORM))
                printf("DENORM is set\n");
    return 0;
}

And it shows that the Denormal flag is set in MXCSR, but fetestexcept returns 0 here.

It seems like fetestexcept only works for the 5 standard IEEE flags, but then why is __FE_DENORM even defined?

   Michael

             reply	other threads:[~2021-06-19  1:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-19  1:09 Michael Morrell [this message]
2021-06-21 20:00 ` Joseph Myers
2021-06-21 20:44   ` Michael Morrell

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=a8a1100a9d9f40f2919969fd6c629b7a@tachyum.com \
    --to=mmorrell@tachyum.com \
    --cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).