<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63554>63554</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISCV] Unnecessary move of undefined with subregister liveness enabled
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:RISC-V,
llvm:codegen
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
lukel97
</td>
</tr>
</table>
<pre>
```llvm
define void @repeat_shuffle(<2 x double> %v, ptr noalias %q) {
%w = shufflevector <2 x double> %v, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
store <4 x double> %w, ptr %q
ret void
}
```
When compiled with `llc -mattr=+v`, there's an unnecessary `vmv1r.v v13, v10` emitted, which copies an implicit def to `v13`.
```asm
repeat_shuffle: # @repeat_shuffle
.cfi_startproc
# %bb.0:
vmv2r.v v12, v8
vsetivli zero, 4, e64, m2, ta, ma
vmv1r.v v13, v10
vslideup.vi v8, v12, 2
vse64.v v8, (a0)
ret
```
Compiling with `-riscv-enable-subreg-liveness=0` avoids this:
```asm
repeat_shuffle: # @repeat_shuffle
.cfi_startproc
# %bb.0:
# kill: def $v8 killed $v8 def $v8m2
vsetivli zero, 4, e64, m2, ta, ma
vmv2r.v v10, v8
vslideup.vi v10, v8, 2
vse64.v v10, (a0)
ret
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVM2O2zYQfprRhbAgkfo96ODYMdBri6bHgBLHFruUqJIUN-nTF6Rkr5N0iwK91DDE4fx8w5lvMNxaeZsROyg_QHlO-OpGbTq1vqBq66TX4msHVbb9lfITZGfIjgKvckbitRQEiszggtx9tuN6vSoE2gA7UfKFCL32CoF9JEBLD_REFmfIrLmS3AbdH0BbAvWHDZUE1SsBdiY7lMfBaUPehfvBsGhp9bybCvKFSEZjADtJRkkWLEHI78KThn28P8M6bfCO8E3W13sR8fG7u0EXW7HdoT7vwr1v-zV-fxtxJoOeFqlQkFfpRhI7O5DDxJ0zwM5AP_gQRU_EjWgQaG0Jn8k6zzigtdx8DTF-8rlJPfE5C64-D6kITtI5FEHzOsphJINeJMZ4OS1KDtIRgVfidMTIGVRZSr57MLc7z98Ry47kvR9Q9jeTsBfepsNVfraOG7cYPezqEEHLvk8zYMeHq588NakPUk5jYc2bzaKTXknI2j_R6GAtwgereEzR3_Eo82fE_I74aNUbpJIC1yX1AdU3mz0C0ee8VbEhRAegDc-Atg8Hg-4fOD9FuuV8e_B9MNIO_oAz7xUe7NobvB2U9DijtcDOkUoeZsoSN0r71KD_B1ER5kUqFVKFeQJa-CZqUOyXh3qi_53Bx0xkP8zENwQ-7O8RuDn8awYT0THRspYn2OVVUzd1U9RVMnasuFbNwARrs7znvGpzOpSiwabmA68ES2RHM8qyitZ5mdVllba9aMo6r7Hq87xvaygynLhUadirqTa3RFq7YlexsiwSxXtUNu5lSns-vOAsgB1__umX0-ET0NAooDSuZHYctMAbzkFdnhPTBfWhX28WikxJ6-xbDiedius-IH2C8kx-fdork_ZI9JWs87bi9xW1Tai0Dg25jynZplckq1Hd6NwSp5RegF5u0o1rnw56AnqJT9yOw2L07zg4oJdYqgV6idX-FQAA___hrdi_">