Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220104211202.GB1320090@port70.net>
Date: Tue, 4 Jan 2022 22:12:02 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: Paul Zimmermann <Paul.Zimmermann@...ia.fr>
Cc: Rich Felker <dalias@...c.org>, musl@...ts.openwall.com, sibid@...c.ca,
	christoph.lauter@...istoph-lauter.org,
	Jean-Michel.Muller@...-LYON.FR
Subject: Re: correctly rounded mathematical functions

* Paul Zimmermann <Paul.Zimmermann@...ia.fr> [2022-01-04 15:19:48 +0100]:
> > Is there a standalone version of the code where it can be read in full
> > not as a patch to glibc? Is the code being developed in such a way
> > that it's not potentially a derivative work of the glibc versions?
> 
> yes there are several standalone versions of the code (entries marked "full"
> on https://homepages.loria.fr/PZimmermann/CORE-MATH/).

i only looked at cr_asinf:

  float
  cr_asinf (float x)
  {
    /* deal here with NaN, +Inf and -Inf */

yeah that can be tricky and different across math libs.
(errno vs no errno, wrapper to handle special cases vs no wrapper etc)

to minimize branches you may want to merge it with the |x|>1 check below.

    double absx = fabsf (x), y;
    if (absx > 1)
      return sqrt (-1.0); /* NaN */
    ...

this reminds me that musl does not use compiler builtins at build time,
which means fabsf, sqrt are extern calls, which means this will not be
a leaf function (note: sqrt is not a tail call here because of the
implicit conversion, i think it should be sqrtf).

i prefer to tail call a function with descriptive name when handling
errors, but it does not always work out well: e.g. underflow can be
tricky if you want to ensure that an exact subnormal result does not
raise it (e.g. powf(2, -140)), but inexact does.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.