<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60400>60400</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AArch64][Intrinsic] Instruction generation problem Integer binary operations that have an immediate form
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
lizhijin1024
</td>
</tr>
</table>
<pre>
I find that intrinsics `svlsr_n_{type}_x` or `svmul_n_{type}_x`, gcc10.2 or later version will always generate instruction without p register, while the instruciton compiled with clang has p register.
Here is the example:
```
#include<arm_sve.h>
#define NUM 19
svuint32_t foo_mul (svbool_t pg, svuint32_t op) {
op = svmul_n_u32_x(pg, op, NUM);
return op;
}
svuint32_t foo_lsr(svbool_t pg, svuint32_t op) {
op = svlsr_n_u32_x(pg, op, NUM);
return op;
}
```
Assembly generated by gcc12.2: https://godbolt.org/z/6sc3EcWGW

Assembly generated by clang trunk: https://godbolt.org/z/s6zMrMxos

Thinking the case of auto loop vectorization, both gcc and clang generate `lsr` and `mul` instructions with no `p`.
```
#include <stdint.h>
void shl_int8_t( int8_t *restrict a, int8_t *restrict b, int8_t *restrict c, int n )
{
for ( int i = 0; i < n; ++i ) {
b[i] = b[i] << 7;
a[i] = a[i] * 80;
}
}
```
clang trunk: https://godbolt.org/z/EKfqsz8Wf
gcc trunk: https://godbolt.org/z/aoTqxK153
So can we change the implemention of shift and integer binary intrinsics that have an immediate form like gcc10.2 or later version?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vktz2zYQ_jXQZUcaEARfBx0kK2o9mfTSdHLUgOCSRAICDADKj1_fASnbchK3aTvleCxgH-Du4vt2KbxXnUHckmxPssNKTKG3bqvVY68-K5NQxle1bR62t9Aq00DoRQBlglPGK-mB5NSftXcncyLFPjyMSIrD6Z7kFKxbtMOkv9cSdgOdlAndsGioRUAHZ3ReWQN3SmsQ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