On Friday, 3 November 2017 at 19:46:58 UTC, Walter Bright wrote:
On 11/3/2017 3:02 AM, Mike Parker wrote:
For clarity, where the changeling says that GDC & LDC use
auto-vectorization, that's actually happening with the array
operations and core.simd is not required, correct?
I think that GDC and LDC do do auto-vectorization, but I
haven't verified it myself.
Auto-vectorization is a fundamentally bizarre feature. It takes
low level code and reverse-engineers it back into a higher
level construct, and then proceeds to generate code for that
higher level construct.
Everything else a compiler does is start from a high level
construct and then generate low level code.
The trouble with AV is whether it succeeds or not depends on
peculiarities (and I mean peculiarities) of the particular
vector instruction set target. It can decided to not vectorize
based on seemingly trivial and innocuous changes to the loop.
I’ll share an anecdotal experience from a time I worked in
reasearch lab of a well known tech giant. 2 senior researchers
spent literally 2 weeks trying to coerce compiler into
vectorizing an inner loop of a non-trivial matrix algorithm.
The only diagnostic from compiler was “loop form is not correct”.
Thankfully it did tell them it failed, else they’d have to
disassemble it each time.
I think eventually they either rewritten it to fit heuristic or
just carried on with explicit intrinsics.
What's needed is a language feature that is straightforwardly
vectorizable. That would be D's array operations.
Sadly array ops would be insufficient for said problem. It wasn’t
a direct element wise expression.