<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/154025>154025</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missed optimization: fold (x0 | x1 | x2 != 0 ? True : C) ? x0 : 0 -> x0
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zxt5
</td>
</tr>
</table>
<pre>
```
define i32 @src(i32 %arg0, i32 %arg1, i32 %arg2, i32 %arg3) {
%v0 = or i32 %arg3, %arg2
%v1 = icmp ne i32 %arg1, 0
%v2 = or i32 %v0, %arg0
%v3 = icmp ne i32 %v2, 0
%v4 = select i1 %v3, i1 true, i1 %v1
%v5 = select i1 %v4, i32 %arg0, i32 0
ret i32 %v5
}
define i32 @tgt(i32 %arg0, i32 %arg1, i32 %arg2, i32 %arg3) {
ret i32 %arg0
}
```
Alive2: https://alive2.llvm.org/ce/z/sz6mjV
Godbolt: https://godbolt.org/z/PsjjK7Pxz
Pattern found in https://github.com/dtcxzyw/llvm-opt-benchmark/blob/main/bench/ffmpeg/optimized/matroskadec.ll
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysU8Fu4yAQ_ZrxBTXCg4njgw9uuuxhtVIPq71jgxNSbCLAaZqvX-GkSdOt9rSSZXvgvXkzb0CGYDaj1jXwR-BPmZzi1vn6dIw8a516q2FJLw9tlO7NqIlhSKCgwXeAqzlALv2GAq7JLczvQ7wPGWBFoHwE2pC0dKAE2BNx_h6zvrLfcfmMM92wJ--l3OToFYaf0h3oLdkNxb5KdsD7VMUMCtrqLhKTn4lzNzmJftKX37m4K4l_QSruLbj6dZbyOl4r4EAbKJ_S-7PrcRP_j-sf9C6eXBQ_DBxo01hz0AisIdsY9wFYAygAhZzXF9YehoXzG0DRaUBxAhThtBx2v4E2351qnY1_kzfnjQsxcZ7DbvejfD6ezqrPMkbtR9K7aVTEjJ_5Jm6ndtG5AVCo2B1Pb6-AIhXz4PbxodVjtx2kfwEUrXUtoBikGVOUdgBF3w97ncTdPprBnLSaMdG78CKV7hbWZqpmqmKVzHSdl5wXPF9WVbatVcULWspVz8tlV7aVRLVE1efLPkfGNM9MjRQ5XeVlXuIqrxZyWSBbFbIrSqbKlYaC6kEae7UvMyFMus55QZFnVrbahvlKIo76lcy7gJhuqK_nNttpE6Cg1oQYbmmiiVbXP00IWpFLazIaN6YZ9M4qArg6UgLlmhzz8ycdgTyd1nQFBfnlJ00SfD0fFiZIwrOGUPIA7Bs50mzytv7HQFI179PYe7fTXQQUcw8BUFyaPNT4JwAA__9iVEQO">