[all-commits] [llvm/llvm-project] 455d67: [libc] Add get_explicit_exponent to fpbits

michaelrj-google via All-commits all-commits at lists.llvm.org
Tue Aug 15 16:23:39 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 455d678019d8a713f04f33ca27573f0676df05f6
      https://github.com/llvm/llvm-project/commit/455d678019d8a713f04f33ca27573f0676df05f6
  Author: Michael Jones <michaelrj at google.com>
  Date:   2023-08-15 (Tue, 15 Aug 2023)

  Changed paths:
    M libc/src/__support/FPUtil/FPBits.h
    M libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
    M libc/src/__support/FPUtil/x86_64/LongDoubleBits.h
    M libc/src/__support/float_to_string.h
    M libc/src/stdio/printf_core/float_dec_converter.h
    M libc/src/stdio/printf_core/float_hex_converter.h

  Log Message:
  -----------
  [libc] Add get_explicit_exponent to fpbits

In the same way that get_explicit_mantissa is used to get the mantissa
with all the implicit bits spelled out, get_explicit_exponent gives you
the exponent with the special cases handled. Mainly it handles the cases
where the exponent is zero, which causes the exponent to either be 1
higher than expected, or just 0.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D157156


  Commit: 89cdaa8d49246cc5c797c5eb54a06a4fb09a07c5
      https://github.com/llvm/llvm-project/commit/89cdaa8d49246cc5c797c5eb54a06a4fb09a07c5
  Author: Michael Jones <michaelrj at google.com>
  Date:   2023-08-15 (Tue, 15 Aug 2023)

  Changed paths:
    M libc/src/stdio/printf_core/float_hex_converter.h
    M libc/test/src/stdio/sprintf_test.cpp

  Log Message:
  -----------
  [libc] Fix printf %a padding issue

The trailing zeroes were previously not counted when calculating the
padding, which caused a high-precision number to get too much padding.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D157534


  Commit: b02e73a3551f7bd9c852e599e4a323f84e4fe43a
      https://github.com/llvm/llvm-project/commit/b02e73a3551f7bd9c852e599e4a323f84e4fe43a
  Author: Michael Jones <michaelrj at google.com>
  Date:   2023-08-15 (Tue, 15 Aug 2023)

  Changed paths:
    M libc/src/stdio/printf_core/float_dec_converter.h
    M libc/test/src/stdio/sprintf_test.cpp

  Log Message:
  -----------
  [libc] Fix printf %f bugs

Fuzzing revealed several bugs in the %f float conversion. This patch
fixes them. Most of these bugs are related to rounding, such as
1.999...999 being rounded to 2.999...999 instead of 2.000...000 due to
rounding up not properly changing the nines to zeros. Additionally, much
of the rounding infrastructure has been refactored out so it can be
shared with the other conversions.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D157535


  Commit: cd06b9d98fe23ffbebe8d730ccf4d2a51f373849
      https://github.com/llvm/llvm-project/commit/cd06b9d98fe23ffbebe8d730ccf4d2a51f373849
  Author: Michael Jones <michaelrj at google.com>
  Date:   2023-08-15 (Tue, 15 Aug 2023)

  Changed paths:
    M libc/src/stdio/printf_core/float_dec_converter.h
    M libc/test/src/stdio/sprintf_test.cpp

  Log Message:
  -----------
  [libc] Fix printf %e and %g bugs

Fuzzing revealed bugs in the %e and %g conversions. Since these are very
similar, they are grouped together. Again, most of the bugs were related
to rounding. As an example, previously the code to check if the number
was truncated only worked for digits below the decimal point, due to it
being originally designed for %f. This patch adds a mechanism to check
the digits above the decimal point for both %e and %g.

Reviewed By: sivachandra, lntue

Differential Revision: https://reviews.llvm.org/D157536


  Commit: e7866ea2125efe4baed98f6f9545966acf1ebad0
      https://github.com/llvm/llvm-project/commit/e7866ea2125efe4baed98f6f9545966acf1ebad0
  Author: Michael Jones <michaelrj at google.com>
  Date:   2023-08-15 (Tue, 15 Aug 2023)

  Changed paths:
    M libc/fuzzing/stdio/CMakeLists.txt
    A libc/fuzzing/stdio/printf_float_conv_fuzz.cpp

  Log Message:
  -----------
  [libc] Add fuzzing for printf floats

To guarantee accuracy for all potential float values, this patch adds a
fuzzer to compare the results for float conversions from our printf
against MPFR's.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D156495


Compare: https://github.com/llvm/llvm-project/compare/95ab1cd712c2...e7866ea2125e


More information about the All-commits mailing list