[PATCH] D22959: MachineLoopInfo: add methods findLoopPreheader and getExitingBlock

Brendon Cahoon via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 4 15:44:38 PDT 2016


bcahoon added a comment.

I think it's a good idea to try to move some of the code in the Hexagon hardware loop pass so that it can be reused.  The  getExitingBlock() function in HexagonHardwareLoops.cpp is probably poorly named since it's doing something different than the existing function that is in MachineLoop.  If the function is moved, it seems to fit better in the MachineLoop class vs the MachineLoopInfo class.

The code in the getExitingBlock() function in HexagonHardwareLoops.cpp is attempting to enable the hardware loop pass to work on two special types of loops.  In one case, we would like to generate a hardware loop even if there are multiple exiting blocks. If that's the case, then we use the latch block as the exiting block (if the latch block is one of the exiting block).  It's ok to exit early from a hardware loop.  In the second case, we would like to generate a hardware loop if there is a single exit, but the latch is not the exit. This case occurs, for example, when a critical edge is added to the loop (see the hwloop-crit-edge.ll as an example).

I just wanted to provide a little background as to how the hardware loop pass uses the function.  Initially, I believe we used the latch block in all the cases where getExitingBlock() is now called. But, that caused problems when attempting to generate a hardware loop for the critical edge case.


https://reviews.llvm.org/D22959





More information about the llvm-commits mailing list