[llvm] [AMDGPU][GlobalISel] Guard against use of disallowed sub-registers (PR #188781)

Igor Wodiany via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 10:48:25 PDT 2026


================
@@ -243,13 +243,15 @@ bool InstructionSelect::selectMachineFunction(MachineFunction &MF) {
         continue;
       Register SrcReg = MI.getOperand(1).getReg();
       Register DstReg = MI.getOperand(0).getReg();
-      if (SrcReg.isVirtual() && DstReg.isVirtual()) {
-        auto SrcRC = MRI.getRegClass(SrcReg);
-        auto DstRC = MRI.getRegClass(DstReg);
-        if (SrcRC == DstRC) {
-          MRI.replaceRegWith(DstReg, SrcReg);
-          MI.eraseFromParent();
-        }
+      unsigned SrcSubIdx = MI.getOperand(1).getSubReg();
----------------
IgWod wrote:

> though it could try to find the compatible subclass and constrain.

Do you mean do it for just `DstReg` and `SrcReg` or do you suggest to also allow SrcSubReg if legal?

https://github.com/llvm/llvm-project/pull/188781


More information about the llvm-commits mailing list