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

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] Commuted pattern is not handled
        </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>
    https://godbolt.org/z/KTbTov4rb
```
define i8 @or_lshr1(i8 %x, i8 %y, i8 %z, i8 %shamt) {
  %sx = lshr i8 %x, %shamt
 %sy = lshr i8 %y, %shamt
  %a = or i8 %sx, %z
  %r = or i8 %sy, %a
  ret i8 %r
}

define i8 @or_lshr2(i8 %x, i8 %y, i8 %z, i8 %shamt) {
  %sx = lshr i8 %x, %shamt
  %sy = lshr i8 %y, %shamt
  %a = or i8 %z, %sx
  %r = or i8 %sy, %a
  ret i8 %r
}
```
```
define i8 @or_lshr1(i8 %x, i8 %y, i8 %z, i8 %shamt) {
  %1 = or i8 %x, %y
  %2 = lshr i8 %1, %shamt
  %r = or i8 %2, %z
  ret i8 %r
}

define i8 @or_lshr2(i8 %x, i8 %y, i8 %z, i8 %shamt) {
  %sx = lshr i8 %x, %shamt
  %sy = lshr i8 %y, %shamt
  %a = or i8 %z, %sx
  %r = or i8 %sy, %a
  ret i8 %r
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzslE-PmzwQxj_NcLES2cP_Awc2EdKr97r3ysZOcAU4sk0a-PQVLDS7dE-t9lYJwTD-MfiZsR7unL72ShUQvwCi9PVjGn8AIsTngA--MbZYk4Ewciwa728OwhKwAqyuRgrT-qOxV8BqAqz-fxWv5h5ZAbSEhK4XLaW66F4RnRGIqLHfWtdYBpjNCYwfgCfyFo7PcHqGruGdB8wJpC9AS7LkHgTCM5krkXdlftG0XOJxT417an7hC2U2xm2lpg2wO2CrwhfAKr8u2Fl4ep7vn6vGL1f957KnjXn8hex3U__iE8A-bm5rxLit474H7LMe7CTih8n_G-zvgw1kEco8zHmgCpaGCUuTLGNBU9SJjBVL0zSSXAghOJOYqZwnOc1rEclAF0gxpowmLEaG9IhxmlwuTIZ1VoswVBBR1XHdHtv23s22EmjnBlUwZGkaBy0XqnWrWc0IhKXuna9NJ3SvZt_CEyB22jklD-bmdacn7rXpV0-zxfzZQQxXBxFttfPu-S-vfbtY4X-986e1ZnwmJ9N1g1eS3Lj3yvZEO9IbTxrey1bJYLDt3hi1bwZxrE0HWC0bfXscbtZ8V7UHrBZhDrBatd0L_BkAAP__RFKEhA">