[llvm] [AMDGPU] Allocate i1 argument to SGPRs (PR #72461)

Jun Wang via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 10 17:27:56 PDT 2024


jwanggit86 wrote:

@arsenm For i1 return value, to avoid having vreg_1 as the dest reg as in `%3:vreg_1 = COPY $sgpr0_sgpr1`, I've added a CopyToReg and another CopyFromReg for the CopyFromReg for the return val. The code now looks as follows:

Initial DAG:
```
  t10: ch,glue = callseq_end # D:1 t9, TargetConstant:i64<0>, TargetConstant:i64<0>, t9:1
  t12: i1,ch,glue = CopyFromReg # D:1 t10, Register:i1 $sgpr0_sgpr1, t10:1
  t17: i64 = Constant<0>
        t14: ch = CopyToReg # D:1 t12:1, Register:i1 %0, t12
      t15: i1,ch = CopyFromReg t14, Register:i1 %0
```

End of insn selection:
```
  t10: i1,ch,glue = ADJCALLSTACKDOWN TargetConstant:i64<0>, TargetConstant:i64<0>, t9, t9:1
  t12: i1,ch,glue = CopyFromReg # D:1 t10:1, Register:i1 $sgpr0_sgpr1, t10:2
          t14: ch = CopyToReg # D:1 t12:1, Register:i1 %0, t12
        t15: i1,ch = CopyFromReg t14, Register:i1 %0
      t32: i32 = V_CNDMASK_B32_e64 TargetConstant:i32<0>, TargetConstant:i32<0>, TargetConstant:i32<0>, TargetConstant:i32<1>, t15
```

Machine code:
```
  ADJCALLSTACKDOWN 0, 0, implicit-def dead $scc
  %4:sreg_64 = COPY $sgpr0_sgpr1
  %0:sreg_64_xexec = COPY %4:sreg_64
  %5:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0:sreg_64_xexec, implicit $exec
```

Pls let know your thoughts.

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


More information about the llvm-commits mailing list