[jdk16] RFR: 8258703: Incorrect 512-bit vector registers restore on x86_32

Jie Fu jiefu at openjdk.java.net
Wed Dec 23 09:10:06 UTC 2020


Hi all,

Following tests fail on our AVX512 machines with x86_32:
  - compiler/runtime/Test7196199.java
  - compiler/runtime/safepoints/TestRegisterRestoring.java
  - compiler/vectorization/TestVectorsNotSavedAtSafepoint.java

The reason is that 512-bit registers (zmm0 ~ zmm7) are restored incorrectly.

Current restore logic for 512-bit registers includes:
  1) restore zmm[511..256] [1]
  2) restore zmm[255..128] [2]  <-- Wrong on AVX512 with avx512vl

On our AVX512 machine, Assembler::vinsertf128 [3] was called in step 2).
According to the Intel instruction set reference,  vinsertf128 just copies the lower half of zmm, which lost the upper half of zmm.
   VINSERTF128 (VEX encoded version)
   TEMP[255:0] <- SRC1[255:0]
   CASE (imm8[0]) OF
   0: TEMP[127:0]   <- SRC2[127:0]
   1: TEMP[255:128] <- SRC2[127:0]
   ESAC
   DEST <- TEMP

The fix just changes the order of the restore logic for 512-bit registers:
  1) restore zmm[255..128] 
  2) restore zmm[511..256] 

Thanks.
Best regards,
Jie

[1] https://github.com/openjdk/jdk16/blob/master/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp#L320
[2] https://github.com/openjdk/jdk16/blob/master/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp#L326
[3] https://github.com/openjdk/jdk16/blob/master/src/hotspot/cpu/x86/macroAssembler_x86.hpp#L1463

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

Commit messages:
 - 8258703: Incorrect 512-bit vector registers restore on x86_32

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

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


More information about the hotspot-compiler-dev mailing list