[llvm] [AMDGPU][GlobalISel] Expand SGPR S1 exts into G_SELECT (PR #68858)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 04:51:57 PDT 2023


Pierre-vh wrote:

> > It also adds some new ISel logic to make G_SELECT 1,0 be lowered to a simple SCC copy. This is because a copy of SCC is already a s_cselect x, 1, 0. Without that we get some regressions.
> 
> I don't understand why this part is required. Do you have a simple example?

`G_SELECT` is lowered into something like
```
  $scc = COPY %30:sreg_32
  %18:sreg_32 = S_CSELECT_B32 %35:sreg_32, %34:sreg_32, implicit $scc
```

But ` $scc = COPY %30:sreg_32` is expanded post RA into a, for example, `s_cselect s0, 1, 0` already. So we end up with two selects that are redundant.

In most cases it doesn't really matter because it seems that we're able to optimize it anyway, but in the case of uaddo, we get something like this without the ISel change:
![MicrosoftTeams-image](https://github.com/llvm/llvm-project/assets/29600849/e4173be8-c353-416b-b95e-e314df170926)


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


More information about the llvm-commits mailing list