@@ -50,16 +50,21 @@ public class TestVectorZeroCount {
50
50
private static final long [] LONG_EXPECTED_TRAILING = new long [SIZE ];
51
51
private static final long [] LONG_RESULT_TRAILING = new long [SIZE ];
52
52
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 ;
55
60
56
61
public static boolean testInt () {
57
62
boolean done = false ;
58
63
59
64
// Non-vectorized loop as baseline (not vectorized because source array is initialized)
60
65
for (int i = 0 ; i < SIZE ; ++i ) {
61
66
INT_VALUES [i ] = intCounter ++;
62
- if (intCounter == Integer . MAX_VALUE ) {
67
+ if (intCounter == INT_END_INDEX ) {
63
68
done = true ;
64
69
}
65
70
INT_EXPECTED_LEADING [i ] = Integer .numberOfLeadingZeros (INT_VALUES [i ]);
@@ -92,7 +97,7 @@ public static boolean testLong() {
92
97
for (int i = 0 ; i < SIZE ; ++i ) {
93
98
// Use random values because the long range is too large to iterate over it
94
99
LONG_VALUES [i ] = RANDOM .nextLong ();
95
- if (longIterations -- == 0 ) {
100
+ if (longCounter ++ == LONG_END_INDEX ) {
96
101
done = true ;
97
102
}
98
103
LONG_EXPECTED_LEADING [i ] = Long .numberOfLeadingZeros (LONG_VALUES [i ]);
@@ -121,6 +126,8 @@ public static boolean testLong() {
121
126
public static void main (String [] args ) {
122
127
// Run twice to make sure compiled code is used from the beginning
123
128
for (int i = 0 ; i < 2 ; ++i ) {
129
+ intCounter = INT_START_INDEX ;
130
+ longCounter = LONG_START_INDEX ;
124
131
while (!testLong ()) ;
125
132
while (!testInt ()) ;
126
133
}
0 commit comments