<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/134093>134093</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missing fold `(X == 0) | (trunc nuw X to i1) -> true`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:optimizations,
missed-optimization
</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/RN4Sch
```
----------------------------------------
define i1 @src(i8 %x) {
#0:
%cmp = icmp eq i8 %x, 0
%trunc = trunc nuw i8 %x to i1
%or = or i1 %cmp, %trunc
ret i1 %or
}
=>
define i1 @tgt(i8 %x) {
#0:
ret i1 1
}
Transformation seems to be correct!
```
It is a variant of https://github.com/llvm/llvm-project/issues/132678. cc @scottmcm
See also https://github.com/dtcxzyw/llvm-opt-benchmark/issues/2234#issuecomment-2772790195.
I don't know how to generalize this :(
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykU01vqzgU_TWXzVUic83nggVtitTFzGI6i26NMcFTwBnbSdr8-ie7SVt18d6THkJguEfH595zLJzT-1WpBvI7yHeJOPrJ2Gbw8vXydk56M7w17axPioC3OHl_cMBboA6oE_H_dp5Py9bYPVAnFVB3Aer--Tt7khOwFgp2vVm7-c0LWDuoUa8KdYqQMWclUKUrBMpfgWqE8i5QE2dBC2sxVORyQOA71GGh_scP_D2yG8bb4yoj6n21Hs83HHqDOr0BjY0oY6OESB6IbhQRZpW_Vo0NcspdePId8IfvHfi9_1UHV7b0g-lfK1Y3GrsIr82KTqnFBZG9QmmsVdIDpd8m_OhROxR4ElaL1aMZv1m213469ltpFqAuGHd9bQ7W_BcpO-3cUTmgLuVUlNUWpYwmSOP9Ihdg7ZNSKGZnfsZ9DdCN3hz8plernBZhX75uQsQzIB6_pVkWtfoNlSWVNUvrfBv6Y-0jDmYFKj2-rOaMkzmHQezVqqyY9UWhn7TDKKRKhoYPNa9Fopq0zHjB8owXydSIepQDG9KeZ_0gJKX1mFeMxEgsFaKoEt0Qo5xljNIsZ7zYFmys66xUNVNDVWUFZEwtQs8fiU-i7CblGat5MotezS4eJKI4W96ag9eLvkQLHRAB3QPRop1Tw-ZrMdTyXWKbOK7-uHeQsVk77z5389rPqvlLO6fXPY5mHjDYTtUzxtjtkL1nKwS1-kz48zXbVOMG-EPIvoKCJUc7N38Sj9j1qaEfAQAA__9FM0Co">