[LLVMdev] On large vectors

Renato Golin renato.golin at linaro.org
Wed Feb 6 10:40:05 PST 2013


On 6 February 2013 18:02, David Given <dg at cowlark.com> wrote:

> I have actually been reading up on the vectorizer. I'm using LLVM 3.2,
> so the vectorizer isn't turned on by default.


Not just that, but there is also a lot more coverage since last release
(including floating points).


Would it be feasible to
> explicitly *not* use vectors --- switching to aggregates instead --- and
> then rely on the vectorizer to autovectorize the code where appropriate?
>


It depends. If you use vectors that are within the boundaries of the
target's vector sizes, than you can possibly generate better code directly.
For instance, if your array has only 3 elements <3 x float>, the vectorizer
could think it's not worth to change it. But if you generated all in vector
types all the way through, the cost of using vector engines is reduced, and
it may be worth even if the vectorizer thinks otherwise. As usual, this is
not always true, as sometimes the vectorizer sees patterns you don't, or
can add run-time checks to do selective vectorization and so on.

In the long term, I think it's best to expect the compiler to do the hard
work for you, and teach the compiler to recognize such cases, than add
special cases on your own programs. As of now, though, you may have to
balance.

It'd be interesting to see a comparison of IRs and benchmarks for programs
running with long vectors vs. arrays, and short non-power-of-two vectors
vs. arrays.

cheers,
--renato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130206/4e037b90/attachment.html>


More information about the llvm-dev mailing list