[LLVMdev] Converting a i32 pointer to a vector of i32 ( C array to LLVM vector)

Tom Stellard tom at stellard.net
Wed Oct 16 17:28:01 PDT 2013


On Wed, Oct 16, 2013 at 11:14:06AM -0400, Matthieu Dubet wrote:
> Hi,
> 
> Thank you for the information,
> 
> So I'm now keeping the array as a pointer (i32*) but the vectorizer doesn't
> vectorize it .
> 
> I've pasted the function code before and after optimization (and the list
> of optimization that I have activated) in this Gist :
> https://gist.github.com/maattd/7008683
> 
> Some "weird" fact of my LLVM code :
> 
> * all variables (even the one used for the loop condition) are pointers to
> memory allocated from the C world and passed to the LLVM functions as an
> argument
> * even with "opt->add(new llvm::DataLayout(*ee->getDataLayout())) ;" in the
> code, the module->dump() doesn't output neither data layout, nor triple
> target
> 
> Both those points might confuse the vectorizer ?
> 
> 
> On Fri, Oct 11, 2013 at 1:40 PM, Renato Golin <renato.golin at linaro.org>wrote:
> 
> > On 11 October 2013 18:27, Matthieu Dubet <maattdd at gmail.com> wrote:
> >
> >> How can I tell LLVM to consider this i32* as an <10 x i32> (and thus get
> >> the performance improvements thanks to SIMD ..etc..) ?
> >>
> >
> > Hi Matthieu,
> >
> > You shouldn't need to do anything, the vectorizer should spot that for
> > you, if the machine you're compiling to has support for vector
> > instructions. Any kind of vector operations that you may want to hard-code
> > will make it not work on anything other than the intrinsics/inline asm
> > you're using, which is not a good idea.
> >

Which part of the vectorizer is responsible for doing pointer->vector transformations?

-Tom

> > If your code didn't get vectorized, it's possible that it is not clear
> > enough that that pointer is being iterated in a way that it's easy for the
> > vectorizer to spot, so maybe you need to make it clearer, and that depends
> > on the code in question. If you could share the code (or a similar example)
> > with the list, people could help you spot the pattern and make it vectorize.
> >
> > cheers,
> > --renato


> >

> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list