<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61923>61923</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[X86] Worse code generation from patch 24780e13e5be1501e34330148137a10fa9965166
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
max-quazan
</td>
</tr>
</table>
<pre>
We see worse code generation on memcmp-like function caused by
```
commit 24780e13e5be1501e34330148137a10fa9965166 (HEAD -> main)
Author: Simon Pilgrim <llvm-dev@redking.me.uk>
Date: Sat Apr 1 15:38:38 2023 +0100
[X86] MatchVectorAllEqualTest - add support for icmp(reduce_and(X),-1) allof reduction patterns
Also, improve codegen in LowerVectorAllEqual for X == -1 cases to reduce over sized vector using a AND reduction
```
Asm on last release: https://godbolt.org/z/GxvaPbMq1
Current asm: https://godbolt.org/z/EGz1n7Wo8
Loop block changedfrom
```
.LBB0_3: # %memcmp.loop
vmovdqu (%rsi,%rdx), %xmm0
vmovdqu 16(%rsi,%rdx), %xmm1
vpsubb 16(%rdi,%rdx), %xmm1, %xmm1
vpsubb (%rdi,%rdx), %xmm0, %xmm0
vpor %xmm1, %xmm0, %xmm0
vptest %xmm0, %xmm0
jne .LBB0_19
```
to
```
.LBB0_3: # %memcmp.loop
vmovdqu (%rsi,%rdx), %xmm0
vmovdqu 16(%rsi,%rdx), %xmm1
vpcmpeqb (%rdi,%rdx), %xmm0, %xmm0
vpmovmskb %xmm0, %r8d
vpcmpeqb 16(%rdi,%rdx), %xmm1, %xmm0
vpmovmskb %xmm0, %r9d
shll $16, %r9d
orl %r8d, %r9d
cmpl $-1, %r9d
jne .LBB0_19
```
I am not sure into how big performance regression this translates (build & benchmark runs are underway), but the assembly definitely looks worse in the loop block.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVktv4zgT_DX0pWFDJCVZPvjgxPF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