[llvm] [AMDGPU][True16][CodeGen] legalize 16bit and 32bit use-def chain for moveToVALU in si-fix-sgpr-lowering (PR #138734)
Brox Chen via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 2 21:58:39 PDT 2025
================
@@ -7787,8 +7807,19 @@ void SIInstrInfo::moveToVALUImpl(SIInstrWorklist &Worklist,
.addReg(Undef)
.addImm(AMDGPU::hi16);
Inst.eraseFromParent();
-
MRI.replaceRegWith(DstReg, NewDstReg);
+ // legalize useMI with mismatched size
+ for (MachineRegisterInfo::use_iterator I = MRI.use_begin(NewDstReg),
+ E = MRI.use_end();
+ I != E; ++I) {
+ MachineInstr &UseMI = *I->getParent();
+ unsigned UseMIOpcode = UseMI.getOpcode();
+ if (AMDGPU::isTrue16Inst(UseMIOpcode) &&
+ (16 ==
+ RI.getRegSizeInBits(*getOpRegClass(UseMI, I.getOperandNo())))) {
+ I->setSubReg(AMDGPU::lo16);
+ }
+ }
----------------
broxigarchen wrote:
It needs to rewrite the fix-sgpr-copy sequences and it might takes a while to address the side-effects. I found that there is a cleaner solution as we can move the use analysis into the addUserToMoveVALU and avoid all the redundant scan
https://github.com/llvm/llvm-project/pull/138734
More information about the llvm-commits
mailing list