<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/129071>129071</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            AMDGPU inreg arguments for SGPRs use whole VGPRs after SGPR arguments run out
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:AMDGPU
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          arsenm
      </td>
    </tr>
</table>

<pre>
    When SGPR available for argument passing run out, they silently switch to using whole VGPRs to pass arguments.

```
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx950 -o - %s

target triple = "amdgcn-amd-amdhsa"

define i32 @test0(<8 x i32> inreg %arg0,
                  <8 x i32> inreg %arg1,
 <2 x i32> inreg %arg2,
                  i32 inreg %arg3,
 i32 inreg %arg4) {
  %add = add i32 %arg3, %arg4 ; arg3 is v0, arg4 is in v1. These should be packed into a lane and extracted with readlane
  ret i32 %add
}
```

Ideally we would start to pack inreg arguments into individual lanes of VGPRs, not directly into VGPRs.

In this example, we ran out of SGPRs after 18 arguments. %arg3 and %arg4 end up in v0 and v1. We could treat these as WWM values, and pass them in v0.lane0 and v0.lane1. 

Either way, we should get a scalar value in downstream code rather than forced VALU usage 
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0VFGPmzgQ_jXmZZTImLCEBx5o0qwqXU-r7W33ecAD-GpMZJtk8-9PNmyu171GRIjxN9_MN_5sdE71hqhi-SeWHxOc_TDZCq0jMybNJG_V60AGvj0-PQNeUGlsNEE3WUDbzyMZD-dAYnqws4Fp9kwcwA90A6c0Ga9v4K7KtwP4CeYIvA6TJvj--PTsQjDk39nclvE6PA98fXjNsk_w_PIny2rQuoXN6K06a2LZEUfZt2aDowz_wSFsxvY8s-zYd29lzmEzwQaYyN3C6tH25GHJB5YdgQnxgYQJscAldcoQqEwA23FPznMm9iw77OEtRFn2GZSx1IcSaHvOxIHxGj78fp-SriksO4j_R4jfkYa2fgZmK_DX-I6JEljxKZKEkJRRenhHaffs9wQIEw8xUA4uQRXEsHKgDFzSLfw1kCNwwzRrCQ3BGdsfJEEZPwGCRkOARgK9eYutJwlX5QewhDKsxU4s-Xt5KcPAi-OvG8_rL5JQ6xtcCa6xmPNo_WKb9seq826epQFlpLooOaOOnTiYusVtQYiZPEhlqQ3OjPC4tNruiwE_KAf0hmOwmDiEyhajswPPt-ha7DxZSPc_2fZ9jFH3-xzJSJjPcWg8LoTZvRK0UYq3hD6cFUeADl5fv8IF9Uyxz4COJ8MPNC4M26Bm5Vk-0i0sfX9WfiALV7ytLa9bE9yO4FrUaBfyQCWnq3Gh-gjtJIO-mO0HNOFotyThe_3HC8wOe4JEVpkssxITqtJixx-KtOA8Gaqy4zJruu4B8326b7ATIuNFUxA2DZW4T1QluMi5EEWa57u83Kb40JVNKRvibc5zZDtOIyq91foybifbJ8q5mapUlLxIE40NaRfvJiGaYDEjWVbXX4-PTy_hlObHxFYhd9PMvWM7rpXz7l82r7ymasF_8Eq4xJbtnB3951Jatne58-7w9XpLZqurwfuzY1nNxImJU6_8MDfbdhqZOIXa62tzttPf1HomTlGWY-K0KrtU4p8AAAD__7Gyt_Y">