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

    <tr>
        <th>Summary</th>
        <td>
            or's with related masks could be folded into one
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            missed-optimization
      </td>
    </tr>

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

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

<pre>
    Consider:

```
unsigned f(unsigned x, int n) {
    x |= 1 << n;
    x |= 1 << (n + 1);
    return x;
}
```

or in LLVM IR:

```
define i32 @f(i32 %0, i32 %1) {
  %3 = shl nuw i32 1, %1
  %4 = or i32 %3, %0
  %5 = add nsw i32 %1, 1
  %6 = shl nuw i32 1, %5
  %7 = or i32 %4, %6
  ret i32 %7
}
```

The two "or" operations could be folded into one:

```
define i32 @f(i32 %0, i32 %1) {
  %3 = shl nuw i32 3, %1
  %4 = or i32 %3, %0
  ret i32 %4
}
```

Alive agrees: https://alive2.llvm.org/ce/z/y6hhJR
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9VEtv4yAQ_jX4MmqEwZjk4EOTqNKuupdqtXccSMwuNhHgpu2v3zFJ2rRqq2oP68d4Hh_z-EBuvX5sVn6IVptA-DWha0LPsqanJ5sjgnaD0bAlbP5sPBC2AjskGAhbAJHLIxjwekBzRfgaSiAclRVi-KdxTDygWEKJyV5hg0ljGLDa2Unk-t0uj9IH7Alub3_9gG93n4-lzdYOBixnQCo6zZZVJmie7KiXb4ZDF4ep9dg5GMZDxpXTggx-QVUZNbVzTMRPGHqBERmjtIYhHi4qruAyU_1hPXGBkm_qVSdMfcYgkeeY_AqTPzsD6eARz3xAAX5vgkoWjwxs_Og0tAa23mk8C3gMPPjB_C_C-b8QfkFA9RUCrp29N6B2wZiIg0GX0n5SCLvBR01RNnPuvp_5sEPPxqB4wvex7rrvd4VuuF7whSqSTc40E4kywsGmDltxKiFvvYp_PmazGINrXlfd4eqxnW18j8ZU-_S52gf_22wSmjbGERtmN6IWc1Z0jZaC14rPuS5FuVEtbSmTXC6oaudtVZnCqda42BCxxG3ucb3RV36fbG-f8n6jl4h1YRtGGaOyxFswwWZ1S8tqK6VqOdNyoXFTTa-seyalCE1urh13EYPOxhRfgirmP4nJhTG_GlPnQ_PUe236Io_R5Bn-Aq5ROqs">