[llvm] [SPIR-V] Handle ASM with multiple outputs (PR #187128)
Alex Voicu via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 6 06:43:29 PDT 2026
https://github.com/AlexVlx commented:
> This looks fragile. May be gracefully check for assumptions? I've combined the hack I had with your patch, the results looks like this:
> ```
> if (DefReg.isValid() && MRI.hasOneUse(DefReg)) {
> MachineInstr &CopyMI = *MRI.use_instr_begin(DefReg);
> if (CopyMI.getOpcode() == TargetOpcode::COPY) {
> Register CopyDst = CopyMI.getOperand(0).getReg();
> if (MRI.hasOneUse(CopyDst)) {
> MachineInstr &ExtMI = *MRI.use_instr_begin(CopyDst);
> if (ExtMI.getOpcode() == TargetOpcode::G_TRUNC ||
> ExtMI.getOpcode() == TargetOpcode::G_ANYEXT) {
> Register ExtDst = ExtMI.getOperand(0).getReg();
> AsmCall->getOperand(0).setReg(ExtDst);
> ExtMI.eraseFromParent();
> CopyMI.eraseFromParent();
> }
> }
> }
> }
>
> ```
Thank you for the excellent suggestion!
https://github.com/llvm/llvm-project/pull/187128
More information about the llvm-commits
mailing list