This is an archive of the discontinued LLVM Phabricator instance.

[libc] Simplify decimalStringToFloat and hexadecimalStringToFloat in str_to_float.h and improve their performance.
ClosedPublic

Authored by lntue on Nov 11 2021, 8:34 AM.

Details

Summary

Combine two loops in decimalStringToFloat and hexadecimalStringToFloat that extract the digits and re-arrange them a little bit. This slightly improves the performance of strtof and strtod:
Running libc_str_to_float_comparison_test parse-number-fxx-test_data/data/* on my machine (Ryzen 1700)

  • with glibc: ~1.92 seconds
  • with current implementation: ~1.78 seconds
  • with this change: ~1.67 seconds

Diff Detail

Event Timeline

lntue created this revision.Nov 11 2021, 8:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 11 2021, 8:34 AM
lntue requested review of this revision.Nov 11 2021, 8:34 AM
michaelrj accepted this revision.Nov 11 2021, 9:52 AM

LGTM with the nit that the commit name is much longer than the recommended length, so shortening it would be good.

This revision is now accepted and ready to land.Nov 11 2021, 9:52 AM
lntue updated this revision to Diff 386631.Nov 11 2021, 12:49 PM

[libc] Simplify decimalStringToFloat and hexadecimalStringToFloat and improve their performance.

lntue updated this revision to Diff 386676.Nov 11 2021, 3:34 PM

[libc] Simplify decimalStringToFloat and hexadecimalStringToFloat and improve their performance.

This revision was landed with ongoing or failed builds.Nov 11 2021, 3:35 PM
This revision was automatically updated to reflect the committed changes.