[PATCH] D43237: [LoopInterchange] Allow some loops with PHI nodes in the exit block.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 12 16:52:44 PDT 2018


fhahn added a comment.

In https://reviews.llvm.org/D43237#1035200, @efriedma wrote:

> So the problem is specifically with values produced in the loop latch?  That makes sense, I guess, but it seems like you could check for that more directly.  (It might also be possible to hoist the instruction out of the latch, but I guess that's complicated in general.)


Yes, I think currently only values produced in the outer loop latch can be a problem, because the outer loop latch must be the inner loop exit block at the moment IIRC. Although if we loosen that restriction at some point, values in other blocks of the outer loop could become problematic as well.

I guess we could simplify the check by just checking if any incoming values to the phis in the exit block are non-phi nodes in the outer loop latch and prevent interchanging in that case.  That way, we would also allow values produced in the outer loop header, which should be fine. With some assertions, ensuring the outer loop latch's predecessors are only blocks exiting the inner loop or the outer loop header. Is that along the lines you were thinking?

There's potential follow-up work to loosen that restriction if we know that the inner loop body gets executed at least once or if we can hoist the offending statements.


https://reviews.llvm.org/D43237





More information about the llvm-commits mailing list