I had actually posted an annotated assembly output for one of this example vector tests (the doAddArraysIfEven one) here: https://groups.google.com/d/msg/mechanical-sympathy/EMIBqjX4...
Enjoy!
Re:New JIT optimizer in the Zing JVM
by mike_hearn on Thursday May 04, 2017 @04:17AM
(#14263366)
If you're testing with JDK8 you're missing the last two years of work on the optimiser. I'd be interested to see what Java 9 does, as it's (supposedly) coming out in a few months.
Re:New JIT optimizer in the Zing JVM
by opportun1st on Thursday May 04, 2017 @02:39PM
(#14267493)
JDK9 has the capability to vectorize a loop with branch inside. I tried JDK9 early release with a simple testing case myself.
you certainly can vectorize branch in a loop. Unroll loop, compute conditions in parallel, use result as a mask for conditional computation.
The parent's point was that the JVM didn't vectorize, not that it wasn't possible.
I'm actually curious to see what the output assembly of LLVM is for that loop, because JDK8 does not optimize a branch in a loop.
But the JVM does do a pretty decent job using ymm<n> registers if you write the loops without branches.
But you end up with really obscure java code like
"(((a - b) ^ (b - a)) >>> 63) ^ 1"
To convert a branch into an integer.