-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[AMDGPU][AsmParser] Some instructions are indistinguishable to AsmParser #69256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@llvm/issue-subscribers-backend-amdgpu Author: Ivan Kosarev (kosarev)
There are instructions in the AMDGPU backend that have identical mnemonics and operands:
Note that both the instructions have Furthermore, where otherwise identical instructions have operands defined in TableGen as having different
anonymous_<n> , where <n> is a number that depends on when during the work of the TableGen's internal machinery this entity was defined relative to other anonymous entities, see RecordKeeper::getNewAnonymousName() . This in turn means that the instruction matching order is generally susceptible to where in .td files used AsmOperandClass es have been defined.
As I side note, we seem to have special code in TableGen that checks specifically for ambiguous matchables (instructions):
couldMatchAmbiguouslyWith() doesn't flag such cases.
Caught on an attempt to prepare an NFC patch involving adding an anonymous operand class, which led to failures on regression tests. A subtask of #62629. |
|
For instructions that look identical to the AsmParser machinery we may end up matching the wrong instruction, which is what actually happened as I was trying to fix the predicates for (I think I was wrong saying it above that it is the names of the classes themselves that matter. I was investigating this months ago and now that I refresh my memory, I think it's the Regarding means to fix this, maybe we could start with using the That apart, it's also possible that we will have to teach the AsmMatcherEmitter backend how to deal with optional operands. It seems it currently just ignores their existence. I don't have any concrete reproducers, but suspect that fixing the ordering logic will require taking them into account. |
This reproduces the problem. Supposed to be an NFC, but causes failures on
|
This resolves AsmParser ambiguity between them and similar instructions for other subtargets, e.g., V_PK_SUB_U16_vi being identical to V_PK_SUB_U16_gfx11 on GFX11. Part of <llvm#69256>.
Resolves AsmParser ambiguity, e.g., V_MFMA_I32_32X32X8I8_vi currently has isGFX908orGFX90A as its subtarget predicate, which makes it identical to V_MFMA_I32_32X32X8I8_gfx90a_acd on GFX90A. Part of <#69256>.
…tructions. Resolves AsmParser ambiguities, e.g., between V_FMA_MIXLO_F16_vi and V_FMA_MIXLO_F16_gfx11. Part of <llvm#69256>.
…s. (#71799) CPol and CPol_GLC1 operand classes have identical predicates, which means AsmParser cannot differentiate between the RTN and non-RTN variants of the instructions. When it currently selects the wrong instruction, a hack in cvtSMEMAtomic() corrects the op-code. Using the new predicated-value operands makes this hack and the whole conversion function not needed. Other uses of CPol_GLC1 operands are to be addressed separately. Resolves about half of the remaining ~1000 pairs of ambiguous instructions. Part of <#69256>.
Resolves AsmParser ambiguities, e.g., between BUFFER_WBINVL1_vi and BUFFER_WBINVL1_gfx6_gfx7. Part of <#69256>.
…s. (llvm#71799) CPol and CPol_GLC1 operand classes have identical predicates, which means AsmParser cannot differentiate between the RTN and non-RTN variants of the instructions. When it currently selects the wrong instruction, a hack in cvtSMEMAtomic() corrects the op-code. Using the new predicated-value operands makes this hack and the whole conversion function not needed. Other uses of CPol_GLC1 operands are to be addressed separately. Resolves about half of the remaining ~1000 pairs of ambiguous instructions. Part of <llvm#69256>.
Resolves AsmParser ambiguities, e.g., between BUFFER_WBINVL1_vi and BUFFER_WBINVL1_gfx6_gfx7. Part of <llvm#69256>.
Resolves AsmParser ambiguities, e.g., between BUFFER_ATOMIC_XOR_X2_BOTHEN_vi and BUFFER_ATOMIC_XOR_X2_BOTHEN_RTN_vi. Part of <llvm#69256>.
Resolves AsmParser ambiguities, e.g., between BUFFER_ATOMIC_XOR_X2_BOTHEN_vi and BUFFER_ATOMIC_XOR_X2_BOTHEN_RTN_vi. Part of <#69256>.
Resolves AsmParser ambiguities, e.g., between V_SUBREV_F16_t16_dpp8_gfx11 and V_SUBREV_F16_t16_dpp8_gfx12. Part of <#69256>.
Resolves AsmParser ambiguities, e.g., between V_DOT4C_I32_I8_dpp_vi and V_DOT4C_I32_I8_dpp_gfx10. The latter is predicated with isGFX10Only while the first has no subtarget generation predicates. Part of <llvm#69256>.
Resolves AsmParser ambiguities, e.g., between V_DOT4C_I32_I8_dpp_vi and V_DOT4C_I32_I8_dpp_gfx10. The latter is predicated with isGFX10Only while the first has no subtarget generation predicates. Part of <#69256>.
…tions. (#79131) As otherwise SGPR+IMM instructions are not distinguishable to SGPR-only ones in AsmParser, leading to ambiguities. GFX12 doesn't have special SGPR-only variants, so we still allow optional immediate offsets for the subtarget. Also rename the offset operand classes while there. Part of <#69256>.
Resolves AsmParser ambiguities, e.g., between V_SUBREV_F16_t16_dpp8_gfx11 and V_SUBREV_F16_t16_dpp8_gfx12. Part of <llvm#69256>.
Resolves AsmParser ambiguities, e.g., between V_DOT4C_I32_I8_dpp_vi and V_DOT4C_I32_I8_dpp_gfx10. The latter is predicated with isGFX10Only while the first has no subtarget generation predicates. Part of <llvm#69256>.
Resolves AsmParser ambiguity, e.g., V_MFMA_I32_32X32X8I8_vi currently has isGFX908orGFX90A as its subtarget predicate, which makes it identical to V_MFMA_I32_32X32X8I8_gfx90a_acd on GFX90A. Part of <llvm/llvm-project#69256>.
CPol and CPol_GLC1 operand classes have identical predicates, which means AsmParser cannot differentiate between the RTN and non-RTN variants of the instructions. When it currently selects the wrong instruction, a hack in cvtSMEMAtomic() corrects the op-code. Using the new predicated-value operands makes this hack and the whole conversion function not needed. Other uses of CPol_GLC1 operands are to be addressed separately. Resolves about half of the remaining ~1000 pairs of ambiguous instructions. Part of <llvm/llvm-project#69256>.
Resolves AsmParser ambiguities, e.g., between BUFFER_WBINVL1_vi and BUFFER_WBINVL1_gfx6_gfx7. Part of <llvm/llvm-project#69256>.
…tructions. (#71194) Resolves AsmParser ambiguities, e.g., between V_FMA_MIXLO_F16_vi and V_FMA_MIXLO_F16_gfx11. Part of <llvm/llvm-project#69256>.
Resolves AsmParser ambiguities, e.g., between V_SUBREV_F16_t16_dpp8_gfx11 and V_SUBREV_F16_t16_dpp8_gfx12. Part of <llvm/llvm-project#69256>.
…tions. As otherwise SGPR+IMM instructions are not distinguishable to SGPR-only ones in AsmParser, leading to ambiguities. GFX12 doesn't have special SGPR-only variants, so we still allow optional immediate offsets for the subtarget. Also rename the offset operand classes while there. Part of <llvm/llvm-project#69256>.
There are instructions in the AMDGPU backend that have identical mnemonics and operands:
Note that both the instructions have
{ MCK_AV_64, MCK_off, MCK_SReg_128, MCK_SCSrcB32, MCK_Offset, MCK_CPol }
as their lists of operand kinds. This means that for a set of parsed operands that is suitable for these instructions as determined by calling their corresponding operand class predicates, of these two instructions AsmParser will select the one that is happened to match first. For instructions with identical mnemonics, operands and features the matching order is generally not defined.Furthermore, where otherwise identical instructions have operands defined in TableGen as having different
AsmOperandClass
es, the matching order is determined by comparing the names of theseAsmOperandClass
es:llvm-project/llvm/utils/TableGen/AsmMatcherEmitter.cpp
Line 364 in dda46b2
anonymous_<n>
, where<n>
is a number that depends on when during the work of the TableGen's internal machinery this entity was defined relative to other anonymous entities, seeRecordKeeper::getNewAnonymousName()
. This in turn means that the instruction matching order is generally susceptible to where in .td files usedAsmOperandClass
es have been defined.As I side note, we seem to have special code in TableGen that checks specifically for ambiguous matchables (instructions):
llvm-project/llvm/utils/TableGen/AsmMatcherEmitter.cpp
Line 3237 in dda46b2
couldMatchAmbiguouslyWith()
doesn't flag such cases.Caught on an attempt to prepare an NFC patch involving adding an anonymous operand class, which led to failures on regression tests.
A subtask of #62629.
The text was updated successfully, but these errors were encountered: