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

Matthieu Dubet maattdd at gmail.com
Wed Oct 16 08:14:06 PDT 2013


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.
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131016/545d0f5a/attachment.html>


More information about the llvm-dev mailing list