<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115466>115466</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[InstCombine] Missed optimization: icmp pred (ext X), (ext_inreg Y) -> icmp pred X, trunc nsw/nuw (ext_inreg Y)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:instcombine,
missed-optimization
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
dtcxzyw
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dtcxzyw
</td>
</tr>
</table>
<pre>
Alive2: https://alive2.llvm.org/ce/z/7xRX6r
```
define i1 @src(i16 %v19, i64 %v20) {
entry:
%0 = trunc i64 %v20 to i32
%conv2 = and i32 %0, 65535
%conv3 = zext i16 %v19 to i32
%cmp = icmp ugt i32 %conv2, %conv3
ret i1 %cmp
}
define i1 @tgt(i16 %v19, i64 %v20) {
entry:
%0 = trunc i64 %v20 to i16
%cmp = icmp ugt i16 %0, %v19
ret i1 %cmp
}
```
This pattern exists in qemu/linux/spike/...
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0U01v2zgQ_TWjC2FBHH5IOujgxCtgD3tZ7CF7KvTByGwlSiUpx_GvL0gpTdIURS8FDJhDvfeG82amcU4PRqkKxB0g9r673p6fABHEKWlWf55ttV8m7dw_V8dRXxQCO5Kz94sDdgSsAesm3qfjeJnS2Q6AdacA6xtgnV__fZAWshNkR5DZ_othrx61UURTAjxztgMsNJUEUFxoCXhPtOQxwgywJJDfbTxlvH0OuWNEAiQjwE7E29V0b1jEz0QzfIPrZnPBiG1MH75FcsglhWDiBySLyJu6evL6sJ-ITksE6nBYB_-iG5MF7Re5F45VPlYdqbs1-Wk_fLTGD_7PWEPlL6vYEmZ7BSHx77z_fY__O2tHlsZ7ZQ1RV-28I9qQr2paAetRm_UKWLtFfwkDk6bpRkv6ivUlK5tEVTRnNJOCF0VyrgTvELmUbduhyjktC971TduVXEnVyCbRFWbIKc0KShnFPM1FqVoh26LEx0JwDjxTU6PH79OaaOdWVVEquJTJ2LRqdPtGBAiwozbOd_PUaqPCcuA9IE7aOdUf5sXrSd8ar2ezL46tAu3QroMDno2h5NdcXvsx7tvfxvn7XVOcyD9RjryTY8etGYtVPQEswhw-AJZbQ0L4SRurBvJ_mIEDsL_e4B8Cauu6cU-AtVmfPrKS1Y7V-10etD-vbdrNU2hQMGD7Oyx2_qw6D1hHwxxgvXt2qfBbAAAA__9zIDkr">