[llvm] [LoopInterchange] Improve profitability check for vectorization (PR #133672)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 4 04:51:53 PDT 2025
https://github.com/Meinersbur commented:
Whether a loop with loop-carried positive dependence distance is vectorizable is unfortunately [more complicated](https://github.com/llvm/llvm-project/blob/20d70196c9a4da344d0944f3c78447c3bd7079c7/llvm/include/llvm/Analysis/LoopAccessAnalysis.h#L125-L144).
First, dependencies are either always positive or the dependency is carried by a surrounding loop (legality check).
Then, the dependence distance has to be either larger than the vector size (which we cannot determine) OR it has to be "lexically forward" (which is difficult to define). Looks like you patch tries to determine "lexically forward" from whether it has been normalized. This derives from the order in which the instructions are iterated over. This is OK within a BB, but BBs themselves can be ordered arbitrarily and does not indicate actual execution order. I think the test should be more conservative in the case of control flow in the loop body. Also, please add comments about the intend to match LLA's forward dependency.
https://github.com/llvm/llvm-project/pull/133672
More information about the llvm-commits
mailing list