UseSuperWord - turned off, still emitting vector instructions?!
Christian Hagedorn
christian.hagedorn at oracle.com
Thu Aug 17 13:31:39 UTC 2023
Hi Martin
-XX:-UseSuperWord will turn off auto-vectorization. What you are observing is
that for some instructions like adding two floats (AddFNode), we directly emit
some vector instructions if the AVX instructions are available. This is done
independently of auto-vectorization.
AddFNode is matched with the addF_reg_mem rule which emits vaddss:
https://github.com/openjdk/jdk/blob/c634bdf9d917c96c38efe826239eab7900c33e74/src/hotspot/cpu/x86/x86.ad#L2987-L2997
For example, this code:
static float test() {
return floatFlield + 3.4f;
}
will be compiled to (if UseAVX > 0):
vmovss -0x4c(%rip),%xmm1 # 0x00007fca3c5b1aa0
vaddss 0x70(%r10),%xmm1,%xmm0 ;*fadd {reexecute=0 rethrow=0 return_oop=0}
So, even if you turn off auto-vectorization, C2 will still emit vector
instructions for some code.
Best regards,
Christian
On 17.08.23 15:00, Martin Stypinski wrote:
> I am benchmarking some algorithms, wondering how much the JIT applies
> auto-vectorization. I set up a JMH project and am trying to turn
> auto-vectorization off.
>
>
> The code snipped, and the results can be found in the following
> gist: https://gist.github.com/Styp/16e8a20fedfb771107377407fc1cf210
> <https://gist.github.com/Styp/16e8a20fedfb771107377407fc1cf210> (Sorry too long
> to post here).
>
>
> The results indicate that one is faster than the other, which is expected.
> Nevertheless, the deviation is so high that the benchmark is not representative.
> What irritates me the most is that the version with turned of SuperWord still
> contains vadd and vmove instructions in the Jit-generated code. Do I miss
> something? How can I enforce vectorization turned off for good?
>
> Any ideas?
>
More information about the discuss
mailing list