[llvm-dev] LLVM Loop vectorizer - 2 vector.body blocks appear

Alex Susu via llvm-dev llvm-dev at lists.llvm.org
Sun Jul 31 17:29:50 PDT 2016


   Hello.
     Mikhail, with the more recent version of the LoopVectorize.cpp code (retrieved at the 
beginning of July 2016) I ran the following piece of C code:
     void foo(long *A, long *B, long *C, long N) {
       for (long i = 0; i < N; ++i) {
         C[i] = A[i] + B[i];
       }
     }

     The vectorized LLVM program I obtain contains 2 vector.body blocks - one named 
"vector.body" and the other "vector.body34" for example. The code seems correct - the 
first "vector.body" block is responsible for the vector add of a number of vector elements 
multiple of VF * UF. There are 2 epilogues which makes things a bit strange - I am still 
trying to understand the code.


     Is it possible to explain to me where in LoopVectorize.cpp are created 2 vector.body 
blocks? I know that InnerLoopVectorizer::vectorize() calls 
InnerLoopVectorizer::createEmptyLoop() which creates the blocks required for 
vectorization, but I have difficulties to follow the classes instantiations.
     I ask because in fact, I would prefer having only one "vector.body" block for the 
above C program, as it was happening with LoopVectorize.cpp version of Nov 2015.

   Thank you very much,
     Alex


More information about the llvm-dev mailing list