Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 01 Apr 2026 10:09:00 +0200
From:      Paul Zimmermann <Paul.Zimmermann@inria.fr>
To:        lwhsu@FreeBSD.org
Cc:        numerics@FreeBSD.org
Subject:   Re: [Bug 216865] math powl(3) uses a poor algorithm due to clang kludge
Message-ID:  <p9u0se9fxftv.fsf@thym>
In-Reply-To: <bug-216865-18636-GRFuCnlbBE@https.bugs.freebsd.org/bugzilla/> (bugzilla-noreply@freebsd.org)
References:  <bug-216865-18636@https.bugs.freebsd.org/bugzilla/> <bug-216865-18636-GRFuCnlbBE@https.bugs.freebsd.org/bugzilla/>

index | next in thread | previous in thread | raw e-mail

       Hi Li-Wen,

great! I will test that in our next comparison of mathematical functions.
Did you check #292988 is also fixed?

Did you also check the new version is thread-safe?
Cf https://github.com/JuliaMath/openlibm/issues/222
(the old code is the same as the same as in OpenLibm I believe).

If you want to test by yourself, you can do the following:

get https://gitlab.inria.fr/zimmerma/math_accuracy/-/blob/master/binary64/check_sample2.c
and do the following (you will also need to get random.c at the same place):

cc -O3 -c random.c
cc -DNO_FLOAT128 -I/host/include -L/host/lib -O3 -DFOO=pow -DFREEBSD -DWORST -DUSE_LDOUBLE -O3 check_sample2.c -lm -lmpfr -fopenmp
./a.out -threshold 1000

then you should get a "NEW" line like (here for double precision)
with hopefully a largest ulp error (here 0.504815) less than Inf:

NEW pow 0 12 0x1.b8fa241e68c0ep-434,0x1.4ec0af8e9feb1p-18 [0.505] 0.504815

then replace the x,y values in line 1424 of check_sample2.c by the new values,
recompile check_sample2.c and run again (feel free to increase the threshold
value if you want).

Paul Zimmermann

> From: bugzilla-noreply@freebsd.org
> Date: Wed, 01 Apr 2026 07:07:15 +0000
> 
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216865
> 
> Li-Wen Hsu <lwhsu@FreeBSD.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>          Resolution|---                         |FIXED
>              Status|New                         |Closed
>                  CC|                            |lwhsu@FreeBSD.org
> 
> --- Comment #1 from Li-Wen Hsu <lwhsu@FreeBSD.org> ---
> The imprecise powl() implementation in lib/msun/src/imprecise.c, which simply
> delegated to pow() (double precision), was replaced by a long double algorithm.
> 
> In src 123afd01341cc509893fea71afcc90b7b3b668b4 (2018-07-15), full-precision
> powl() implementations were imported from OpenBSD and added as
> lib/msun/ld80/e_powl.c and lib/msun/ld128/e_powl.c. The stub in imprecise.c was
> removed at the same time.
> 
> Subsequently, imprecise.c itself was disconnected from the build entirely in
> src d47b524eadb5a87506fe6ae03febbf72fad2ee06 .
> 
> -- 
> You are receiving this mail because:
> You are the assignee for the bug.


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p9u0se9fxftv.fsf>