<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/122243>122243</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
AMDGPU vector shuffle lowering does not make use of v_pk_mov_b32
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AMDGPU,
missed-optimization
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
arsenm
</td>
</tr>
</table>
<pre>
The lowering of vector shuffles (and all other vector operations) are still decomposed into copies of 32-bit pieces on targets with support for v_pk_mov_b32:
```
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx942 < %s
; Not using v_pk_mov_b32
define <4 x float> @shuffle_v4f32_2367(ptr addrspace(1) %arg0, ptr addrspace(1) %arg1) {
%val0 = load <4 x float>, ptr addrspace(1) %arg0
%val1 = load <4 x float>, ptr addrspace(1) %arg1
%shuffle = shufflevector <4 x float> %val0, <4 x float> %val1, <4 x i32> <i32 2, i32 3, i32 6, i32 7>
ret <4 x float> %shuffle
}
; Not using v_pk_mov_b32
define <4 x double> @shuffle_v4f64_2367(ptr addrspace(1) %arg0, ptr addrspace(1) %arg1) {
%val0 = load <4 x double>, ptr addrspace(1) %arg0
%val1 = load <4 x double>, ptr addrspace(1) %arg1
%shuffle = shufflevector <4 x double> %val0, <4 x double> %val1, <4 x i32> <i32 2, i32 3, i32 6, i32 7>
ret <4 x double> %shuffle
}
define <8 x half> @shuffle_v4f16_2345_891011(ptr addrspace(1) %arg0, ptr addrspace(1) %arg1) {
%val0 = load <8 x half>, ptr addrspace(1) %arg0
%val1 = load <8 x half>, ptr addrspace(1) %arg1
%shuffle = shufflevector <8 x half> %val0, <8 x half> %val1, <8 x i32> <i32 2, i32 3, i32 4, i32 5, i32 8, i32 9, i32 10, i32 11>
ret <8 x half> %shuffle
}
```
All of these cases codegen using pairs of v_mov_b32, but can compress these into one v_pk_mov_b32 on gfx90a+.
</pre>
<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