<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/110392>110392</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AArch64][SVE] Fold svmul and svdiv with all-zero operands to zero vector
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
k-arrows
</td>
</tr>
</table>
<pre>
GCC has implemented this in recent patches. Consider the following example.
https://godbolt.org/z/dPY9f3oxe
```cpp
#include <arm_sve.h>
svint64_t test1 (svbool_t pg, svint64_t op2)
{
return svmul_x (pg, svdup_s64 (0), op2);
}
svint64_t test2 (svbool_t pg, svint64_t op2)
{
return svdiv_x (pg, svdup_s64 (0), op2);
}
```
GCC:
```asm
test1(__SVBool_t, __SVInt64_t):
mov z0.b, #0
ret
test2(__SVBool_t, __SVInt64_t):
mov z0.b, #0
ret
```
Clang:
```asm
test1(__SVBool_t, __SVInt64_t):
mov z1.d, #0
mul z0.d, p0/m, z0.d, z1.d
ret
test2(__SVBool_t, __SVInt64_t):
mov z1.d, #0
sdivr z0.d, p0/m, z0.d, z1.d
ret
```
I referred to the GCC patch below.
[svmul](https://github.com/gcc-mirror/gcc/commit/08aba2dd8c9390b6131cca0aac069f97eeddc9d2#diff-a0457d88b0d47e7fa65ca14363689f0d158f12cf779b2b453d6108d6c8b77c17)
[svdiv](https://github.com/gcc-mirror/gcc/commit/e311dd13a9adbc51d56971cba06e1ff15a4256d2#diff-5266094cae22f614a126169c383227dab55595771ecf184cb8c9527965877354)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyslV-P2zYMwD-N8iIkkChLth78cMk1Rd8GFCiwp0D_HGuTLUNSfF0__WAnadbbbRi6C4LYokjqRzKkVM7-PDrXIr5H_HmjLqWPqf19q1KKL3mjo_2j_Xg44F5l7IcpuMGNxVlcep-xH3Fyxo0FT6qY3uUdPsQxe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