Skip to content

8352512: TestVectorZeroCount: counter not reset between iterations #24134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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
15 changes: 11 additions & 4 deletions test/hotspot/jtreg/compiler/vectorization/TestVectorZeroCount.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,21 @@ public class TestVectorZeroCount {
private static final long[] LONG_EXPECTED_TRAILING = new long[SIZE];
private static final long[] LONG_RESULT_TRAILING = new long[SIZE];

private static int intCounter = Integer.MIN_VALUE;
private static int longIterations = 100_000_000;
private static final int INT_START_INDEX = Integer.MIN_VALUE;
private static final int INT_END_INDEX = Integer.MAX_VALUE;
private static final int LONG_START_INDEX = 0;
private static final int LONG_END_INDEX = 100_000_000;

private static int intCounter;
private static int longCounter;

public static boolean testInt() {
boolean done = false;

// Non-vectorized loop as baseline (not vectorized because source array is initialized)
for (int i = 0; i < SIZE; ++i) {
INT_VALUES[i] = intCounter++;
if (intCounter == Integer.MAX_VALUE) {
if (intCounter == INT_END_INDEX) {
done = true;
}
INT_EXPECTED_LEADING[i] = Integer.numberOfLeadingZeros(INT_VALUES[i]);
Expand Down Expand Up @@ -92,7 +97,7 @@ public static boolean testLong() {
for (int i = 0; i < SIZE; ++i) {
// Use random values because the long range is too large to iterate over it
LONG_VALUES[i] = RANDOM.nextLong();
if (longIterations-- == 0) {
if (longCounter++ == LONG_END_INDEX) {
done = true;
}
LONG_EXPECTED_LEADING[i] = Long.numberOfLeadingZeros(LONG_VALUES[i]);
Expand Down Expand Up @@ -121,6 +126,8 @@ public static boolean testLong() {
public static void main(String[] args) {
// Run twice to make sure compiled code is used from the beginning
for (int i = 0; i < 2; ++i) {
intCounter = INT_START_INDEX;
longCounter = LONG_START_INDEX;
while (!testLong()) ;
while (!testInt()) ;
}
Expand Down