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

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] Unprofitable transformation
        </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://llvm.godbolt.org/z/PP1q1hTYE
```llvm
define i8 @src(i8 noundef %_23) {
  %_17 = lshr i8 %_23, 4
  %_18 = and i8 %_23, 15
  %_16 = add nuw nsw i8 %_17, %_18
  ret i8 %_16
}
define i8 @tgt(i8 noundef %_23) {
  %_17 = lshr i8 %_23, 4
  %1 = mul i8 %_17, -15
  %_16 = add i8 %1, %_23
  ret i8 %_16
}
```
This goes against our usual guideline to avoid introducing mul out of thin air, and also increases the length of the dependence chain.

From: https://github.com/rust-lang/rust/issues/143513
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysk01vnDAQhn-NuYx2ZQxew4EDyRaptxzSQ0-VwQO4NfbWH4maX1_hzYcSVTlVQgLhx55nXo1lCHqxiB3hN4SfC5ni6nxn9S89FaNTf7o1xksgVU_YQNhgzMN2XJwanYlH5xfChifChru78ne53n__QmhPTvT67CyhvcJZWwTdAKlp8BNhjW7AumQVzkAY_8Eqwlog4obQHvKfUgCpzmDC6vPGZ-gW6jekyYi06j1R8jfkdEWUApsewYbHF7QUO3o9JuMe4-vaaW9CnD-qxyX-H_UyA1sy720O_za_MuWLL6s-8X2NntD-ftUBFocB5CK1DRFc8pBCkgaWpBWavbXoQD44rUDb6J1Kk7ZLVnMpgpshrtqC1H4vv0ctTXCg7eRRBgwQVwSDdonrFUZQeEGr0E4I0yq1Pe5atB-820jVw_tpWnRc03ic3EbY4FOIByPt8vxN2KBDSBgIG8q64mVVqK5SbdXKArtS8FI0bSVEsXa8xnke65mqpkZOKacndhJzq6a25qNoC90xyjgV9EQb2lbiOI1qmrDlkgusxchITXGT2hzzgDu_FLl2V9aiFKfCyBFNyJeEsTzXVb9nOrlt1BYJY4TdEsY2HQKqg7tEveknGbWz-xo_F77btx3GtARSU6NDDG-1oo4mX8GvNsTb5zP5Gb7Zi3ezjnI0CNFLG2bnt3xskbzpPkkzS15fh4t3P3H6EGju66FjfwMAAP__XfwwFQ">