public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Janne Blomqvist <blomqvist.janne@gmail.com>
To: FX Coudert <fxcoudert@gmail.com>
Cc: Steve Kargl <sgk@troutmask.apl.washington.edu>,
	fortran <fortran@gcc.gnu.org>,
	 gcc-patches@gcc.gnu.org
Subject: Re: [Fortran] half-cycle trig functions and atan[d] fixes
Date: Tue, 23 Jan 2024 13:37:54 +0200	[thread overview]
Message-ID: <CAO9iq9F8xUbRefzVQn0xV+MmZXTB_FodL-sUYz_uz+82-6ue2A@mail.gmail.com> (raw)
In-Reply-To: <AF08DC72-6BBE-4B1E-B182-A2D5EB572EC2@gmail.com>

On Tue, Jan 23, 2024 at 11:09 AM FX Coudert <fxcoudert@gmail.com> wrote:
>
> Hi Steve,

Hello, long time no see.

> Thanks for the patch. I’ll take time to do a proper review, but after a first read I had the following questions:
>
> - "an OS's libm may/will contain cospi(), etc.”: do those functions conform to any standard? Are there plans to implement them outside FreeBSD at this point?

acospi, asinpi, atan2pi, atanpi, cospi, sinpi, tanpi are all in IEEE
754-2019, and are slated to be part of C23. I would assume actively
developed libm's will eventually catch up and implement them.

> - If I get this right, to take one example, the Fortran front-end will emit a call to gfortran_acospi_r4(), libgfortran provides this as a wrapper calling acospif(), which is called either from libm or from libgfortran. This is different from other math library functions, like ACOS() where the acosf() call is generated directly from the front-end (and then the implementation comes either from libm or from libgfortran). Why not follow our usual way of doing things?

Good point, that's what we've done in c99_functions.c in libgfortran.
We should probably do this so we can skip jumping via libgfortran when
libm implements these directly.

> - On most targets, cospi() and friends are not available. Therefore, we end up doing the fallback (with limited precision as you noted) but with a lot of indirection. We could generate that code directly in the front-end, couldn’t we?

The frontend generally doesn't know what the target libm implements,
hence it's better to just generate the call, and if necessary have a
barebones implementation in libgfortran if libm doesn't implement it
properly.


-- 
Janne Blomqvist

  reply	other threads:[~2024-01-23 11:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-20 20:10 Steve Kargl
2024-01-23  9:08 ` FX Coudert
2024-01-23 11:37   ` Janne Blomqvist [this message]
2024-01-23 17:30     ` Steve Kargl
2024-01-24  6:21     ` Steve Kargl
2024-01-24  8:28       ` FX Coudert
2024-01-24  9:13         ` Janne Blomqvist
2024-01-24 17:23           ` Harald Anlauf
2024-01-24 19:28           ` Steve Kargl
2024-01-23 14:40   ` Steve Kargl
2024-01-23 17:21     ` Steve Kargl

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=CAO9iq9F8xUbRefzVQn0xV+MmZXTB_FodL-sUYz_uz+82-6ue2A@mail.gmail.com \
    --to=blomqvist.janne@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=fxcoudert@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=sgk@troutmask.apl.washington.edu \
    /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).