<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56088>56088</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AArch64][SVE] Suboptimal code-gen for fmul(index)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
stevesuzuki-arm
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/6E4Ts6zc7
```
define <vscale x 8 x half> @fmul_index_nxv8(half %a, <vscale x 8 x half> %b) #0 {
%1 = fsub reassoc nnan ninf nsz contract afn half 0xH3C00, %a
%2 = insertelement <vscale x 8 x half> undef, half %1, i64 0
%3 = shufflevector <vscale x 8 x half> %2, <vscale x 8 x half> undef, <vscale x 8 x i32> zeroinitializer
%4 = fmul reassoc nnan ninf nsz contract afn <vscale x 8 x half> %b, %3
ret <vscale x 8 x half> %4
}
```
More instructions are generated with SVE2 than with Neon which fmul(index) is used instead of mov+fmul.
Option : `-mattr=+sve2 -O3`
```
fmul_index_nxv8: // @fmul_index_nxv8
fmov h2, #1.00000000
fsub h0, h2, h0
mov z0.h, h0
fmul z0.h, z1.h, z0.h
ret
fmul_index_v8: // @fmul_index_v8
fmov h2, #1.00000000
fsub h0, h2, h0
fmul v0.8h, v1.8h, v0.h[0]
ret
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VE2T2yAM_TXOhYkHQ-I4Bx-SzXZ6afewnV53sC3HtBh2ALtpfn0F-djdNMn0UgYPyBLSk_SgMs3vsvP-1SV8lbBPOLemqYzyqbFblPb45Y-zby7f14uEbhK6SnJ6nFFsoJUaSMIfRlcLBWRHCvw6odqEP5JkRtt-UC9SN7B70buxSFgRlCRhc5Gwh9sn2bxK2BJXTkmyWB_CERyoyfDYhrRuqIgF4ZypidZCEy11S7Tbk9pob0XtiWh1dEno7jN_oDSGDKHfu2PRndQOrAcFPWh_E9eAmbTByymLLAgynxH6wSePPl03tK2CEWpv7L1c2b1anGNeGkjOgn4P1kgtvRRK4v4DjtmhVNiEfynV_W7E0vE39xZu1ymEPjJmsblKnS_GQii6t0PtpdGOCPyxBQ1WeGjIL-k78vz9kRHfIeAofgWDu07WXUwJyRSZFYgiHRkcHgseQTTEtKQ3Y8LWwTA9hHx6DYEQ84ogjGkvvLdYHjRyIzAyfeJndBdgL1nMYwGujcM9usb8c93CaBFcWLtD5xnPUnocF4aB5cEwcvdg3l3YHH2RPU27a_rY_nf6fXZcg_zBElv6V8J3072R8H9N95TOSNMi5jFmp01IaL6myXxzI69zXydNyZslX4qJl15BicdWK1t3-Swcnq-Rebghz0NlkDW9UHhTGpgiP0mLd_mCfpPBqsunFAk7VGltehSUGk_L9NWaH_ggoCidG8DhZp7Toph0ZVM1kMGMNnS5oEW-hCUrGM0ynsOi5SKbKFGBcgEsgpvIklHGaJ4tMs4WbJnOeFYXlIu6ZSxv6jk2BXohVRoCh0d9YsuIoRq2DpVKOu_elPg-yK0GOPkXg--MLfFCjeCG_fBTToXtJxF2GTH_AcyMxFY">