<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/120203>120203</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[X86] AVX1 targets failure to recognise VPTEST YMM pattern
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:X86
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
RKSimon
</td>
</tr>
</table>
<pre>
```ll
define i1 @both_equal_v32qi(<32 x i8> %a, <32 x i8> %b, <32 x i8> %v) {
entry:
%0 = icmp ne <32 x i8> %v, %a
%1 = icmp ne <32 x i8> %v, %b
%2 = or <32 x i1> %0, %1
%3 = bitcast <32 x i1> %2 to i32
%cmp5 = icmp eq i32 %3, 0
ret i1 %cmp5
}
define i1 @both_equal_v16qi(<16 x i8> %a, <16 x i8> %b, <16 x i8> %v) {
entry:
%0 = icmp ne <16 x i8> %v, %a
%1 = icmp ne <16 x i8> %v, %b
%2 = or <16 x i1> %0, %1
%3 = bitcast <16 x i1> %2 to i16
%cmp5 = icmp eq i16 %3, 0
ret i1 %cmp5
}
```
llc -mcpu=znver2
```asm
both_equal_v32qi: # @both_equal_v32qi
vpxor %ymm0, %ymm2, %ymm0
vpxor %ymm1, %ymm2, %ymm1
vpor %ymm1, %ymm0, %ymm0
vptest %ymm0, %ymm0
sete %al
vzeroupper
retq
both_equal_v16qi: # @both_equal_v16qi
vpxor %xmm0, %xmm2, %xmm0
vpxor %xmm1, %xmm2, %xmm1
vpor %xmm1, %xmm0, %xmm0
vptest %xmm0, %xmm0
sete %al
retq
```
llc -mcpu=btver2
```asm
both_equal_v32qi: # @both_equal_v32qi
vpcmpeqb %xmm0, %xmm2, %xmm3
vextractf128 $1, %ymm2, %xmm4
vpcmpeqb %xmm1, %xmm2, %xmm2
vextractf128 $1, %ymm0, %xmm0
vextractf128 $1, %ymm1, %xmm1
vpcmpeqb %xmm0, %xmm4, %xmm0
vpcmpeqb %xmm1, %xmm4, %xmm1
vpand %xmm2, %xmm3, %xmm2
vpand %xmm1, %xmm0, %xmm0
vpand %xmm0, %xmm2, %xmm0
vpmovmskb %xmm0, %eax
xorl $65535, %eax # imm = 0xFFFF
sete %al
retq
both_equal_v16qi: # @both_equal_v16qi
vpxor %xmm0, %xmm2, %xmm0
vpxor %xmm1, %xmm2, %xmm1
vpor %xmm1, %xmm0, %xmm0
vptest %xmm0, %xmm0
sete %al
retq
```
The AVX2 codegen is legal on AVX1 (just replace vpxor/vpor with vxorps/vorps).
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzslkGPmzgUgH-Nc7Emsp-BJAcOdNJcVpVW21HVPVWGvCRubSC2yTL99SsgmSQTJ8PedzQK6PG9Z_zxMJbOqW2JmJL4E4mXE9n4XWXTv_74qkxVTvJq_ZqShA3_WhOWrXGjSqSKUxKxvPK7H7hvpP5xELBXBOZEPAugLVVzIj5TArEk8ExvonkweiCwoGT2ibAMS29ficgIy7orjBKxpKowNS0xmPg8DMYy2p3wcXx-4qHnK3tG-RFlR5SfUNGjufKFdP6WB-orqgSc8MLU8flmcN9d68t0dVlPWfS90AEmLCOzZff7wDZPTrZ5ErJ9Hc2D0Tu2g7pvMj_QHeaDugd0vO5rftDNk_u6eTJS96nPCcu0LuiTKeqGiOXv8oAWLgHpDGHZTfOLjIb_CIjg28LeEg51W9mejF-NOTl4NQbOp-yGH-I8SPMrui9-y7N71T12rh8xDj0ea0p9mfsbbdXUNdouaNHv36nqO_e_qOoTWHbpqD3fVnuedRtydOJ5kOdD4Tc91yC7V7jX8xjq_byXc9Rxr9NyP77TxvRUYWrc52e1972JyzxsvZWF33CYD3lRoMVaY6LQYI9sw-hR3kt9TPN3D3SsgOje8w3l8WDe9XiyXL_xV3bDCq74MX13yY95AUx1MO5XHpw_yvaCbSurj2KTOBbxGbr3lipj-nWWtavVavVoZfh_EfhoEXjZIc2-fQdaVGvcYkmVoxq3UtOq7C50H6v5z8Z5arHWssBhXg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