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

    <tr>
        <th>Summary</th>
        <td>
            [SPIR-V] sortBlocks() hangs on the attached reproducer
        </td>
    </tr>

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

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

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

<pre>
    The following reproducer causes `sortBlocks()` to loop without ending:

```
@G2 = internal unnamed_addr addrspace(3) global ptr addrspace(4) undef, align 8

define weak_odr dso_local spir_kernel void @foo(ptr addrspace(4) %p, i1 %f1, i1 %f2, i1 %f3) {
entry:
  br label %l0

l0:
  br label %l2

l2:
 %val2 = phi ptr addrspace(4) [ %p, %l0 ], [ %val3, %l3 ]
  br i1 %f2, label %l1, label %l3

l1:
  %val1 = phi ptr addrspace(4) [ %p, %l3 ], [ %val2, %l2 ]
  br i1 %f1, label %exit, label %l3

l3:
 %val3 = load ptr addrspace(4), ptr addrspace(3) @G2, align 8
  br i1 %f3, label %l1, label %l2

exit:
  ret void
}
```

CC: @Keenuts 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlFGPozYQxz-NeRntyh4DCQ883G6Uqmofqra615XBA7jr2Mg2SfPtK0j2QvbSk06KHJv_4PnN32ZUjKZ3RDUrXlixy9SUBh_qr2fVDhStOv5Ox3OK7-dz1nh9rv8eCDpvrT8Z10OgMXg9tRSgVVOkCKzk0Yf0Yn37HhluGVas5JA8WO9HOJk0-CkBOW1cz-QXxneMf4wlv_4uy5z_gsDkDoxLFJyyMDmnDqTflNYB5iGOqiWGW8mwgt76RlkY072Wz9rkNHUMX0FZ0zvYrvNq6owjOJF6f_M6gI7-zfpWWYijCW_vFBxZOHqjgeW8857h9mEShsU45zBinnZiNcfVfIFlm5dLdnIpnL85AdAEsKohO4davua0_P_C8C4Mb2EMi6OyFxfHwTz2hhUv39CXpMCK3bK4CEdl5YcmF-3GsC7vxiPul_IOT6yquOwufo5Pfs-HHxo-5rsHon9N-hGh_GygXACtV_oh4bzX5-eXQ56v8He3bg0mf2jc3bku1DfrAqXlTl5DNrvHH9Eyvr4y-WWm-Y3ITSlCpmupK1mpjGqxkaIq5abAbKiFkpXWZSeaQlR8WzZc8Yp4mWul2hzbzNTIMRdCbFFwlPjciZbrijaypLLLZclyTgdl7LO1x8OzD31mYpyoFqIsK8yW4uLSbhAdnWBRGeLcfUI9v_TUTH1kObcmpnjbJplklz711x-__vn0lRU7-NxqYFCuj-AdpIFApTR3Mb1qU9kUbD2kNMbZSdwz3PcmDVPz3PoDw_2c7Pr3NAb_D7WJ4X5BjAz31xqONf4XAAD__9-8e34">