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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Missed optimization: clang doesn't skip not used evaluation
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    Hello,

I recently found that clang doesn't optimize simple code.
Specifically, it won't remove computation of `x + 777*x/34` when `bool b` is false in this code (https://godbolt.org/z/fWssbGrer):
```
int f(bool b, int x) {
 auto it = x + 777*x/34;
    if (b && it != 7) {
        return 1;
 } else {
        return 0;
    }
}
```

In other function f1, it will first check `bool b` and only compute `x + 777*x/34` when it's true.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEU8tu2zAQ_JrVZRGDWolifNDBiaG2h5566JmSVhYbmjRIKonz9QVlp4H7QAVBD3L2MZwdHaM5OOYW5APIfaGXNPvQHs76aS56P57bz2ytB3oEsQexuzy_YOCBXbJnnPziRkyzTjhY7Q44eo4OSCX0p2SO5o0xmuPJMg5-5M0lwbcTD2Yyg7b2DPSIJuGLv0QFPvrnDD6elqST8Q79hNCIVwR6QKUU0O4VqKtqaAS-zOzybu-9xT6vmIiTtpHROEyziWtdBLqfUzpFqHZAHVB38GPvbdr4cADq3oC66XuM_afAAWibYRfCjbje669xCSeg-2u53LpL-Aq0RVAPFwzqJflMCao9_qXr6h2HiGbKnfUI1AA1axCVOU7dprxegdMSHJYfOUDtkTPbf2HFTT1Q-yuvXx-3BK8CO_Rp5oDT4oZVg6l818lYi5MJMeEw8_B0e_jajeidPV_14_8IZxKQipjCwptibKtxW211wW2pRF2phhpZzC1LOUhVl2VFY0Ol2vaikoOotoLKsp5kYVoSVItS1GUlSyE3UzXKWoySaqH6SSioBR-1sRtrn49Z8cLEuHCrmq0sC6t7tnF1ANE6xECUzRDajL_rl0OEWlgTU_zIkEyyq20uEXKPX02MPL6P_Tq6UO3-sEV8Mid0PuGS0fys7bJiiyXY9rcZNWle-s3gj0Bdrnx93Z2C_8FDAupWIhGoW7n8DAAA__9lcB5k">