This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Treat KIMM32 and KIMM16 operand types as noninlinable
ClosedPublic

Authored by mbrkusanin on Aug 10 2023, 7:58 AM.

Details

Summary

While they are represent 32/16 bit immediate values they are already
included in encoding of the instructions that use them and are not true
literals. FMAMK and FMAAK instructions that use them are marked with fixed
size so getInstSizeInBytes will not increase the size for these operands.

We also add tests whose logic relies on KIMM16 and KIMM32 being considered
not inlinable.

Diff Detail

Event Timeline

mbrkusanin created this revision.Aug 10 2023, 7:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2023, 7:58 AM
mbrkusanin requested review of this revision.Aug 10 2023, 7:58 AM
arsenm added inline comments.Aug 10 2023, 8:01 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
7822–7823

this part is redundant?

mbrkusanin added inline comments.Aug 10 2023, 8:04 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
7822–7823

No, because size of fmamk and fmaak (instructions that use kimm32 and kimm16 operands) is already 8 so we do not need to add extra 4 bytes for these literals.

arsenm added inline comments.Aug 10 2023, 8:08 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
7822–7823

Then that should be covered by !isInlineConstant.

The API made more sense before when it was only checking for explicitly encoded src operands. This shouldn't require special casing here, something is wrong with the operand definitions if it does

Joe_Nash added inline comments.Aug 10 2023, 8:16 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
7822–7823

The KIMM are not inline constants and they are not true Literals either. There needs to be a special case somewhere. I think it is better to have a special case here than spread over everywhere we have to handle literals.

foad added inline comments.Aug 10 2023, 8:29 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
7822–7823

Just a drive-by comment: would it help to set the size of fmaak to 4, so you *do* have to add the size of the literal to get the true size?

arsenm added inline comments.Aug 10 2023, 8:31 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
7822–7823

Is isFixedSize not correctly set on these?

mbrkusanin edited the summary of this revision. (Show Details)
  • Set FixedSize for FMAMK and FMAAK instructions
arsenm added inline comments.Aug 10 2023, 9:20 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
3909

Wouldn't this still be true?

  • Update tablegen comments
Joe_Nash accepted this revision.Aug 10 2023, 2:01 PM

LGTM, but please wait for @arsenm

This revision is now accepted and ready to land.Aug 10 2023, 2:01 PM
arsenm added inline comments.Aug 10 2023, 3:05 PM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
3909

I think this part is unnecessary but the rest looks fine

mbrkusanin added inline comments.Aug 11 2023, 2:42 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
3909

Not for the issue of inst size which is fixed with FixedSize, but for a downstream test (see email).

Joe_Nash added inline comments.Aug 11 2023, 8:35 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
3909

This is a fix for the test noted on here https://reviews.llvm.org/D157103, and setting it to false is necessary for that.

Should also add the other test for the failing case

mbrkusanin edited the summary of this revision. (Show Details)
  • add test case which needs kimm16 and kimm32 to be not inlinable
  • remove some now redundant checks
arsenm accepted this revision.Aug 11 2023, 9:50 AM
mbrkusanin added inline comments.Aug 11 2023, 9:54 AM
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
5268–5270

This check here was why test mentioned in https://reviews.llvm.org/D157103#4579608 failed, but only for fmaak_f16 not f32 version. Previously we only checked for KIMM32, but with this patch it's redundant to check either.

This revision was landed with ongoing or failed builds.Aug 11 2023, 9:56 AM
This revision was automatically updated to reflect the committed changes.

@mbrkusanin This is causing failures on EXPENSIVE_CHECKS buildbots: https://lab.llvm.org/buildbot/#/builders/16/builds/52934 - please can you take a look?

@mbrkusanin This is causing failures on EXPENSIVE_CHECKS buildbots: https://lab.llvm.org/buildbot/#/builders/16/builds/52934 - please can you take a look?

Here is a fix: https://reviews.llvm.org/D157857