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

    <tr>
        <th>Summary</th>
        <td>
            Missed optimization: fold (select C, (x | a), x) | b -> x | select C, (a | b), b
        </td>
    </tr>

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

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

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

<pre>
    ```
define i8 @src(i8 %arg0, i8 %arg1) {
 %v0 = icmp eq i8 %arg1, -1
  %v1 = or i8 %arg0, 4
  %v2 = select i1 %v0, i8 %v1, i8 %arg0
  %v3 = or i8 %v2, 1
  ret i8 %v3
}

define i8 @tgt(i8 %arg0, i8 %arg1) {
  %v0 = icmp eq i8 %arg1, -1
  %v1 = select i1 %v0, i8 5, i8 1
  %v2 = or i8 %arg0, %v1
  ret i8 %v2
}
```

Alive2: https://alive2.llvm.org/ce/z/Nq6b4_
Godbolt: https://godbolt.org/z/dnv46Kede

Pattern found in https://github.com/dtcxzyw/llvm-opt-benchmark/blob/main/bench/linux/optimized/fib_trie.ll

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUk8GOmzAQhp9muFiJzNgQOHBgs6WHqlXfYGWDSdwanMWGzebpKwObbbJV1UoI8Mz_j_15bOGcPvRKFZA8QPIYidEf7VBczj6JpG1eC0jp-tCyUa3uFdEZAU7dUANm4R8TMRwo4J5cRzFgTmD3ALQMkYkSYI9E192JqOcb2Z5s4qCaZfEsswO5LcuvApwFThlVe6Ljpfb7zFN8swp69bHbwhMG3TLvoPxblAEtYfcY3new_uD_Dfb_af8Mk6zf-A79w94s1Hcg-A7yW_uAlqXRk0JgJTl6f3LASsAKsBJzfGvM1G3tcACsagVYXQCrb8-p5E9Ay8-2kdb4j-bDkliNwdP0E0-_qEYts34X3quhJ60d-4bo_t6v_XGU29p2werr8-X1BbAKi9nYk99I1dfHTgw_AStprASsOqH7MAqZINX9eAas7MnrTl9UA1i1Wj75QautMUDLqClYk7NcRKqId0mSpGmapdGxEBjThos03eWyFrKl-a5ljKGUNKsbSSNdIMWEZnFOY-Q83TJGWcp5GO84tgo4VZ3Q5rp7kXZuVEWccORpZIRUxs33C7FXL2TOAmK4bkMxU8rx4IBTo51372W89kYVX7VzqiErmvDa9qEFrTUNAczW47NfzkJ2JrDbEwGYh8B5OZl7IskG2CeyZO8sYlGsFhmNgyn-0qCwvLfunAb7Q9UesJqhHGC1Uk8F_goAAP__H6g6xg">