[PATCH] D22630: Loop rotation
Michael Zolotukhin via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 19 15:22:36 PDT 2016
mzolotukhin added a comment.
> Essentially, if the header and latch both are exiting, the loop will not rotate (as per your suggestion).
Can you please explain why we need to rotate those loops? Then we can figure out heuristics that we can use here.
> The vectorizer already tags loops with metadata, so I assumed having it here should have been okay.
The vectorizer is a different beast. When we vectorize a loop, we usually don't want other passes to touch it afterwards at all. That's why we use metadata, we kind of say "this loop is as good as we can get, leave it alone".
In case of loop-rotation it's not the case - we are not sure that the loop is in the best position even in terms of rotation after one iteration of loop-rotate. Using metadata to avoid further rotation seems like an attempt to paper over a real problem, i.e. finding the best candidate for the bottom check for the loop versus trying to get lucky with that.
When I suggested to rotate only loops that have not-exiting latch, that was my attempt to create a heuristics to find that 'best candidate' for the bottom check. Your testing shows that it's not good enough, so my question is what cases this heuristics misses. Probably we just need to take into account some additional characteristics of the loop and it'll work just fine.
More information about the llvm-commits