[jdk18] RFR: 8278889: AArch64: [vectorapi] VectorMaskLoadStoreTest.testMaskCast() test fail

Ningsheng Jian njian at openjdk.java.net
Tue Dec 21 07:01:25 UTC 2021


On Mon, 20 Dec 2021 15:35:47 GMT, Eric Liu <eliu at openjdk.org> wrote:

> This bug appears intermittently and it's caused by vmaskAll_immI[1]
> when the vector mask size is smaller than max predicate size of running
> machine. It generates an all-true predicate without considering those
> inactive bits. That may result in the wrong result of VectorMask.toLong.
> The problematic code is as below:
> 
> 
>         ShortVector.SPECIES_64.MaskAll(true).toLong()
> 
> assembly:
> 
>         ptrue   p0.h          <= MaskAll(true)
>         mov     z16.h, p0/z, #1
>         mov     z17.h, #0
>         uzp1    z16.b, z16.b, z17.b
>         fmov    x10, d16
>         orr     x10, x10, x10, lsr #7
>         orr     x10, x10, x10, lsr #14
>         orr     x10, x10, x10, lsr #28
>         and     x10, x10, #0xff
> 
> (gdb) p/x $p0 # on an SVE machine with vector length as 64 in bytes
> $1 = {0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55}
> 
> Expected:
> (gdb) p/x $p0
> $1 = {0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
> 
> 
> 
> Considering MaskAll is used in VectorMask.fromLong() only for a special
> case and relies on the mechanism of inline and intrinsification, even it
> could be optimized out, this patch also adds test cases for MaskAll to
> reproduce this issue stably.
> 
> Also fix a small issue on register utilization for
> sve_reduce_[max|min][D|F].
> 
> [1] https://github.com/openjdk/jdk18/blob/master/src/hotspot/cpu/aarch64/aarch64_sve.ad#L416
> 
> hotspot/compiler/vectorapi, jdk/incubator/vector passed on SVE enabled
> system.
> 
> Change-Id: I9631f26f9232ffe7a28b74f14062d945c32fa1fb

Thanks for the fix! Overall looks good to me. Just one enhancement suggestion.

src/hotspot/cpu/aarch64/aarch64_sve_ad.m4 line 389:

> 387:     Assembler::SIMD_RegVariant size = __ elemType_to_regVariant(bt);
> 388:     __ sve_dup(as_FloatRegister($tmp$$reg), size, as_Register($src$$reg));
> 389:     __ sve_ptrue_lanecnt(as_PRegister($dst$$reg), size, Matcher::vector_length(this));

I think you can generate this insn conditionally, only when current vector size is not MaxVectorSize.

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

Marked as reviewed by njian (Committer).

PR: https://git.openjdk.java.net/jdk18/pull/49


More information about the hotspot-compiler-dev mailing list