[llvm-dev] Separate LoopVectorize LLVM pass
Alex Susu via llvm-dev
llvm-dev at lists.llvm.org
Mon Apr 17 03:01:44 PDT 2017
Hi.
I managed to find the reason why my own LoopVectorize pass does not vectorize.
Actually, the loop-simplify pass was getting executed, but because it did not run the
passes loop-rotate and licm before it did not generate a proper loop preheader and the
loops were not valid for vectorization.
To make my own LoopVectorize pass vectorize I got inspired from the arguments
displayed on stdout of:
opt -debug-pass=Arguments -O3 ...
and looked at what other passes are being executed before and after -loop-vectorize .
So I chose the following:
opt -mem2reg -loop-rotate -licm -loop-unswitch -simplifycfg -domtree -basicaa -aa
-instcombine -loops -loop-simplify \
-force-vector-width=128 -load MyLoopVectorize.so -my-loop-vectorize \
-loop-simplify -scalar-evolution -aa -loop-accesses -loop-load-elim -basicaa
-aa -instcombine -scalar-evolution -demanded-bits -slp-vectorizer
Best regards,
Alex
On 4/14/2017 11:04 PM, Alex Susu wrote:
> Hello.
> I am trying to create my own LoopVectorize.cpp pass as a separate pass from the LLVM
> trunk, as described in http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project. Did
> anybody try something like this?
> I added close to the end of the .cpp file:
> /* this line seems to be required - it allows to run this pass
> as an embedded pass by giving opt -my-loop-vectorize */
> static RegisterPass<LoopVectorize> Z("my-loop-vectorize",
> "Write comments in source file.");
>
> Note that I did NOT register my new pass in
> llvm/lib/Transforms/IPO/PassManagerBuilder.cpp - the original LoopVectorize module is
> registered there.
>
> However, when I give:
> opt -debug -load NewLoopVectorize.so -my-loop-vectorize test.c
> it does not vectorize a loop that was normally vectorized by the original
> LoopVectorize module in LLVM. My module gives:
> <<loop not vectorized: loop control flow is not understood by vectorizer
> LV: Not vectorizing: Cannot prove legality.>>
>
> So I tried to explicitly run a few more passes before my new LoopVectorize to help it
> (I think the most important one is -loop-simplify, which canonicalizes the loop):
> opt -debug -loop-simplify -mem2reg -lcssa -load NewLoopVectorize.so
> -my-loop-vectorize test.c
> However, I do not see any line in the output of opt starting with "LoopSimplify" (when
> I have success, when I give opt -O3, I get "LoopSimplify: Creating pre-header
> for.body.preheader; LoopSimplify: Creating dedicated exit block for.end.loopexit" before
> LoopVectorize) and my LoopVectorize still does not vectorize the loop.
>
> Can anybody help me run explicitly the LoopSimplify pass (before my LoopVectorize pass)?
>
> Thank you. And wish you happy Easter holidays!
> Alex
More information about the llvm-dev
mailing list