This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Fix V_CMP_CLASS_F16_t16_e64 src1 type.
ClosedPublic

Authored by Joe_Nash on Sep 29 2022, 11:16 AM.

Details

Summary

For V_CMP_CLASS_F16_t16_e64 and V_CMPX_CLASS_F16_t16_e64,
https://reviews.llvm.org/D133723 changed the value type of src1 from i32 to i16.
These src1 operands are 16 bits, therefore need to be encoded as true16
operands. So the _e32 type was correctly set to VGPR_32_Lo128.
In _e64 form the operand class went from
VSrc_b32 to VSrc_b16. For some reason, we cannot encode inline literals for
VSrc_b16, see 5f5f566b265db00f577ead268400d99f34ba9cdd. In this phase of
the true16 implementation, VSrc_b16 and VSrc_b32 are still similar,
except from that quirk of inlines. So set the operand class to regain
that function.

Diff Detail

Event Timeline

Joe_Nash created this revision.Sep 29 2022, 11:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2022, 11:16 AM
Joe_Nash requested review of this revision.Sep 29 2022, 11:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2022, 11:16 AM

The semantics of this instruction are strange, and we should probably improve on the inline literal support for 16 bit operands, so if you have any thoughts on this patch or future improvements please let me know.

arsenm accepted this revision.Sep 29 2022, 11:31 AM

A valid class mask is only 10 bits anyway so it's not like it matters

This revision is now accepted and ready to land.Sep 29 2022, 11:31 AM
dp added a comment.Sep 29 2022, 12:10 PM

For some reason, we cannot encode inline literals for VSrc_b16.

This is true for inline floating-point constants only. Integer inline constants may be used without limitations, so I do not see any problems using VSrc_b16 for src1.

In D134897#3824780, @dp wrote:

For some reason, we cannot encode inline literals for VSrc_b16.

This is true for inline floating-point constants only. Integer inline constants may be used without limitations, so I do not see any problems using VSrc_b16 for src1.

Before D133723, inline floating-point constants were allowed. Arguably they should be allowed ( https://developer.amd.com/wp-content/resources/RDNA2_Shader_ISA_November2020.pdf "Note that the S1 has a format of f16 since floating point literal
constants are interpreted as 16 bit value for this opcode"), though I don't know if they would be emitted by codegen.

dp added a comment.Sep 29 2022, 12:48 PM
In D134897#3824780, @dp wrote:

For some reason, we cannot encode inline literals for VSrc_b16.

This is true for inline floating-point constants only. Integer inline constants may be used without limitations, so I do not see any problems using VSrc_b16 for src1.

Before D133723, inline floating-point constants were allowed. Arguably they should be allowed ( https://developer.amd.com/wp-content/resources/RDNA2_Shader_ISA_November2020.pdf "Note that the S1 has a format of f16 since floating point literal
constants are interpreted as 16 bit value for this opcode"), though I don't know if they would be emitted by codegen.

Thanks, I see. I forgot that there are special opcodes with 16 bit integer operands which should be handled differently. I'll take a closer look at the issue.

5f5f566b265d is really a hardware bug, so it's possible it's been fixed on newer hardware (don't think it was ever properly communicated as one to fix though)

dp added a comment.Sep 29 2022, 1:34 PM

5f5f566b265d is really a hardware bug, so it's possible it's been fixed on newer hardware (don't think it was ever properly communicated as one to fix though)

Last time I read SP3 documentation for GFX11, this issue was presented as a feature, not a bug. There was also a special flag to label opcodes which correctly handled fp inline constants for 16 bit integer operands.

dp accepted this revision.Oct 5 2022, 7:27 AM

LGTM. Created a separate issue we might want to tackle in the future: https://github.com/llvm/llvm-project/issues/58167.

In D134897#3836885, @dp wrote:

LGTM. Created a separate issue we might want to tackle in the future: https://github.com/llvm/llvm-project/issues/58167.

That makes sense, thanks.

This revision was automatically updated to reflect the committed changes.