Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Oct 2005 12:13:37 +0000 (UTC)
From:      Bruce Evans <bde@FreeBSD.org>
To:        src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   cvs commit: src/lib/msun/src e_rem_pio2f.c
Message-ID:  <200510251213.j9PCDbBp010108@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
bde         2005-10-25 12:13:37 UTC

  FreeBSD src repository

  Modified files:
    lib/msun/src         e_rem_pio2f.c 
  Log:
  More fixes for arg reduction near pi/2 on systems with broken assignment
  to floats (mainly i386's).  All errors of more than 1 ulp for float
  precision trig functions were supposed to have been fixed; however,
  compiling with gcc -O2 uncovered 18250 more such errors for cosf(),
  with a maximum error of 1.409 ulps.
  
  Use essentially the same fix as in rev.1.8 of k_rem_pio2f.c (access a
  non-volatile variable as a volatile).  Here the -O1 case apparently
  worked because the variable is in a 2-element array and it takes -O2
  to mess up such a variable by putting it in a register.
  
  The maximum error for cosf() on i386 with gcc -O2 is now 0.5467 (it
  is still 0.5650 with gcc -O1).  This shows that -O2 still causes some
  extra precision, but the extra precision is now good.
  
  Extra precision is harmful mainly for implementing extra precision in
  software.  We want to represent x+y as w+r where both "+" operations
  are in infinite precision and r is tiny compared with w.  There is a
  standard algorithm for this (Knuth (1981) 4.2.2 Theorem C), and fdlibm
  uses this routinely, but the algorithm requires w and r to have the
  same precision as x and y.  w is just x+y (calculated in the same
  finite precision as x and y), and r is a tiny correction term.  The
  i386 gcc bugs tend to give extra precision in w, and then using this
  extra precision in the calculation of r results in the correction
  mostly staying in w and being missing from r.  There still tends to
  be no problem if the result is a simple expression involving w and r
  -- modulo spills, w keeps its extra precision and r remains the right
  correction for this wrong w.  However, here we want to pass w and r
  to extern functions.  Extra precision is not retained in function args,
  so w gets fixed up, but the change to the tiny r is tinier, so r almost
  remains as a wrong correction for the right w.
  
  Revision  Changes    Path
  1.12      +8 -5      src/lib/msun/src/e_rem_pio2f.c



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