[libc-commits] [PATCH] D115828: [libc] Implement correctly rounded log2f based on RLIBM library.

Paul Zimmermann via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Dec 17 01:59:36 PST 2021


zimmermann6 added a comment.

the new version applies cleanly to the main branch. I have tested it on x86_64 under Linux (haswell). I confirm it is CR for rounding to nearest, and I get 3 failures if I disable the 3 exceptional cases. For other rounding modes I get 8 failures for rounding towards zero (with the exceptional cases), 8 failures too for rounding towards -Inf, and 7 failures for rounding towards +Inf.

I tried with a polynomial generated by Sollya and with this polynomial we need no exceptional cases, and the routine is CR for all rounding modes (please can someone confirm?):

  double r = __llvm_libc::fputil::polyeval(
      d, extra_factor, 0x1.71547652b7fefp+0, -0x1.715476500a42ep-1,
      0x1.ec70917f77152p-2, -0x1.71482b204ea69p-2, 0x1.21da0eb07c659p-2);

For the record this polynomial was obtained with the following input file (then run sollya log2f.sollya):

  n = 5; /* polynomial degree */
  P = 53; /* precision of the coefficients */
  
  pretty = proc(u) {
    return ~(floor(u*1000)/1000);
  };
  
  d = [0, 1/2^7];
  f = log2(1+x);
  w = 1;
  p =  remez(f, n, d, w);
  pf = fpminimax(log2(1+x), [|1,2,3,4,5|], [|P...|], d, absolute, floating, 0, p)\
  ;
  err_p = -log2(dirtyinfnorm(pf*w-f, d));
  print (pf, pretty(err_p));

Sollya is available from https://www.sollya.org/. Would you consider using the Sollya polynomial?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115828/new/

https://reviews.llvm.org/D115828



More information about the libc-commits mailing list