This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Allow multiple uses of the same literal
ClosedPublic

Authored by foad on Apr 19 2021, 9:00 AM.

Details

Summary

In GFX10 VOP3 can have a literal, which opens up the possibility of two
operands using the same literal value, which is allowed and only counts
as one use of the constant bus.

AMDGPUAsmParser::validateConstantBusLimitations already knew about this
but SIInstrInfo::verifyInstruction did not.

Diff Detail

Event Timeline

foad created this revision.Apr 19 2021, 9:00 AM
foad requested review of this revision.Apr 19 2021, 9:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2021, 9:01 AM
arsenm added inline comments.Apr 19 2021, 9:43 AM
llvm/test/CodeGen/AMDGPU/verify-duplicate-literal.mir
14

Should probably add a few more tests for other instruction types (in particular ones without an implicit vcc use and would be a more sensible place for this to happen)

I wonder if a 16 bit literal + non-default opsel and the same literal with different opsel, or different literal which turns into the same literal after opsel is applied constitutes a same value? I.e. is it checked on decoding or after?

foad updated this revision to Diff 338853.Apr 20 2021, 6:54 AM

Add a test with fma.

foad marked an inline comment as done.Apr 20 2021, 6:56 AM

I wonder if a 16 bit literal + non-default opsel and the same literal with different opsel, or different literal which turns into the same literal after opsel is applied constitutes a same value? I.e. is it checked on decoding or after?

AMDGPUAsmParser::validateConstantBusLimitations says that if different operands use the same literal with different sizes, then that counts as two scalar values. So I guess we may need to refine this code a bit, but I would prefer to leave that for later patches.

llvm/test/CodeGen/AMDGPU/verify-duplicate-literal.mir
14

Added an fma test which is slightly more realistic.

foad marked an inline comment as done.Apr 20 2021, 6:56 AM
arsenm accepted this revision.Apr 20 2021, 8:34 AM
This revision is now accepted and ready to land.Apr 20 2021, 8:34 AM
This revision was automatically updated to reflect the committed changes.