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

    <tr>
        <th>Summary</th>
        <td>
            `!unpredictable` not propagated when combining select+add
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            llvm:instcombine,
            missed-optimization
      </td>
    </tr>

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

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

<pre>
    When instcombine combines select+add into add+select the `!unpredictable` metadata is lost on the way.

```llvm
define i64 @add_select(i1 %cond, i64 %x, i64 %y) {
  %add = add i64 %x, %y
  %ret = select i1 %cond, i64 %add, i64 %x, !unpredictable !0
  ret i64 %ret
}

!0 = !{}
```



```llvm
define i64 @add_select(i1 %cond, i64 %x, i64 %y) {
  %add = select i1 %cond, i64 %y, i64 0
  %ret = add i64 %add, %x
  ret i64 %ret
}
```


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEU8GOmzAQ_ZrhYm1kj8HAgcNm0_xCj5XBDrgCjPDQbfr1FYZ0kyqtequEsDV-M_Pek54OwbWjtRVkR0BsuosOBIiQnRK9UOfnaqsltTfX6nNnR-bGQI0fajdatp-BBdvbhgCP2hjmRvJMGwN43OqMOstAcUCxjNNsjWtI170FxdlgSRtNmrnAeh-I-THC3_X1APwE_HX_K759ff9t2ErGXlYSTqUMUq6N-XKjUTjBALPGjwbwbUNg9v3ufgUsGeTHbRJbSyt1kCcWJdx1RPQHbLYUYbu0p5ui-LffpjxqXwv8NnaduYNnS7vg_PSgHwWPewHFyvvX682XB_AnhEJBif_Hwb9Zc73d-RNP76zfLYxL_8mlZz4kppKmlKVObCVUUSqOBedJV5la5JiKLJWWZ_LCVW1NcxE6K_QFVSoTVyFHyXORi5SrlB-arCxkLpom17VUTQ4pt4N2_WF18-DnNnEhLLZSshQ86XVt-7DHKvotX--Cs0YM3wBxcCFY8-IncoP7ocn5cY_fXK1tL_XSBkh57wKFj1XkqLfVHxI1emLT7CfdarKGva-h3fa6sX1IarLMfdURTQHkK-AZ8Nw66pb60PgB8ByJb8fLNPuvsfEcdQbAc5T6MwAA__9BkDWc">