This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add get_explicit_exponent to fpbits
ClosedPublic

Authored by michaelrj on Aug 4 2023, 4:16 PM.

Details

Summary

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.

Diff Detail

Event Timeline

michaelrj created this revision.Aug 4 2023, 4:16 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 4 2023, 4:16 PM
michaelrj requested review of this revision.Aug 4 2023, 4:16 PM
michaelrj updated this revision to Diff 548690.Aug 9 2023, 11:15 AM

move explicit exponent changes in printf floats to this patch

michaelrj updated this revision to Diff 548691.Aug 9 2023, 11:18 AM

the rest of the explicit exponent changes

michaelrj updated this revision to Diff 548722.Aug 9 2023, 11:56 AM

fix 80 bit sqrt

lntue added inline comments.Aug 14 2023, 1:12 PM
libc/src/__support/FPUtil/x86_64/LongDoubleBits.h
150

In most of the conventions for floating point exponents, zeros are often grouped together with denormal numbers. Unless it's used in more places, do you think the logic that requires different ways of handling exponents of zeros can be put locally to those functions?

michaelrj added inline comments.Aug 14 2023, 1:36 PM
libc/src/__support/FPUtil/x86_64/LongDoubleBits.h
150

We can handle subnormals and zero in the individual places, that's what I was doing before, but I added this function because I realized it was repeated.

Regardless of if we add the new function, we should keep the change for long double get_exponent because otherwise it behaves differently from other float types.

lntue accepted this revision.Aug 15 2023, 8:11 AM
This revision is now accepted and ready to land.Aug 15 2023, 8:11 AM
This revision was automatically updated to reflect the committed changes.