<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/89516>89516</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            miscompile of vanilla integer code by InstCombine
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            miscompilation,
            llvm:instcombine
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          regehr
      </td>
    </tr>
</table>

<pre>
    https://alive2.llvm.org/ce/z/jRfVLr

this function:
```llvm
define i8 @f(i8 %0, i8 %1) {
  %3 = icmp slt i8 %1, 0
  %4 = shl i8 1, %0
  %5 = srem i8 1, %4
  %6 = add i8 %5, %4
  %7 = select i1 %3, i8 %6, i8 %5
  ret i8 %7
}
```
is getting mis-optimized to:
```llvm
define i8 @f(i8 %0, i8 %1) {
  %3 = icmp ne i8 %0, 0
  %4 = zext i1 %3 to i8
  ret i8 %4
}
```
here I'll just give Alive's work:
```
Example:
i8 %#0 = #x00 (0)
i8 %#1 = #xff (255, -1)

Source:
i1 %#3 = #x1 (1)
i8 %#4 = #x01 (1)
i8 %#5 = #x00 (0)
i8 %#6 = #x01 (1)
i8 %#7 = #x01 (1)

Target:
i1 %#3 = #x0 (0)
i8 %#4 = #x00 (0)
Source value: #x01 (1)
Target value: #x00 (0)
```

cc @nunoplopes @hatsunespica
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0lMGOszYQx5_GXKxEZsABDhzyJUVaqae26t2YAbw1GNkm3d2nr8DZJEo2u6dKkWN7fjPznwFGOKe6EbEk_Bfhx0jMvje2tNhhb6PaNO9l7_3kSLInUBGohFYnhK3Wp2FrbEegkkig-iBQvf7R_v27JexI2D6svleOtvMovTLjEiLYdiz8liDhqsFWjUhVTknKWgL5sgPOCBxo2MYECkqyX4Gny1VCSXKkSg4TddpfuQNlN1S6Uq7XC7Ba18BXgAfA4nBLpDfEbiVE05xz8C-YLERBjdJTFa_6rup31y3_dLL4qTk79yU73jUoHJWjHXqvxo4Oym3M5NWgPrCh3vyfPT37nj0eW_qBb5dKqTdU5Y-Vpd9X1qNF-kIg05q-zs7TTp2Q7pdXjEDm6L_G_vNYYjj-9iaGSePFHBISSNiqjkDyxhglkDMCxR0SX5C2XZDzI93EFzSsf5rZypsU8dk_ufgvN3n8mCG9iniG8J917n6Okj1FwvqXsB3670p4ljx9qi-0hZ6EnpfmfJk95L1j7uLcPdGwSrm8r-M8mkmbCd1y6oV384huUlJETZk0RVKICMs4i5MdTwqWR31ZyDRrk6ROijRmHFopkctYAqR1UWeCR6oEBilLgQHwHPJtEdeMp23NdyxueN6QlOEglL5Mt0g5N2OZFzzeRVrUqN06KAEG5aQZJqXFOtoACBwIwPr1JXs1Oi_NUKsRFxM_RrZcTJt67hxJmVbOu2sWr7zG8hISqWnpSYxKa0HV6LFDS6VpkNbv9GV0_hBCR7PVd9O5U76f6600A4FqFRP-NpM1ryg9gWotyRGo1qr-CwAA__9WMo10">