Fixes: SWDEV-288006
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/AMDGPU/SIISelLowering.cpp | ||
---|---|---|
4228–4237 | Should just constrain the register class to an even aligned 32-bit register class |
llvm/lib/Target/AMDGPU/SIISelLowering.cpp | ||
---|---|---|
4228–4237 | That was the first thing I did. It is much more code to handle just these 3 instructions, and it does not really work, I cannot prevent SIFoldOperands from replacing a register with unaligned one. Then isLegalRegOperand() should also handle this situation, which in turn would mean duplicating ds_gws opcodes with a different operand RC, handling new operand type in asm/disasm and other places. On top of that such RC must have OtherVT as the only supported VT so that ISel will not use it after a call to getMinimalPhysRegClass(). This RC also will make it a quest to implement something line getCompatibleSubRegClass() and similar when an odd subreg is requested. This is really an overkill. |
JBTW, this patch directly reflects what's actually happen in HW. Even though these 3 instructions read 32 bit as a source internally they request to read 64 bit which in turn triggered alignment requirement. I assume this is really modeled as "read dword as an operand and have an implicit read of a superreg".
llvm/lib/Target/AMDGPU/SIISelLowering.cpp | ||
---|---|---|
4228–4237 | And for that I had to write a pipe of code in the D103213 to handle it in the isOperandLegal(), which as I said is an overkill. | |
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | ||
4351–4353 | Any idea how to skip verifier after selection with gisel and before finalize lowering? We should have lot more problems like this as finalizeLowering() calls legalizeOperands() for many more instructions, we just do not have enough tests I guess. |
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | ||
---|---|---|
4351–4353 | Here is what happens with gisel: # *** IR Dump After InstructionSelect (instruction-select) ***: # Machine code for function gws_init_odd_agpr: IsSSA, TracksLiveness, Legalized, RegBankSelected, Selected Function Live Ins: $sgpr0_sgpr1 in %1, $sgpr2 in %6 ... DS_GWS_INIT %16:vgpr_32, 0, implicit $m0, implicit $exec :: (store 4 into custom "GWSResource") ... # *** IR Dump After Finalize ISel and expand pseudo-instructions (finalize-isel) ***: # Machine code for function gws_init_odd_agpr: IsSSA, TracksLiveness, Legalized, RegBankSelected, Selected Function Live Ins: $sgpr0_sgpr1 in %1, $sgpr2 in %6 ... BUNDLE implicit %19:vreg_64_align2, implicit $m0, implicit $exec { DS_GWS_INIT %19.sub0:vreg_64_align2, 0, implicit $m0, implicit $exec, implicit %19:vreg_64_align2 :: (store 4 into custom "GWSResource") S_WAITCNT 0 } If verifier kiks-in before finalizeLowering the instruction is not yet fixed, just like any other instruction which is supposed to be legalized there. |
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | ||
---|---|---|
4351–4353 | Oh right, this problem. We currently have an ugly hack where we disable the verifier for selectiondag before finalize lowering, but I would like to avoid spreading that problem. Can you adjust the class directly in selectDSGWSIntrinsic for gisel? |
LGTM plus comment
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp | ||
---|---|---|
1394 | Should add a comment explaining this hack |
Should add a comment explaining this hack