Skip to content

Commit 1c0fa0a

Browse files
dbriemannTheRealMDoerr
authored andcommitted
8352512: TestVectorZeroCount: counter not reset between iterations
Reviewed-by: mdoerr, chagedorn
1 parent 466f82a commit 1c0fa0a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

test/hotspot/jtreg/compiler/vectorization/TestVectorZeroCount.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,21 @@ public class TestVectorZeroCount {
5050
private static final long[] LONG_EXPECTED_TRAILING = new long[SIZE];
5151
private static final long[] LONG_RESULT_TRAILING = new long[SIZE];
5252

53-
private static int intCounter = Integer.MIN_VALUE;
54-
private static int longIterations = 100_000_000;
53+
private static final int INT_START_INDEX = Integer.MIN_VALUE;
54+
private static final int INT_END_INDEX = Integer.MAX_VALUE;
55+
private static final int LONG_START_INDEX = 0;
56+
private static final int LONG_END_INDEX = 100_000_000;
57+
58+
private static int intCounter;
59+
private static int longCounter;
5560

5661
public static boolean testInt() {
5762
boolean done = false;
5863

5964
// Non-vectorized loop as baseline (not vectorized because source array is initialized)
6065
for (int i = 0; i < SIZE; ++i) {
6166
INT_VALUES[i] = intCounter++;
62-
if (intCounter == Integer.MAX_VALUE) {
67+
if (intCounter == INT_END_INDEX) {
6368
done = true;
6469
}
6570
INT_EXPECTED_LEADING[i] = Integer.numberOfLeadingZeros(INT_VALUES[i]);
@@ -92,7 +97,7 @@ public static boolean testLong() {
9297
for (int i = 0; i < SIZE; ++i) {
9398
// Use random values because the long range is too large to iterate over it
9499
LONG_VALUES[i] = RANDOM.nextLong();
95-
if (longIterations-- == 0) {
100+
if (longCounter++ == LONG_END_INDEX) {
96101
done = true;
97102
}
98103
LONG_EXPECTED_LEADING[i] = Long.numberOfLeadingZeros(LONG_VALUES[i]);
@@ -121,6 +126,8 @@ public static boolean testLong() {
121126
public static void main(String[] args) {
122127
// Run twice to make sure compiled code is used from the beginning
123128
for (int i = 0; i < 2; ++i) {
129+
intCounter = INT_START_INDEX;
130+
longCounter = LONG_START_INDEX;
124131
while (!testLong()) ;
125132
while (!testInt()) ;
126133
}

0 commit comments

Comments
 (0)