<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/89500>89500</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[InstCombine] Miscompilation with poison vectors in `src_and_eq_C_xor_OrAndNotC `
</td>
</tr>
<tr>
<th>Labels</th>
<td>
miscompilation,
llvm:instcombine
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dtcxzyw
</td>
</tr>
</table>
<pre>
Alive2: https://alive2.llvm.org/ce/z/yB3oAx
```
define <2 x i32> @src_and_eq_C_xor_OrAndNotC(<2 x i32> %0, <2 x i32> %1, <2 x i32> %2) {
entry:
%and = and <2 x i32> %1, %0
%cmp = icmp eq <2 x i32> %and, %2
%xor = xor <2 x i32> %1, %0
%or = or <2 x i32> %1, %0
%not = xor <2 x i32> %2, <i32 -1, i32 poison>
%and1 = and <2 x i32> %or, %not
%cond = select <2 x i1> %cmp, <2 x i32> %xor, <2 x i32> %and1
ret <2 x i32> %cond
}
```
```
----------------------------------------
define <2 x i32> @src_and_eq_C_xor_OrAndNotC(<2 x i32> %#0, <2 x i32> %#1, <2 x i32> %#2) {
entry:
%and = and <2 x i32> %#1, %#0
%cmp = icmp eq <2 x i32> %and, %#2
%xor = xor <2 x i32> %#1, %#0
%or = or <2 x i32> %#1, %#0
%not = xor <2 x i32> %#2, { 4294967295, poison }
%and1 = and <2 x i32> %or, %not
%cond = select <2 x i1> %cmp, <2 x i32> %xor, <2 x i32> %and1
ret <2 x i32> %cond
}
=>
define <2 x i32> @src_and_eq_C_xor_OrAndNotC(<2 x i32> %#0, <2 x i32> %#1, <2 x i32> %#2) nofree willreturn memory(none) {
entry:
%or = or <2 x i32> %#1, %#0
%not = xor <2 x i32> %#2, { 4294967295, poison }
%and1 = and <2 x i32> %or, %not
ret <2 x i32> %and1
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source
Example:
<2 x i32> %#0 = < poison, #x00000000 (0) >
<2 x i32> %#1 = < poison, #x00000000 (0) >
<2 x i32> %#2 = < poison, #x00000000 (0) >
Source:
<2 x i32> %and = < poison, #x00000000 (0) >
<2 x i1> %cmp = < poison, #x1 (1) >
<2 x i32> %xor = < poison, #x00000000 (0) >
<2 x i32> %or = < poison, #x00000000 (0) >
<2 x i32> %not = < poison, poison >
<2 x i32> %and1 = < poison, poison >
<2 x i32> %cond = < poison, #x00000000 (0) >
Target:
<2 x i32> %or = < poison, #x00000000 (0) >
<2 x i32> %not = < poison, poison >
<2 x i32> %and1 = < poison, poison >
Source value: < poison, #x00000000 (0) >
Target value: < poison, poison >
Summary:
0 correct transformations
1 incorrect transformations
0 failed-to-prove transformations
0 Alive2 errors
```
cc @nikic
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUV99v4jgQ_muGF6uVMw6EPOSBQpHu4W6l3r4j4xjwXWKztkNh__qTk5CWNuHobqXbQyg_55vxfPPZE3Pn1FZLmcH4AcaLEa_8ztgs9-L4_fQ8Wpv8lM0KdZAIbEZ23u8dsBngEnDJ6-f3RXEo743dAi6FBFx-B1yeHpiZHYEugM5gQtt_fZvLjdKSAJsjORLFENgjgZg6K1Zc5yv5bTVfHY1dfbEznf9h_Bxw-sYaxxRw_tYHjqPepwiYEkgemvhSe3sKOdR3JBhwnRNgC9Kce32GiC8AUe5rgAoX8tt7ENd5C8NXsKOxNaw53xCntb_FHHCsjR92jy01iiG5q8Hham-UMxrY4yUb0TAdxraBtfGvGTEth04WUvgOF7UwUe57a3Ns_fUQGLXurfTv34d4rbySRa_O3t7Wx7sbf58pVUDWr1ZA1i9YQPZzmu08t9F_SLn1KG4U73DAKxIeBl1VcsPOPLBDYkzjdJJgOg5PGjWTThG_pJxv1zNbdBPzv1aiNhsrJXlWRWGlr6wmpSyNPQFOtdHy38T6PxRBb5Veyti5_2q5dhtjS-6V0SQ30mnAxJODtGpzAoxerz-PT09fnkIn_crtVnqiHCmNle2gTeWI33FNnKmskBf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