public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: FX <fxcoudert@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org
Subject: Re: [PATCH] fortran: Expand ieee_arithmetic module's ieee_value inline [PR106579]
Date: Tue, 16 Aug 2022 14:58:19 +0200	[thread overview]
Message-ID: <D73D25FE-C664-4E51-AE2B-40B73715FA8F@gmail.com> (raw)
In-Reply-To: <Yvqq1vVE0FkwhmXB@tucnak>

Hi,

>> Why looping over fields? The class type is a simple type with only one member (and it should be an integer, we can assert that).
> 
> I wanted to make sure it has exactly one field.
> The ieee_arithmetic.F90 module in libgfortran surely does that, but I've
> been worrying about some user overriding that module with something
> different.

In Fortran world it would be a rare and crazy thing to do, but I see. Could you add a comment (pointing out to the type definition in libgfortran)?


> The libgfortran version had default: label:
>    switch (type) \
>    { \
>      case IEEE_SIGNALING_NAN: \
>        return __builtin_nans ## SUFFIX (""); \
>      case IEEE_QUIET_NAN: \
>        return __builtin_nan ## SUFFIX (""); \
>      case IEEE_NEGATIVE_INF: \
>        return - __builtin_inf ## SUFFIX (); \
>      case IEEE_NEGATIVE_NORMAL: \
>        return -42; \
>      case IEEE_NEGATIVE_DENORMAL: \
>        return -(GFC_REAL_ ## TYPE ## _TINY) / 2; \
>      case IEEE_NEGATIVE_ZERO: \
>        return -(GFC_REAL_ ## TYPE) 0; \
>      case IEEE_POSITIVE_ZERO: \
>        return 0; \
>      case IEEE_POSITIVE_DENORMAL: \
>        return (GFC_REAL_ ## TYPE ## _TINY) / 2; \
>      case IEEE_POSITIVE_NORMAL: \
>        return 42; \
>      case IEEE_POSITIVE_INF: \
>        return __builtin_inf ## SUFFIX (); \
>      default: \
>        return 0; \
>    } \
> and I've tried to traslate that into what it generates.

OK, that makes sense. But:

> There is at least the IEEE_OTHER_VALUE (aka 0) value
> that isn't covered in the switch, but it is just an integer
> under the hood, so it could have any other value.

I think I originally included the default for IEEE_OTHER_VALUE, but the standard says IEEE_OTHER_VALUE as an argument to IEE_VALUE is not allowed. If removing the default would make the generated code shorter, I suggest we do it; otherwise let’s keep it.

With those two caveats, the patch is OK. We shouldn’t touch the library code for now, but when the patch is committed we can add the removal of IEEE_VALUE and IEEE_CLASS from the library to this list: https://gcc.gnu.org/wiki/LibgfortranAbiCleanup

FX

      reply	other threads:[~2022-08-16 12:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 10:20 Jakub Jelinek
2022-08-15 20:00 ` FX
2022-08-15 20:21   ` Jakub Jelinek
2022-08-16 12:58     ` FX [this message]

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=D73D25FE-C664-4E51-AE2B-40B73715FA8F@gmail.com \
    --to=fxcoudert@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /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).