Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Member

Choose a reason for hiding this comment

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

I see jdk/incubator/vector/Float64VectorTests.java covers the case arrangement == __ T2S.
Is there a test covering the case arrangement == __ T2D?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see jdk/incubator/vector/Float64VectorTests.java covers the case arrangement == __ T2S. Is there a test covering the case arrangement == __ T2D?

Thanks for your review.
I don't find such a case. I will add a test case in TestVectorMaskTrueCount.java to cover arrangement == __ T2D.

__ 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