<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69038>69038</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[InstCombine] `a && (a | b)` is not simplified
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
k-arrows
</td>
</tr>
</table>
<pre>
https://alive2.llvm.org/ce/z/Z5Ly98
```llvm
define i32 @src(i32 %0, i32 %1) {
%2:
%3 = icmp ne i32 %0, 0
%4 = or i32 %1, %0
%5 = icmp ne i32 %4, 0
%6 = and i1 %3, %5
%7 = zext i1 %6 to i32
ret i32 %7
}
=>
define i32 @tgt(i32 %0, i32 %1) {
%2:
%3 = icmp ne i32 %0, 0
%4 = zext i1 %3 to i32
ret i32 %4
}
Transformation seems to be correct!
```
Reproducer:
https://godbolt.org/z/YEqW7sE6n
```cpp
int foo(int a, int b)
{
return a && (a | b);
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0lM1u2zAMx5-GvggNZMqfBx-apAYG7DQMGLabbNGJNlvKJLld-_SDFafNgvY4IIhF6ac_P0xaeq8PhqiBfAv5PpFzOFrX_LqTztknn3RWPTfHEE4exD1gC9jKUT8SbsbxcdpYdwBsewJsXwDbH_nn57oCvgd-DwU__xbwvKVo0IaYFsgg4971gFU0MOeAO7auU8CaQblddTDHxXc02HIuGIg90_10Yhe1VYBfUVmkrLtS3Z3BNyZ_Tym7VSoiJY1iOo3-V6X8iikj80J_wgoVLNhF8cI4ChcH5ZpYuV8XYg_i4b0ShUP4_yW6Clp8HHR2E_RXJ40frJtk0NYwTzT55XZHrLfOUR8A05tOWM34_4VOzqq5J_ca-b9tdrCqs2NYW2zpru8Pv7-V_qEwN7L96XTe0SawwdqlZCYwGetlAusA60v020tqS26zM0wywAKwYICVZFDuzrjY3r6ki7dENULVopYJNWlRl5hVVSqSY9NVkjo19FjWPC0V5b0aqMgoLXmX971IdIMcRcrTjCPnqdhwXvVCdgMqErJUA2ScJqnH19lKtPczNUXNRZWMsqPRx0FFNPTE4iEgLnPrmuXOXTcfPGR81D74N5Wgwxgn_JPxYWenThuCfM-g4B-kX3CmPTM2MK-n06gHTSqZ3XjzKTjocJy7TW8nwDbO-flxd3L2Z2yBNgbpAduYxN8AAAD__3k8LcE">