<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/135353>135353</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Clang is unable to generate maddubs_epi16 intrinsics.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
topitopotin
</td>
</tr>
</table>
<pre>
Clang 20.1.0 is unable to generate `vpmaddubsw`. Tested with the following code stub on Compiler Explorer with compiling options `-O2 -march=znver4`
```c
#include <cstdint>
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define CLIP(low,high,value) MAX((low),MIN((high),(value)))
void maddubs(const uint8_t* const __restrict in_a, const int8_t* const __restrict in_b, int16_t* __restrict result)
{
int d = 64;
for (int i = 0, dst = 0; i < d; i += 2, dst++){
result[dst] = CLIP(INT16_MIN, INT16_MAX, (in_a[i + 0] * in_b[i + 0] + in_a[i + 1] * in_b[i + 1]));
}
}
void madd(const int16_t* const __restrict in_a, const int16_t* const __restrict in_b, int32_t* __restrict result)
{
int d = 32;
for (int i = 0, dst = 0; i < d; i += 2, dst++){
result[dst] = CLIP(INT32_MIN, INT32_MAX, (in_a[i + 0] * in_b[i + 0] + in_a[i + 1] * in_b[i + 1]));
}
}
```
The madd function vectorizes properly with `vpmaddwd` as expected.
https://godbolt.org/z/fMdcP8hjP
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEVUFv2zoM_jXMhWggU7ZjH3xInAUo8LbXQw_vFtiWEmtQJEOSk62__kG203XF0GGnAQISfvxEUvwMsvFenY2UFWQ7yParZgy9dVWwgwp2sEGZVWvF96rWjTkjsXWyZqg8jqZptcRg8SyNdE2QCDm7DpdGiLH1N8jZGp-lD1LgTYUeQy_xZLW2N2XO2Fkh0YexRWuwtpdBaenw07dBWyfdfKOb4Mi2Q1DW-Jjh4V_Ch0vjuh74_sVcpUshZ8C28eRsPl00iCvT6VFIBF53PghlAvBPC5W4kCdlJH7e_gdUNEB1C1QiUDGfBqiMdCoiPhmHV3j7Bv4p2OOXD4LVfxas_ufxCajQ9gZU9-rcA9XXRo8yhp7LvrtLoHrODVTM1AgBFfcLP-JP52qVwEUroKKzxgcclQnFMQBtcQaORyd9cKoLqMwxPmtxfExsI1GZkOQz543XST_qsFSy2SEC22LkokDge8xT4LsJO1kX-xddanKxGFX4sBh8N-E1iuUv7aKDFlY04ylhM8fDe-5sF93Zfoqz9Pjxy3OSH6cO1rgYscH1XMKxgWw3pUA23aTt_M536A5_4ia_5Eb0_hHMpcFmP7Vj_06bV2He9PL3wnzEvCvD6Y-V4fS3lOH0Rplo_CVl7tMF2Pa5l5NCeBpNF2cTXmUXrFMv0uPg7CCd_j5PsdepeBOQM2w8ym-D7IIUa2DbPoTBTyPgAHQ4W9FaHdbWnYEOL0CH02fRPRX916eVqLgoedmsZJVs0pRveJYlq77K0jzlJWdtSrxklDLWFOxU8IZ3RZln2UpVxChjaZIklBBna9Hkp2TTZcRLKsqWIGXy0ii91vp6iblXyvtRVgnPeMZXumml9tN-IOriGgCiuCpcFS88tOPZQ8q08sH_CBFU0NNSmW9ke5w3yK9XxzKJjnJQSR4_OqeMV51fr0anq3dNUqEf23VnL0CHmG_5eRic_Sq7AHSY6vdAh-UJ14r-DwAA__9Wgvu_">