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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Clang unnecessarily removes code during optimization (regression)
        </td>
    </tr>

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

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

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

<pre>
    Putting these lines at the beginning of a function causes clang to remove the entire function. Does not happen if dummy variable inside the `if` is removed.
```
unsigned A = 32;
unsigned B = 1 << A;
if (B) { unsigned Dummy; }
```

Clang version: 15+, works fine in clang 14.
Optimization level: -O1 or higher

https://godbolt.org/z/554qxxnbz
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxcUkGPszgM_TXmYk0VDJTmwAFacZ39C4EYyG5IuknozsyvX0Gr-UYjRYpi-9l-L0_FaGbH3EDVQXXL1JYWHxqtVqOcHv3CgV3KBq8_m7-2lIybMS0cGa1xHFGl_YkDz8a5PeknVDhtbkzGOxzVFjniaNWO8xh49Q8-IOySCfxdesKb54jOJ1zU_c4OzYR6W9dPfKhg1GAZjYtGP9FwFmaCs0ATX031CUQLZ_E6ot3cQU1ji1DcsCAoup_h7gjnCMUViiu2z7SZEOjSAUmEusPv6tu-ChQdQn37NQhEez0IPjhE4x0ULeYVUAd0xf98-CfiZNy-_kuIvNx3fb8ns5ovdQhl-cF2B7695-gDLmZeODybLyndIxQtUA_Uz14P3qaTDzNQ_wXUV1X578eHG74y3RRaFlJl3OR1VeRCnM95tjQsc1kP06iFqiqqZSnziyxJj-dSXkopM9OQoErUlOdEZX45iVpJVcmRy_LCxVRDKXhVxp6sfaz77MzEuHGTl_IiKLNqYBsPExEdJIFo91NodsDbsM0RSmFNTPFPi2SSPZz3RFQ3fOq4Occjx6iCsZ-v7404es2ot3C47Kd2QJfAc-B4iE8y24Jtfolm0rINp9GvQP0-_3W93YP_m8cE1B98IlD_ovRo6P8AAAD__3mW_Xw">