[llvm-branch-commits] [llvm] [AMDGPU][GlobalISel] Add COPY_SCC_VCC combine for VCC-SGPR-VGPR pattern (PR #179352)

Petar Avramovic via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Feb 23 05:53:49 PST 2026


petar-avramovic wrote:

> Speaking of G_SELECT combine here, think we are actually doing a much more generic combine
> 
> %**1**:sgpr(s32) = G_COPY-FROM-VGPR-OR-VCC %**0**
> %**2:sgpr**(s32) = G_XYZ %**1**, %x, %y - SALU 
> %**3**:vgpr(s32) = COPY %**2** 
> -> 
> %**3:vgpr**(s32) = G_XYZ %**0**, %x_vgpr, %y_vgpr - VALU
> 
> but I am not sure on actual conditions when we want to move instruction to VALU

To get back to one of the questions, quoted combine should be considered for pretty much **all** opcodes (maybe some checks are needed but usually if there is SALU version, there is also VALU version of same instruction)

Description needs to be clarified a bit, this is `"move sgpr g_select to VALU" if one of the inputs is COPY_SCC_VCC`.
Not sure if you want to merge the select first and do generic case in another PR or are you updating this one.
Try adding .ll tests with different number of COPY_SCC_VCC or G_READANYLANE inputs to se if we can get some heuristic go get this going. I assume good start would be to count instructions that would be deleted, v_mov that would be added (COPY to vgpr at this point) and ignore v_mov of constant or similar if we could predict that they would be inlined later

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


More information about the llvm-branch-commits mailing list