Skip to content

Commit

Permalink
8309129: AArch64: guarantee(T != T2S) failed: "incorrect arrangement"…
Browse files Browse the repository at this point in the history
… after JDK-8307795

Reviewed-by: thartmann, xgong, eastigeevich
  • Loading branch information
changpeng1997 authored and TobiHartmann committed Jun 5, 2023
1 parent 9be5769 commit 6d511f1
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 23 deletions.
10 changes: 5 additions & 5 deletions src/hotspot/cpu/aarch64/aarch64_vector.ad
Original file line number Diff line number Diff line change
Expand Up @@ -5522,12 +5522,12 @@ instruct vstoremask_truecount_neon(iRegINoSp dst, vReg src, immI_gt_1 size, vReg
// Input "src" is a vector mask represented as lanes with
// 0/-1 as element values.
uint esize = (uint)$size$$constant;
if (esize == 8) {
__ addpd($vtmp$$FloatRegister, $src$$FloatRegister);
uint length_in_bytes = Matcher::vector_length_in_bytes(this, $src);
Assembler::SIMD_Arrangement arrangement = Assembler::esize2arrangement(esize,
/* isQ */ length_in_bytes == 16);
if (arrangement == __ T2D || arrangement == __ T2S) {
__ addpv($vtmp$$FloatRegister, arrangement, $src$$FloatRegister, $src$$FloatRegister);
} else {
uint length_in_bytes = Matcher::vector_length_in_bytes(this, $src);
Assembler::SIMD_Arrangement arrangement = Assembler::esize2arrangement(esize,
/* isQ */ length_in_bytes == 16);
__ addv($vtmp$$FloatRegister, arrangement, $src$$FloatRegister);
}
__ smov($dst$$Register, $vtmp$$FloatRegister, __ B, 0);
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/cpu/aarch64/aarch64_vector_ad.m4
Original file line number Diff line number Diff line change
Expand Up @@ -3832,12 +3832,12 @@ instruct vstoremask_truecount_neon(iRegINoSp dst, vReg src, immI_gt_1 size, vReg
// Input "src" is a vector mask represented as lanes with
// 0/-1 as element values.
uint esize = (uint)$size$$constant;
if (esize == 8) {
__ addpd($vtmp$$FloatRegister, $src$$FloatRegister);
uint length_in_bytes = Matcher::vector_length_in_bytes(this, $src);
Assembler::SIMD_Arrangement arrangement = Assembler::esize2arrangement(esize,
/* isQ */ length_in_bytes == 16);
if (arrangement == __ T2D || arrangement == __ T2S) {
__ addpv($vtmp$$FloatRegister, arrangement, $src$$FloatRegister, $src$$FloatRegister);
} else {
uint length_in_bytes = Matcher::vector_length_in_bytes(this, $src);
Assembler::SIMD_Arrangement arrangement = Assembler::esize2arrangement(esize,
/* isQ */ length_in_bytes == 16);
__ addv($vtmp$$FloatRegister, arrangement, $src$$FloatRegister);
}
__ smov($dst$$Register, $vtmp$$FloatRegister, __ B, 0);
Expand Down
64 changes: 52 additions & 12 deletions test/hotspot/jtreg/compiler/vectorapi/TestVectorMaskTrueCount.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
*/

public class TestVectorMaskTrueCount {
private static final VectorSpecies<Double> SPECIES = DoubleVector.SPECIES_PREFERRED;
private static final VectorSpecies<Float> SPECIES_F = FloatVector.SPECIES_64;
private static final VectorSpecies<Double> SPECIES_D = DoubleVector.SPECIES_128;
private static final VectorSpecies<Integer> SPECIES_I = IntVector.SPECIES_128;
private static final int LENGTH = 1024;
private static final Random RD = new Random();
private static boolean[] ba;
Expand All @@ -57,11 +59,11 @@ public class TestVectorMaskTrueCount {
}
}

static int maskAndTrueCount(boolean[] a, boolean[] b, int idx) {
static int maskAndTrueCount(boolean[] a, boolean[] b, int idx, int count) {
int trueCount = 0;
boolean[] c = new boolean[SPECIES.length()];
boolean[] c = new boolean[count];

for (int i = idx; i < idx + SPECIES.length(); i++) {
for (int i = idx; i < idx + count; i++) {
c[i - idx] = a[i] & b[i];
}

Expand All @@ -72,23 +74,61 @@ static int maskAndTrueCount(boolean[] a, boolean[] b, int idx) {
return trueCount;
}

static void assertArrayEquals(int[] r, boolean[] a, boolean[] b) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
Asserts.assertEquals(r[i], maskAndTrueCount(a, b, i));
static void assertArrayEqualsFloat(int[] r, boolean[] a, boolean[] b) {
for (int i = 0; i < a.length; i += SPECIES_F.length()) {
Asserts.assertEquals(r[i], maskAndTrueCount(a, b, i, SPECIES_F.length()));
}
}

static void assertArrayEqualsDouble(int[] r, boolean[] a, boolean[] b) {
for (int i = 0; i < a.length; i += SPECIES_D.length()) {
Asserts.assertEquals(r[i], maskAndTrueCount(a, b, i, SPECIES_D.length()));
}
}

static void assertArrayEqualsInteger(int[] r, boolean[] a, boolean[] b) {
for (int i = 0; i < a.length; i += SPECIES_I.length()) {
Asserts.assertEquals(r[i], maskAndTrueCount(a, b, i, SPECIES_I.length()));
}
}

@Test
@IR(counts = { IRNode.VSTOREMASK_TRUECOUNT, ">= 1" })
public static void testFloat() {
int[] r = new int[LENGTH];
for (int i = 0; i < LENGTH; i += SPECIES_F.length()) {
VectorMask<Float> ma = VectorMask.fromArray(SPECIES_F, ba, i);
VectorMask<Float> mb = VectorMask.fromArray(SPECIES_F, bb, i);
r[i] = ma.and(mb).trueCount();
}

assertArrayEqualsFloat(r, ba, bb);
}

@Test
@IR(counts = { IRNode.VSTOREMASK_TRUECOUNT, ">= 1" })
public static void testDouble() {
int[] r = new int[LENGTH];
for (int i = 0; i < LENGTH; i += SPECIES_D.length()) {
VectorMask<Double> ma = VectorMask.fromArray(SPECIES_D, ba, i);
VectorMask<Double> mb = VectorMask.fromArray(SPECIES_D, bb, i);
r[i] = ma.and(mb).trueCount();
}

assertArrayEqualsDouble(r, ba, bb);
}

@Test
@IR(counts = { IRNode.VSTOREMASK_TRUECOUNT, ">= 1" })
public static void test() {
public static void testInt() {
int[] r = new int[LENGTH];
for (int i = 0; i < LENGTH; i += SPECIES.length()) {
VectorMask<Double> ma = VectorMask.fromArray(SPECIES, ba, i);
VectorMask<Double> mb = VectorMask.fromArray(SPECIES, bb, i);
for (int i = 0; i < LENGTH; i += SPECIES_I.length()) {
VectorMask<Integer> ma = VectorMask.fromArray(SPECIES_I, ba, i);
VectorMask<Integer> mb = VectorMask.fromArray(SPECIES_I, bb, i);
r[i] = ma.and(mb).trueCount();
}

assertArrayEquals(r, ba, bb);
assertArrayEqualsInteger(r, ba, bb);
}

public static void main(String[] args) {
Expand Down
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,6 @@ jdk/incubator/concurrent/ScopedValue/StressStackOverflow.java 8303498 linux-s3

jdk/incubator/vector/ShortMaxVectorTests.java 8306592 generic-i586
jdk/incubator/vector/LoadJsvmlTest.java 8305390 windows-x64
jdk/incubator/vector/Float64VectorTests.java 8309129 generic-aarch64

############################################################################

Expand Down

1 comment on commit 6d511f1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.