This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Print Zfa fli instruction FP values in a more adaptive way.
ClosedPublic

Authored by craig.topper on Mar 8 2023, 8:09 PM.

Details

Summary

Previously, we printed all constants in scientific notation with
6 digits of precision. This is not enough to accurately display
the smallest value, but increasing the precision would be too much
for other values.

This patch prints values with fractional bits using only as many digits as
needed. 1*2^-15 and 1*2^-16 will be printed in scientific notation while
the others are printed without scientific notation. The integer values
are printed with a single 0 after the decimal point.

Diff Detail

Event Timeline

craig.topper created this revision.Mar 8 2023, 8:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 8 2023, 8:09 PM
craig.topper requested review of this revision.Mar 8 2023, 8:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 8 2023, 8:09 PM
reames accepted this revision.Mar 10 2023, 7:16 AM

LGTM - assuming my inline comment is correct.

llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
167–177

To check my understanding - it's okay to treat FLI.D (doubles) as floats here since the only values for doubles which aren't representable exactly as floats are the ones we explicitly emit symbolically just above? And the same basic argument for floats?

This revision is now accepted and ready to land.Mar 10 2023, 7:16 AM
craig.topper added inline comments.Mar 10 2023, 7:37 AM
llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
167–177

That's correct.

joshua-arch1 added a comment.EditedMar 16 2023, 1:12 AM

I'm wondering why you print values other than 1*2^-15 and 1*2^-16 without scientific notation. From my perspective, for one instruction, we need to keep the operands relatively consistent only in some particular occasions (like min/inf/nan).

hi,
I don't quite understand why this is necessary. Isn't it more reasonable to have a unified format? The cost is very small.

hi,
I don't quite understand why this is necessary. Isn't it more reasonable to have a unified format? The cost is very small.

hi,
I don't quite understand why this is necessary. Isn't it more reasonable to have a unified format? The cost is very small.

We need 11 digits of decimal point for the smallest number consistency made the other numbers overly long.

I'm wondering why you print values other than 1*2^-15 and 1*2^-16 without scientific notation. From my perspective, for one instruction, we need to keep the operands relatively consistent only in some particular occasions (like min/inf/nan).

I wanted to present the least amount of information so it was easy to read. The instructions are going to be scattered in a binary. They aren’t often going to appear in a grouping where the inconsistency is noticeable.

This comment was removed by joshua-arch1.