Not auto-vectorization

bearophile bearophileHUGS at lycos.com
Tue May 22 11:52:10 PDT 2012


On Reddit they have linked an article that shows auto 
vectorization in GCC 4.7:

http://locklessinc.com/articles/vectorize/

http://www.reddit.com/r/programming/comments/tz6ml/autovectorization_with_gcc_47/

GCC is good, it knows many tricks, it contains a lot of pattern 
matching code and other code to allow such vectorizations, and 
that C code is almost transparent & standard (restrict is 
standard, and I think __builtin_assume_aligned isn't too much 
hard to #define away when not available. And something like 
--fast-math is available on most compilers (despite Walter 
doesn't like it)). So it's good to optimize legacy C code too.

But this article also shows why such strategy is not usable for 
serious purposes. If small changes risk turning off such major 
optimizations, you can't rely much on them. More generally, 
writing low-level code and hoping the compiler recovers that high 
level semantics of the code is a bit ridiculous. It's way better 
to express that semantics in a more direct way, in a standard way 
that's understood by all compilers of a language (this also 
because the code shown in that article has very simple semantics).

How is the development of the D SIMD ops going? Are those efforts 
(maybe with the help of another higher level Phobos lib) going to 
avoid the silly problems shown in that article?

Bye,
bearophile


More information about the Digitalmars-d mailing list