This is an archive of the discontinued LLVM Phabricator instance.

[libc] fix MPFR rounding problems in fuzz test
ClosedPublic

Authored by michaelrj on Jun 29 2023, 1:55 PM.

Details

Summary

The accuracy for the MPFR numbers in the strtofloat fuzz test was set
too high, causing rounding issues when rounding to a smaller final
result.

Diff Detail

Event Timeline

michaelrj created this revision.Jun 29 2023, 1:55 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 29 2023, 1:55 PM
michaelrj requested review of this revision.Jun 29 2023, 1:55 PM
lntue accepted this revision.Jun 30 2023, 8:43 AM
lntue added inline comments.
libc/fuzzing/stdlib/strtofloat_fuzz.cpp
83

These values are useful. Maybe you could add them directly to FloatProperties , something like:
FloatProperties<T>::PRECISION ?

This revision is now accepted and ready to land.Jun 30 2023, 8:43 AM
lntue retitled this revision from [libc] fix MPFR accuracy in fuzz test to [libc] fix MPFR double-rounding problems in fuzz test.Jun 30 2023, 8:44 AM
lntue edited the summary of this revision. (Show Details)
lntue added inline comments.Jun 30 2023, 8:49 AM
libc/fuzzing/stdlib/strtofloat_fuzz.cpp
83
michaelrj retitled this revision from [libc] fix MPFR double-rounding problems in fuzz test to [libc] fix MPFR rounding problems in fuzz test.Jun 30 2023, 1:20 PM
michaelrj edited the summary of this revision. (Show Details)
michaelrj updated this revision to Diff 536392.Jun 30 2023, 1:21 PM
michaelrj marked 2 inline comments as done.

add MANTISSA_PRECISION to float_properties, and use it in MPFR utils.

I also changed the title of the commit slightly since the proposed one was too long

lntue accepted this revision.Jun 30 2023, 6:22 PM
This revision was automatically updated to reflect the committed changes.