This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix float-number representation bug
ClosedPublic

Authored by peixin on Apr 13 2022, 5:03 AM.

Details

Summary

The float number is represented as (-1)^s * 1.f * 2^(-127) for 32-bit,
where s is the signed flag, f is the mantissa. When the exponent bits
are all zeros, the float number is represented as (-1)^s * 0.f *2^(-126)
for 32-bit, in which case, the intPart is '0'.

Diff Detail

Event Timeline

peixin created this revision.Apr 13 2022, 5:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2022, 5:03 AM
Herald added a subscriber: jdoerfert. · View Herald Transcript
peixin requested review of this revision.Apr 13 2022, 5:03 AM
peixin added a reviewer: sscalpone.

There is a unittest that is failing with the buildbots:

/var/lib/buildkite-agent/builds/llvm-project/flang/unittests/Evaluate/real.cpp:43: FAIL: Real4{Integer4{table[j].raw}}.DumpHexadecimal() == table[j].expected
	11
/var/lib/buildkite-agent/builds/llvm-project/flang/unittests/Evaluate/real.cpp:43: FAIL: Real4{Integer4{table[j].raw}}.DumpHexadecimal() == table[j].expected
	12
16839176 tests pass, 2 tests FAIL
peixin updated this revision to Diff 422535.Apr 13 2022, 9:18 AM

Thanks @jeanPerier . Not noticed these test cases are not in fir-dev. The failed test cases are just what this patch fixes. For them, the exponent bits are all zeros. Fix the test cases.

jeanPerier accepted this revision.Apr 14 2022, 3:34 AM

Looks good, thanks

This revision is now accepted and ready to land.Apr 14 2022, 3:34 AM