<div dir="ltr">Hi everyone,<br><br>Recently we needed to know whether an SCC is a loop in a patch: <a href="https://reviews.llvm.org/D74691#1878465">https://reviews.llvm.org/D74691#1878465</a><br><br>First of all, do you think this is a useful addition to the SCC interface?<br><br>If yes, yhe solution that we ended up doing is:<br>- Get LoopInfo for the function.<br>- Given an SCC, take one random block of it. Then, call `getLoopFor()` with that block.<br>If we don't get a loop back, then this SCC is definitely not a loop.<br>- Otherwise, we compare the size of the SCC with that of the loop and there are 3 cases:<br>  - They're equal: this SCC is a loop.<br>  - The SCC is smaller: This SCC is not a loop because `getLoopFor()` gives the innermost loop. So, if this is smaller, it is an SCC inside a loop.<br>  - The SCC is bigger: In that case, we can't decide since let's say the SCC has blocks A, B, C. And the loop has blocks A, B. But blocks A, B, C might also make a loop. However, since `getLoopFor()` gives us the innermost loop, it will give us A, B. So, in that case, use `getParentLoop()` repeatedly and repeat the procedure for the parent loops.<br><br>Do you think there's a better way ? I was thinking that maybe there was a more straightforward way by trying to verify whether the criteria for a loop are satisfied (i.e. there's a block that dominates all the other blocks).<br><br>Best,<br>Stefanos Baziotis</div>