<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/141753>141753</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[InstCombine] Missed optimization for add + and + icmp pattern
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:instcombine,
missed-optimization
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nikic
</td>
</tr>
</table>
<pre>
https://alive2.llvm.org/ce/z/7A_uJr
```llvm
define i1 @src(i8 range(i8 0, 4) %arg) {
%add = add nsw i8 %arg, -1
%and = and i8 %add, -3
%cmp = icmp eq i8 %and, 0
ret i1 %cmp
}
define i1 @tgt(i8 range(i8 0, 4) %arg) {
%and = and i8 %arg, 1
%cmp = icmp ne i8 %and, 0
ret i1 %cmp
}
```
Not sure how to generalize this best.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUk9-unCAQxp9mvCG7gUGOeuGFZzcmbdK-QoOCSquwBdyT7tM34u7270WbkAzRn8P3jR8yBDNarWsQryDOmVzj5HxtzRfTZ51T3-opxksA3gC2gK2czVXjcZ6vy9H5EbDtNWB7A2yL5tP63gNttvVC97WBQBulB2M1MYxAToPvAUtTEi_tqPctBTyRHLAigEJujSsCxSvQhqQnShHgZ7JVG96IKZ_ciRzYE7N3zKoHolRC-APpl0tCzLbRXx-YTRhNlNcxKU3wZqY4765-cRHH-N8u_pS3O2B_Vbcd9c_qHgPflX50kYTVazK5NxIdGbXVXs7mpkmcTCCdDvGYqZqrilcy0zUr8jLnohBVNtUdU4JR1tNOivKF5aoUueioGniOFDnLTI0UBRVYMuRCVMeXqsKcDkOFXMqh4pBTvUgzP4OSmRBWXbOcFYJns-z0HFLmEFNEeGNsiL1bOmM1IAKeAHExIWh1cJdoFnOT0Ti7vRPnzNfbZ4duHQPkdDYhhh9nRRPnlOh3NsTTvac4kw-pHfm5HRmcT6kCfE3_Zatp-hcZo_Y2W_382x0YTZzW7ti7BbBN6vdyuHj3WfcRsE1uA2B7N3yt8XsAAAD__w4k_dU">