HEADSUP: math is broken with clang and optimization

From: Steve Kargl <sgk_at_troutmask.apl.washington.edu>
Date: Sun, 14 Feb 2021 13:59:58 -0800
Just a headsup for anyone doing numerical work with
FreeBSD-current.  clang with optimization of -O1 or
higher produces wrong results.  Testing 1 million 
complex values of ccoshf and limiting |z| < 20,
shows

% cc -o testf -O2 -pipe -static -Wall -fno-builtin \
  -I/usr/home/kargl/include -I/usr/local/include -I../mp \
  -I../libm/msun/src testf.c  -L/usr/home/kargl/lib \
  -L/usr/local/lib -L../mp -L../libm/msun -lmpsk -lmpfr -lgmp -lm
% ./testf -u -n 1 -X 10
Max ULP Re: 136633.320045
Max ULP Im: 1890038.672637

% cc -o testf -O0 -pipe -static -Wall -fno-builtin \
  -I/usr/home/kargl/include -I/usr/local/include -I../mp \
  -I../libm/msun/src testf.c  -L/usr/home/kargl/lib \
  -L/usr/local/lib -L../mp -L../libm/msun -lmpsk -lmpfr -lgmp -lm
% ./testf -u -n 1 -X 10
Max ULP Re: 2.785010
Max ULP Im: 2.926068

One of these is more correct than the other.

-- 
Steve
Received on Sun Feb 14 2021 - 21:00:10 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:27 UTC