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

Bruce Evans bde at FreeBSD.org
Thu Nov 17 02:20:05 GMT 2005


bde         2005-11-17 02:20:04 UTC

  FreeBSD src repository

  Modified files:
    lib/msun/src         e_rem_pio2f.c 
  Log:
  Rearranged the the optimizations for special cases to reduce the average
  number of branches.
  
  Use a non-bogus magic constant for the threshold of pi/4.  It was 2 ulps
  smaller than pi/4 rounded down, but its value is not critical so it should
  be the result of natural rounding.  Use "<=" comparisons with rounded-
  down thresholds for all small multiples of pi/4.
  
  Cleaned up previous commit:
  - use static const variables instead of expressions for multiples of pi/2
    to ensure that they are evaluated at compile time.  gcc currently
    evaluates them at compile time but C99 compilers are not required
    to do so.  We want compile time evaluation for optimization and don't
    care about side effects.
  - use M_PI_2 instead of a magic constant for pi/2.  We need magic constants
    related to pi/2 elsewhere but not here since we just want pi/2 rounded
    to double and even prefer it to be rounded in the default rounding mode.
    We can depend on the cmpiler being C99ish enough to round M_PI_2 correctly
    just as much as we depended on it handling hex constants correctly.  This
    also fixes a harmless rounding error in the hex constant.
  - keep using expressions n*<value for pi/2> in the initializers for the
    static const variables.  2*M_PI_2 and 4*M_PI_2 are obviously rounded in
    the same way as the corresponding infinite precision expressions for
    multiples of pi/2, and 3*M_PI_2 happens to be rounded like this, so we
    don't need magic constants for the multiples.
  - fixed and/or updated some comments.
  
  Revision  Changes    Path
  1.16      +53 -42    src/lib/msun/src/e_rem_pio2f.c


More information about the cvs-src mailing list