I would like to work on one of the open projects of polly “Integrating polly analysis with LLVM vectorizer”.So can someone suggest any resources/files I can go through to better understand how to implement it?
sorry for my late reply, I’ve been inactive on Discord for a while.
Polly had its own vectorizer until it was removed in [Polly] Remove -polly-vectorizer=polly. · llvm/llvm-project@42cd38c · GitHub. The approach had the disadvantage in that it had no cost model that would determine whether vectorization was even beneficial, but instead just vectorized all instructions with a default vector size of 4 using only what in VPlan calls the “Widen” recipe.
Instead of reinventing the wheel, it would be better if Polly instead steers the LoopVectorize implementation. This can be done using metadata such as
llvm.loop.vectorize.width. Polly already inserts such metadata in the ScopAnnotator.
Polly still has the option
-polly-vectorize=stripmine that just creates loops of the default or chosen vector size and then annotates the loop with the
llvm.loop.vectorize.enable metadata, but I doubt that that’s helpful for LoopVectorize which is capable of doing this itself including in the case where the loop trip count is not a multiple of the vector length.
A better integration could:
- Reuse the LoopVectorize heuristic (LoopVectorizationPlanner) itself to determine the vector size.
- Determine itself what loops are best to vectorize
- Outer loop vectorization (something LoopVectorize still cannot do) by stripmining only non-innermost loop
- Potentially instead unroll stripmined loop and let the SLPVectorizer do the job.
Let me know if you are still interested.