[llvm-dev] Separate LoopVectorize LLVM pass

Alex Susu via llvm-dev llvm-dev at lists.llvm.org
Fri Apr 14 13:04:49 PDT 2017


   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