<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/121701>121701</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/5bh5v8Tn6
```
define i1 @no_masks_with_logical_or1(i32 %a, i32 %b, i32 noundef %c) {
  %cmp1 = icmp ne i32 %a, 0
  %cmp2 = icmp ne i32 %b, 63
  %or1 = select i1 %cmp1, i1 true, i1 %cmp2
  %cmp3 = icmp ne i32 %c, 0
  %or2 = or i1 %or1, %cmp3
 ret i1 %or2
}

define i1 @no_masks_with_logical_or2(i32 %a, i32 %b, i32 noundef %c) {
  %cmp1 = icmp ne i32 %a, 0
  %cmp2 = icmp ne i32 %b, 63
 %or1 = select i1 %cmp1, i1 true, i1 %cmp2
  %cmp3 = icmp ne i32 %c, 0
 %or2 = or i1 %cmp3, %or1
  ret i1 %or2
}
```
```
define i1 @no_masks_with_logical_or1(i32 %a, i32 %b, i32 noundef %c) {
  %cmp2 = icmp ne i32 %b, 63
  %1 = or i32 %a, %c
  %2 = icmp ne i32 %1, 0
  %or2 = select i1 %2, i1 true, i1 %cmp2
  ret i1 %or2
}

define i1 @no_masks_with_logical_or2(i32 %a, i32 %b, i32 noundef %c) {
  %cmp1 = icmp ne i32 %a, 0
  %cmp2 = icmp ne i32 %b, 63
  %or1 = select i1 %cmp1, i1 true, i1 %cmp2
  %cmp3 = icmp ne i32 %c, 0
  %or2 = or i1 %cmp3, %or1
 ret i1 %or2
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzUVc2OmzwUfZrLxkpkX_OXBYtMIqRv_-0jg53g1tjINplOnr6CkGmmTdvZ9E-KgjGHc-49OviKEPTJKlVB9gSIMrafLi_PgAjZPhFj7Jyvls2kcfKl6mIcAvAtYA1Yn5xsnIlr50-A9QWwzpouO5f_2xzoFnK6_OhWqqO2imhGIKXWHXoRPobDs47dwbiTboU5OM8AS82RAGYCcEeWdXNbWzdaqY7TXgu4IVA8Ad2S-b4fGAG-J7rtBzIp3fHQOxQ-Qs0KOb_BnL9yBWVUG-eirwpzIYxEP6pluZDeCfBHAu2bMpy_VuH8QjG3vrsRTDCv4uuziR2K_fT_TiPxLzDyF_v4yMbZvKuPk6MT13d8vEvmb07pe_LHXtu6k5npFsBDEvYwY2-8xx8b_--H7o98vd_G7iepS2TF5YZvRKIqVvCcbtIyp0lXZUXJUoYlP0pOszQvStEwXoo8zZG1TZroCilmlNGM5TxFuhaIxxQlRzzSouQppFT1Qpu1Med-OpcTHcKoKoasoCwxolEmLKf9BAG-1TbE1vWNtmo6-HEHiL0OQcmVG6Lu9UVE7ewyFHw1vbZqxlOAlBodYviiFXU08yz5z4a4WzizPdm5vh-jkmQQMSpviQ7Eukg6YaVRMhm9-Xqy6NiNzbp1PWA9F3q9rAbvPqg2AtZzYwGwXno7V_g5AAD__wWc4Dg">