[jdk16] RFR: 8259775: [Vector API] Incorrect code-gen for VectorReinterpret operation

Jie Fu jiefu at openjdk.java.net
Thu Jan 14 12:37:11 UTC 2021


Hi all,

The code-gen for VectorReinterpret may be wrong on x86.

Let's see the opto-assembly for the reproducer in the JBS, which was actually based on @XiaohongGong 's example in JDK-8259353 and many thanks to her.
066     B7: #   out( N1 ) <- in( B6 )  Freq: 0.999994
066     vector_reinterpret_expand XMM0,XMM0     !
066     store_vector [R12 + R11 << 3 + #16] (compressed oop addressing),XMM0
 
Please note that the dst and src [1] share the same XMM0 register and movdqu [2] should be generated for this case.
But when dst == src, movdqu actually generates nothing [3], which leads to incorrect result;

For this case, movdqu should not be empty since the upper bits of dst should be zeroed.
The similar error also exists for vmovdqu [4].

I think we should also change movflt [5] to movss but I just can't understand why we have 4-byte vectors.
Isn't the shortest vectors 8-byte on x86?

Thanks.
Best regards,
Jie

[1] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/x86.ad#L3354
[2] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/x86.ad#L3364
[3] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/macroAssembler_x86.cpp#L2490
[4] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/macroAssembler_x86.cpp#L2515
[5] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/x86.ad#L3379

-------------

Commit messages:
 - 8259775: [Vector API] Incorrect code-gen for VectorReinterpret operation

Changes: https://git.openjdk.java.net/jdk16/pull/122/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk16&pr=122&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8259775
  Stats: 2 lines in 1 file changed: 0 ins; 2 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk16/pull/122.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk16 pull/122/head:pull/122

PR: https://git.openjdk.java.net/jdk16/pull/122


More information about the hotspot-compiler-dev mailing list