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

    <tr>
        <th>Summary</th>
        <td>
            Infinite/exponential loop unswitch due to invariant condition injection
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            llvm:hang
      </td>
    </tr>

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

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

<pre>
    Running `opt -passes='simple-loop-unswitch<nontrivial>'` on https://gist.github.com/nikic/852fbcaa307231c3aa0a5cdc1f057ede does not finish after 5 minutes.

My attempt to reduce this resulted in https://gist.github.com/nikic/52d9fc05e986a4e9279620461fe54d26, which does finish after about 50 seconds, resulting in this output: https://gist.github.com/nikic/45fb4b1448caa7195618c5001874f8cc The first test case might not be infinite as well, just very slow.

This problem does not occur when `-simple-loop-unswitch-inject-invariant-conditions=false` is passed.

cc @serguei-katkov

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMk82OpDYQgJ_GXEq0jMH8HDh0dtJSDrlE-wLGFFA7xka43J15-8jdyW4mymEvIIGxP398NjHS6hFHoX8R-q0wibdwjp7eyRZTmD_GP5L35FcQrQwHQ3mYGDGK-k2oLtJ-OCxdCEeZfHwQ203UX3zwfNKdjBP1r0J1opUQPGzMRxT1VaibULeVIl9W4i1NFxt2oW7PRYW69VotkzWmlp2qK1sbI422s60WqTucEeaAEXxgWMhT3MAsjCdo2MknxngR8k3I6-v6-wcYZtwPBg5w4pwsAm8U4cSYHOMM9PNoWs3DYqXGoW9Ng4PqhlbJpq0W1M2sWqG-wGMju70YP_GZKSQGLSGiDX6OeeyLIesl_6IKiY_Eor7-NFOjl6mZqqbprTFdNei26q2Wsuq7Zumtha8bwkJnZGCMDNZEhJ3WjZ8OJwTyGZQRTIQHOpfJvqXIcMfzA6ILj09Kv2bO4wyTw_3HvwjWphMeG_qcSvl_aZTkv6HlkvzdnGQ8l1kEMQWfg1qMi5hbydPnyuZPy1oLopERzzUhle-G38P99aaYx3oe6sEUOFbtoKuhbZUqtlEa2fRDNxjb9rZXZuorbbpKzYusJ2OHgkYlVS0HJWWnO6kuSz91gx60brTUlepFI3E35C7O3fdLONeCYkw4tm3f9oUzE7r4PDtK5RGivm7Gr0KpfJjOMT8rp7RG0UhHkeOPeZjY4fjb3-qFuuGfR_DomYyDrA3-0QZzwhzvd23wXRu8jFLwRTrd-N9k_lXLk-51K48z5K-Euj03E4W6PffzVwAAAP__1bRTZg">