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

Michael Zolotukhin via llvm-dev llvm-dev at lists.llvm.org
Fri Aug 5 16:15:22 PDT 2016


Hi Alex,

How do you compile this program? I compile it as follows, and don’t see extra vector-bodies:

> bin/clang -O3 vec.c -S -o - |grep "##"
_foo:                                   ## @foo
## BB#0:                                ## %entry
## BB#1:                                ## %for.body.preheader
## BB#8:                                ## %min.iters.checked
## BB#9:                                ## %vector.memcheck
## BB#10:                               ## %vector.memcheck
## BB#11:                               ## %vector.body.preheader
## BB#12:                               ## %vector.body.prol
LBB0_13:                                ## %vector.body.prol.loopexit
## BB#14:                               ## %vector.body.preheader.new
LBB0_15:                                ## %vector.body
                                        ## =>This Inner Loop Header: Depth=1
LBB0_16:                                ## %middle.block
LBB0_2:                                 ## %for.body.preheader27
## BB#3:                                ## %for.body.prol.preheader
LBB0_4:                                 ## %for.body.prol
                                        ## =>This Inner Loop Header: Depth=1
LBB0_5:                                 ## %for.body.prol.loopexit
## BB#6:                                ## %for.body.preheader27.new
LBB0_7:                                 ## %for.body
                                        ## =>This Inner Loop Header: Depth=1
LBB0_17:                                ## %for.cond.cleanup


Best regards,
Michael


> On Jul 31, 2016, at 5:29 PM, Alex Susu <alex.e.susu at gmail.com> wrote:
> 
>  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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160805/bee75aa1/attachment.html>


More information about the llvm-dev mailing list