[PATCH] D32261: [LoopUnroll] Don't try to unroll non-rotated loops

Gerolf Hoflehner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 20 15:27:49 PDT 2017


Gerolf added a comment.

I don't know if this patch makes the situation better or worse. It seems to touch on the tip of an iceberg. The underlying problem is: What can or should happen when a loop is irreducible? It the answer is "don't unroll", then this is the fix your actually looking for. Obviously this loop is irreducible since it has a retreat edge from sink to body2, but body2 does not dominate sink. I'm also curious if this loop is in the source code already or if some pass in the compiler actually generated. FWIW, unless the compiler has a problem irreducible loops should be rare. And when the user writes an irreducible loop, I think it is OK when compiler optimizations turn conservative.

-Gerolf



================
Comment at: lib/Transforms/Utils/LoopUnroll.cpp:328
+  L->getExitingBlocks(ExitingBlocks);
+  bool NotRotated =
+      llvm::all_of(ExitingBlocks, [&LatchBlock](const BasicBlock *BB) {
----------------
There must  be a helper routine to answer the question whether a loop is rotated or not. Otherwise each pass may end up having its own definition. I'm also wondering how one decides whether or not a loop is rotated when the loop is irreducible.


https://reviews.llvm.org/D32261





More information about the llvm-commits mailing list