The main problem people run into is that they see the compiler flounder at autovectorization and arrogantly assume that it's just stupid, rather than asking why it didn't do what they expected and trying to figure out what it got hung up on. If you put in the effort to do that, then you might be surprised at how good they can be and you might save yourself some time & effort from having to do the entire process by hand.
It's the programmer's fault for not telling the compiler those things won't happen. The language is well-defined and the tools give you nearly all the expressiveness you need to say what you actually mean. If you fail to tell the compiler what you really mean, that's on you, not the compiler.
Seriously, do you hear machinists blaming their milling machines for being dumb and advising to do the work by hand? No! They learn how to use their tools and we should do the same![/QUOTE]
There is a reason why every popular FOSS software that needs SIMD, the devs write it by hand with assembly or intrinsics, like FFMPEG, Blender, and so on.
Look great devs, like Daniel Lemire in his blog, he is a expert in ow level programming and always vectoruze by hand.
Auto-vectorization is very hard to be done by compilers, it is a intrinsically complex problem, it is the only optimization where a assembly programmer can easily outperform a compiler.
And also very fragile, there can be a regression on new compiler version. And not work on older versions.
So if you want RELIABLE vectorization, that will never stop working on a compiler update, and will work on older compiler version.
Comment