Hi Nadav, I tried your suggestion by changing the condition to : 189 if (LoopVectorize && OptLevel >= 0) 190 MPM.add(createLoopVectorizePass()); and compiled. Then I used the following command: opt -mtriple=x86_64-linux-gnu -vectorize-loops -vectorizer-min-trip-count=6 -debug-only=loop-vectorize -O1-S -o example1_vect.s example1.s where example1.s is IR generated by clang -S -emit-llvm example1.c example1.c contains the following loop: for(int i=0;i<SIZE;i++) { aa[i] = bb[i] + count; count++; printf("a[%d] is %d", i,aa[i]); } LV runs and says "LV: Found too many inductions". I am guessing that this because some of the loop passes are missing. Could you please shed some light on what passes should be used to prepare the IR for LV? Best, Anadi On Thu, Apr 11, 2013 at 2:48 AM, Nadav Rotem <nrotem at apple.com> wrote:> > Hi Anadi, > > In the file PassManagerBuilder.cpp you can change the lines below to get rid of the O3 restriction. > > 189 if (LoopVectorize && OptLevel > 2) > 190 MPM.add(createLoopVectorizePass()); > > Nadav > > > > > On Apr 10, 2013, at 5:39 PM, Anadi Mishra <reachanadi at gmail.com> wrote: > > Hello, > > I am trying out the LoopVectorizer(LV) pass and would like to decouple it from O3 which is currently required to run LV. I want to do this because I want to understand the behaviour of LV by trying simple loops but the O3 mostly optimises away the loop body. > > Any ideas would be appreciated. > > Best, > Anadi. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >
Hi Anadi, Yes, this is a bug in the loop vectorizer. The loop vectorizer expects only one loop counter (integer with step=1). There is no reason why we should not handle the case below, and it should be easy to fix. Interestingly enough if you reverse the order of iterations and count from SIZE to zero, the loop vectorizer would vectorize it. If you open a bugzilla report and assign it to me I will look at it. Example: int foo(int *aa, int *bb, int SIZE) { int count = 190; for(int i=SIZE;i > 0;i--) { aa[i] = bb[i] + count; count++; } } Thanks, Nadav The loop vectorizer has some LSR-like capabilities for merging multiple induction variables into a On Apr 10, 2013, at 7:52 PM, Anadi Mishra <reachanadi at gmail.com> wrote:> Hi Nadav, > > I tried your suggestion by changing the condition to : > > 189 if (LoopVectorize && OptLevel >= 0) > 190 MPM.add(createLoopVectorizePass()); > > and compiled. Then I used the following command: > > opt -mtriple=x86_64-linux-gnu -vectorize-loops > -vectorizer-min-trip-count=6 -debug-only=loop-vectorize -O1-S -o > example1_vect.s example1.s > > where example1.s is IR generated by > > clang -S -emit-llvm example1.c > > example1.c contains the following loop: > > for(int i=0;i<SIZE;i++) > { > aa[i] = bb[i] + count; > count++; > printf("a[%d] is %d", i,aa[i]); > } > > LV runs and says "LV: Found too many inductions". > > I am guessing that this because some of the loop passes are missing. > Could you please shed some light on what passes should be used to > prepare the IR for LV? > > > Best, > Anadi > > > On Thu, Apr 11, 2013 at 2:48 AM, Nadav Rotem <nrotem at apple.com> wrote: >> >> Hi Anadi, >> >> In the file PassManagerBuilder.cpp you can change the lines below to get rid of the O3 restriction. >> >> 189 if (LoopVectorize && OptLevel > 2) >> 190 MPM.add(createLoopVectorizePass()); >> >> Nadav >> >> >> >> >> On Apr 10, 2013, at 5:39 PM, Anadi Mishra <reachanadi at gmail.com> wrote: >> >> Hello, >> >> I am trying out the LoopVectorizer(LV) pass and would like to decouple it from O3 which is currently required to run LV. I want to do this because I want to understand the behaviour of LV by trying simple loops but the O3 mostly optimises away the loop body. >> >> Any ideas would be appreciated. >> >> Best, >> Anadi. >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130410/6f2a97b7/attachment.html>
Done. Best, Anadi. On Thu, Apr 11, 2013 at 7:01 AM, Nadav Rotem <nrotem at apple.com> wrote:> Hi Anadi, > > Yes, this is a bug in the loop vectorizer. The loop vectorizer expects only > one loop counter (integer with step=1). There is no reason why we should > not handle the case below, and it should be easy to fix. Interestingly > enough if you reverse the order of iterations and count from SIZE to zero, > the loop vectorizer would vectorize it. If you open a bugzilla report and > assign it to me I will look at it. > > Example: > > int foo(int *aa, int *bb, int SIZE) { > int count = 190; > for(int i=SIZE;i > 0;i--) { > aa[i] = bb[i] + count; > count++; > } > } > > > Thanks, > Nadav > > The loop vectorizer has some LSR-like capabilities for merging multiple > induction variables into a > > > On Apr 10, 2013, at 7:52 PM, Anadi Mishra <reachanadi at gmail.com> wrote: > > Hi Nadav, > > I tried your suggestion by changing the condition to : > > 189 if (LoopVectorize && OptLevel >= 0) > 190 MPM.add(createLoopVectorizePass()); > > and compiled. Then I used the following command: > > opt -mtriple=x86_64-linux-gnu -vectorize-loops > -vectorizer-min-trip-count=6 -debug-only=loop-vectorize -O1-S -o > example1_vect.s example1.s > > where example1.s is IR generated by > > clang -S -emit-llvm example1.c > > example1.c contains the following loop: > > for(int i=0;i<SIZE;i++) > { > aa[i] = bb[i] + count; > count++; > printf("a[%d] is %d", i,aa[i]); > } > > LV runs and says "LV: Found too many inductions". > > I am guessing that this because some of the loop passes are missing. > Could you please shed some light on what passes should be used to > prepare the IR for LV? > > > Best, > Anadi > > > On Thu, Apr 11, 2013 at 2:48 AM, Nadav Rotem <nrotem at apple.com> wrote: > > > Hi Anadi, > > In the file PassManagerBuilder.cpp you can change the lines below to get rid > of the O3 restriction. > > 189 if (LoopVectorize && OptLevel > 2) > 190 MPM.add(createLoopVectorizePass()); > > Nadav > > > > > On Apr 10, 2013, at 5:39 PM, Anadi Mishra <reachanadi at gmail.com> wrote: > > Hello, > > I am trying out the LoopVectorizer(LV) pass and would like to decouple it > from O3 which is currently required to run LV. I want to do this because I > want to understand the behaviour of LV by trying simple loops but the O3 > mostly optimises away the loop body. > > Any ideas would be appreciated. > > Best, > Anadi. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >