[PATCH] D134279: [MustExec][LICM] Handle latch being part of an inner cycle (PR57780)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 3 09:40:11 PDT 2022


nikic added a comment.

To provide some more context here: What the algorithm essentially does is collect all the predecessors in the loop, and then check that this is a closed set, in the sense that all control flow either stays in the set or goes to the target block. If no loops are involved, then this ensures control flow will eventually hit the target block.

Once loops are involved, we can run into two complications:

1. The issue fixed here: If we have a loop latch in the set, then control flow can escape the set by going to the next loop iteration. However, this "next iteration" distinction gets lost in the current representation, and it looks as if we were staying in the set. This is why the separate check is necessary.

2. Separate issue not addressed by this patch: Control flow might infinitely loop around an inner cycle and thus never reach the target block. Haven't tried to reproduce this, but I suspect that this may not be handled correctly (for non-mustprogress semantics).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134279/new/

https://reviews.llvm.org/D134279



More information about the llvm-commits mailing list