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

    <tr>
        <th>Summary</th>
        <td>
            Optimizer optimizes out potential infinite loop
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          Pranavkumar-T-S
      </td>
    </tr>
</table>

<pre>
    ### All information necessary to reproduce the problem.

It is reproducible in 
- version: clang 18 and above 
- architecture: x86_64, armv8-a, arv7-a
- optimization flag : O1 and above
- standard : c++11 and above

### The reduced test-case that triggers the bug.

``` cpp
#include <iostream>
#include <unordered_set>
int main() {
    std::unordered_set<int> isPresent;
    isPresent.insert(0);
    // std::cout << "before loop, size of isPresent: " << isPresent.size() << std::endl;
    while (!isPresent.empty()) {
        // std::cout << "infinite loop " << std::endl;
    };
    // std::cout << "after loop " << std::endl;

    return 0;
}
```

### The location where you obtained LLVM (if not from our Git repository).

- it is from [compiler explorer](https://godbolt.org/).
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVFGP2zYM_jXKC5HAlp3EfvBDcrcMAzq0wIq9FrJN29xkyaDotOmvH2TnLtduAw4QkET8PvL7GIomBOodYqX2Z7V_3phZBs_VJzbOXP-eR8Pbz9s_NrVvb5XS2XrgZC2Q6zyPRsg7cNhgCIZvIB4YJ_bt3CDIgDCxry2OO5WcVHL6TYDCK4Jqi0AOVHLawhU5kHcqO0FjjeshLcC4Fkztr7hCDDcDCTYyM0bct-Lw5ZAr_QSGx2uxNevX63FrFryfhEb6vmrsrOkhsj6mj7wLLIhxreF2iTZKn5U-pz-C4nl1_3lAYIwOWxAMsm1MiGaNgDD1PXJYrNdzf7etDsl6oJmmNRe5xs4tgsqeyAdhNKPKfvlXbHaeW2RsvwSUFUBOYDTklC6ULkEdzyo5AQAEaVV2UtnpJ9ITuUgFCp8YA8YfL5TXqx25gCxKF4nS5QOg9EXpyyN142eJulT2BErrGjvPCNb7KfY-0HcE372tdIqwF8ajXES-GFhjryXQtfYh4OtAFmGBpg86jpPcVv6PPXiHZnIdOZJV9Vt1_6NAHZ_f3Q_TCfJ7Et_TMcrMDpL75fH57bD819xZ36zj_HVARrj5GXwthhy28OHDn7_HTlEHzgt07EfwM8OvJPHJ-UDi-aZ0eZ_KLdDyHBeg2p8bP05kkQG_TdYzsto_K10MIlOI-hfrvW9rb2XnuV8uyt2mrbK2zEqzwSo97nWWl7rIN0NV5hnui1pnWdZ1e1PXx6KoTVnXxaE8Zk2-oUonep8cU52WearznSnzwqRlpzNzSJMiV3mCoyG7s_Y6xpIbCmHGKs2LrDxurKnRhmV1ae3wKyxRpXXcZFxF0rae-6DyxFKQ8EgjJBarj-t-QH7ZFBgg_p-TF3RCZllyj1nZzGyrn7pBMsz1rvGj0peY_f6xndj_hY0ofVk0BaUvd9HXSv8TAAD__36pplA">