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

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] missing fold for 'or' with mismatched extends
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    ```ll
define i5 @src(i3 %x) {
  %sx = sext i3 %x to i5
  %notx = xor i3 %x, -1
  %znotx = zext i3 %notx to i5
  %r = or i5 %sx, %znotx
  ret i5 %r
}

define i5 @tgt(i3 %x) {
  %sx = sext i3 %x to i5
  %r = or i5 %sx, 7
  ret i5 %r
}
```
There's also a potential reduction when the 'not' is paired with the sext:
https://alive2.llvm.org/ce/z/fBg_nG

Noticed while looking at the examples in:
#59482
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykU02Po0oM_DXmYk0EBkI4cHgzEU_v8k57XzVgwLtNd9TtzGTn168gmczsx2GllZCg7aJcVWqbGGVyzA2Uj1AeE3PW2YcmeDXKQaZZk84P3xrYp9fHWkiPkP4z8CiOUUqEIo2hBzpIjkDlBahGqB6vMFxL8YKQHzHyRfEGQvUo5QeM83pFXXzAO9MTPmQfQK931Os711b7mS5sqJWqvCpYud4Y3nCB9dYP1xJUx9vHrx510r_1-FtR1R-oeQv_evw0c2CgKqKx0aPBk1d2KsZi4OHcq3iHLzM71JkRqHJegSqUiCcjgQd8EZ235ioX8pvdWfUU1xO1QK2x8sy0s_Z52fkwAbU9A7WvQO34OH12_35M6n-v0q_Es1hG6_1XcRMa3YbwxSwnyxHF3WcB5WVdHCgZmnyo89ok3GT7Kkspp5SSuRnr7JB2db3PDZuxOPSF6ep9Tv1Q1L1JOZGGUqKMsiLL031BO-qGvOgPPBZmLLguoUh5MWLvFhKJ8cxNWZdZnVjTsY3btSdy_IJbE4jWLQjN-s9Dd54iFKmVqPGdRUXtti__uahPfunEMZRHXCTG1fXo7YCjD2vyPqzBb3EvEhej_cwD8kXZDTE5B9v8GPokOp-7Xe8XoHadeHs9nIL_wr0CtZvOCNRuPr4HAAD__7KhGGc">