> On Mar 18, 2016, at 1:47 PM, Rail Shafigulin <rail at esenciatech.com> wrote: > > Yes this IR does not build or shuffle any vector. Try to write a function that takes 8 ints and a pointer to a <4xi32>, builds two vectors with the 8 ints, > > This might sound like a dumb question, but how does one build a vector of ints out of regular ints in IR?See: http://llvm.org/docs/LangRef.html#vector-operations In short, the IR has "insertelement", which maps to "INSERT_VECTOR_ELT" in SDAG and "extractelement", which maps to "EXTRACT_VECTOR_ELT" in SDAG. I usually find good example by grepping in the lit tests. Another way is to write the function in clang, and run it with -O3 -emit-llvm -S to get a good starting point. -- Mehdi> > sum them, and store the result to the pointer. > > >> >> In other words I left the code as is. >> >> However if I use a .c code and run it through clang, I don't see any vector instructions. I'm puzzled. What am I doing wrong? There seems to be a step missing, the one that will generate vectorized IR, but I can't seem to find how to do it. > > Try: clang -O3 -emit-llvm -S test.c > > -- > Mehdi > > >> >> Any help on this is really appreciated. >> >> -- >> Rail Shafigulin >> Software Engineer >> Esencia Technologies > > > > > -- > Rail Shafigulin > Software Engineer > Esencia Technologies-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160318/b0529f1a/attachment.html>
On Fri, Mar 18, 2016 at 1:53 PM, Mehdi Amini <mehdi.amini at apple.com> wrote:> > On Mar 18, 2016, at 1:47 PM, Rail Shafigulin <rail at esenciatech.com> wrote: > > Yes this IR does not build or shuffle any vector. Try to write a function >> that takes 8 ints and a pointer to a <4xi32>, builds two vectors with the 8 >> ints, >> > > This might sound like a dumb question, but how does one build a vector of > ints out of regular ints in IR? > > > See: http://llvm.org/docs/LangRef.html#vector-operations > > In short, the IR has "insertelement", which maps to "INSERT_VECTOR_ELT" in > SDAG and "extractelement", which maps to "EXTRACT_VECTOR_ELT" in SDAG. > > I usually find good example by grepping in the lit tests. Another way is > to write the function in clang, and run it with -O3 -emit-llvm -S to get a > good starting point. >I tried using clang test.c -O3 -emit-llvm -S, but the only I didn't see any of the insertvectorelt or extractvectorelt. I'm wondering how does one trigger vector operations? Below is the test.c file. It seemed to me like a good candidate for vectorization, however nothing happened. I would really appreciate if you could point me in the right direction with respect to vector generation. Any help is appreciated.> > -- > Mehdi >-- Rail Shafigulin Software Engineer Esencia Technologies -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160318/c938590e/attachment.html>
On Fri, Mar 18, 2016 at 2:03 PM, Rail Shafigulin <rail at esenciatech.com> wrote:> On Fri, Mar 18, 2016 at 1:53 PM, Mehdi Amini <mehdi.amini at apple.com> > wrote: > >> >> On Mar 18, 2016, at 1:47 PM, Rail Shafigulin <rail at esenciatech.com> >> wrote: >> >> Yes this IR does not build or shuffle any vector. Try to write a function >>> that takes 8 ints and a pointer to a <4xi32>, builds two vectors with the 8 >>> ints, >>> >> >> This might sound like a dumb question, but how does one build a vector of >> ints out of regular ints in IR? >> >> >> See: http://llvm.org/docs/LangRef.html#vector-operations >> >> In short, the IR has "insertelement", which maps to "INSERT_VECTOR_ELT" >> in SDAG and "extractelement", which maps to "EXTRACT_VECTOR_ELT" in SDAG. >> >> I usually find good example by grepping in the lit tests. Another way is >> to write the function in clang, and run it with -O3 -emit-llvm -S to get a >> good starting point. >> > I tried using clang test.c -O3 -emit-llvm -S, but the only I didn't see > any of the insertvectorelt or extractvectorelt. I'm wondering how does one > trigger vector operations? > > Below is the test.c file. It seemed to me like a good candidate for > vectorization, however nothing happened. I would really appreciate if you > could point me in the right > direction with respect to vector generation. > > Any help is appreciated. > > >> >> -- >> Mehdi >> > > > > -- > Rail Shafigulin > Software Engineer > Esencia Technologies >Forgot to attach a C file. Here it is: #define N 32 int main () { int a[N], b[N]; int c[N]; for (int i = 0; i < N; ++i) c[i] = a[i] + b[i]; int sum=0; for (int i = 0; i < N; ++i) sum += c[i]; return sum; } -- Rail Shafigulin Software Engineer Esencia Technologies -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160318/42b507f8/attachment.html>