cvs commit: src/lib/msun/src e_rem_pio2f.c

Bruce Evans bde at FreeBSD.org
Sun Nov 6 09:48:02 PST 2005


bde         2005-11-06 17:48:02 UTC

  FreeBSD src repository

  Modified files:
    lib/msun/src         e_rem_pio2f.c 
  Log:
  Use a 53-bit approximation to pi/2 instead of a 33+53 bit one for the
  special case pi/4 <= |x| < 3*pi/4.  This gives a tiny optimization (it
  saves 2 subtractions, which are scheduled well so they take a whole 1
  cycle extra on an AthlonXP), and simplifies the code so that the
  following optimization is not so ugly.
  
  Optimize for the range 3*pi/4 < |x| < 9*Pi/2 in the same way.  On
  Athlon{XP,64} systems, this gives a 25-40% optimization (depending a
  lot on CFLAGS) for the cosf() and sinf() consumers on this range.
  Relative to i387 hardware fcos and fsin, it makes the software versions
  faster in most cases instead of slower in most cases.  The relative
  optimization is smaller for tanf() the inefficient part is elsewhere.
  
  The 53-bit approximation to pi/2 is good enough for pi/4 <= |x| <
  3*pi/4 because after losing up to 24 bits to subtraction, we still
  have 29 bits of precision and only need 25 bits.  Even with only 5
  extra bits, it is possible to get perfectly rounded results starting
  with the reduced x, since if x is nearly a multiple of pi/2 then x is
  not near a half-way case and if x is not nearly a multiple of pi/2
  then we don't lose many bits.  With our intentionally imperfect rounding
  we get the same results for cosf(), sinf() and tanf() as without this
  optimization.
  
  Revision  Changes    Path
  1.15      +39 -9     src/lib/msun/src/e_rem_pio2f.c


More information about the cvs-src mailing list