< prev index next >

test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationMismatchedAccess.java

Print this page

148         int i;
149         for (i = 0; i < Math.max(offset, 0); i++) {
150             if (UNSAFE.getByte(null, baseOffHeap + i) != 0) {
151                 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != 0");
152             }
153         }
154         for (; i < Math.min(size * 8 + offset, size * 8); i++) {
155             if (UNSAFE.getByte(null, baseOffHeap + i) != verifyByteArray[i - offset]) {
156                 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != " + verifyByteArray[i-offset]);
157             }
158         }
159         for (; i < byteArray.length; i++) {
160             if (UNSAFE.getByte(null, baseOffHeap + i) != 0) {
161                 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != 0");
162             }
163         }
164     }
165 
166     @Test
167     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
168         applyIfOr = {"UseCompactObjectHeaders", "false", "AlignVector", "false"},
169         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
170         applyIfPlatform = {"64-bit", "true"})
171     // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned).
172     //         might get fixed with JDK-8325155.
173     public static void testByteLong1a(byte[] dest, long[] src) {
174         for (int i = 0; i < src.length; i++) {
175             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, handleByteOrder(src[i]));
176             // With AlignVector, we need 8-byte alignment of vector loads/stores.
177             // UseCompactObjectHeaders=false                  UseCompactObjectHeaders=true
178             // B_adr = base + 16 + 8*i  ->  always            B_adr = base + 12 + 8*i  ->  never
179             // L_adr = base + 16 + 8*i  ->  always            L_adr = base + 16 + 8*i  ->  always
180             // -> vectorize                                   -> no vectorization
181         }
182     }
183 
184     @Test
185     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
186         applyIfOr = {"UseCompactObjectHeaders", "false", "AlignVector", "false"},
187         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
188         applyIfPlatform = {"64-bit", "true"})
189     // 32-bit: address has ConvL2I for cast of long to address, not supported.
190     public static void testByteLong1b(byte[] dest, long[] src) {
191         for (int i = 0; i < src.length; i++) {
192             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * i, handleByteOrder(src[i]));
193             // With AlignVector, we need 8-byte alignment of vector loads/stores.
194             // UseCompactObjectHeaders=false                  UseCompactObjectHeaders=true
195             // B_adr = base + 16 + 8*i  ->  always            B_adr = base + 12 + 8*i  ->  never
196             // L_adr = base + 16 + 8*i  ->  always            L_adr = base + 16 + 8*i  ->  always
197             // -> vectorize                                   -> no vectorization
198         }
199     }
200 
201     @Test
202     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
203         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"})
204     public static void testByteLong1c(byte[] dest, long[] src) {
205         long base = 64; // make sure it is big enough and 8 byte aligned (required for 32-bit)
206         for (int i = 0; i < src.length - 8; i++) {
207             UNSAFE.putLongUnaligned(dest, base + 8 * i, handleByteOrder(src[i]));
208             // With AlignVector, we need 8-byte alignment of vector loads/stores.
209             // UseCompactObjectHeaders=false                  UseCompactObjectHeaders=true
210             // B_adr = base + 64 + 8*i  ->  always            B_adr = base + 64 + 8*i  ->  always
211             // L_adr = base + 16 + 8*i  ->  always            L_adr = base + 16 + 8*i  ->  always
212             // -> vectorize                                   -> vectorize
213         }
214     }
215 
216     @Test
217     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
218         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
219         applyIfPlatform = {"64-bit", "true"})
220     // 32-bit: address has ConvL2I for cast of long to address, not supported.
221     public static void testByteLong1d(byte[] dest, long[] src) {
222         long base = 64; // make sure it is big enough and 8 byte aligned (required for 32-bit)
223         for (int i = 0; i < src.length - 8; i++) {
224             UNSAFE.putLongUnaligned(dest, base + 8L * i, handleByteOrder(src[i]));
225             // With AlignVector, we need 8-byte alignment of vector loads/stores.
226             // UseCompactObjectHeaders=false                  UseCompactObjectHeaders=true
227             // B_adr = base + 64 + 8*i  ->  always            B_adr = base + 64 + 8*i  ->  always
228             // L_adr = base + 16 + 8*i  ->  always            L_adr = base + 16 + 8*i  ->  always
229             // -> vectorize                                   -> vectorize
230         }
231     }
232 
233     @Run(test = {"testByteLong1a", "testByteLong1b", "testByteLong1c", "testByteLong1d"})
234     public static void testByteLong1_runner() {
235         runAndVerify(() -> testByteLong1a(byteArray, longArray), 0);
236         runAndVerify(() -> testByteLong1b(byteArray, longArray), 0);
237         testByteLong1c(byteArray, longArray);
238         testByteLong1d(byteArray, longArray);
239     }
240 
241     @Test
242     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
243         applyIfOr = {"UseCompactObjectHeaders", "false", "AlignVector", "false"},
244         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
245         applyIfPlatform = {"64-bit", "true"})
246     // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned).
247     //         might get fixed with JDK-8325155.
248     public static void testByteLong2a(byte[] dest, long[] src) {
249         for (int i = 1; i < src.length; i++) {
250             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), handleByteOrder(src[i]));
251             // With AlignVector, we need 8-byte alignment of vector loads/stores.
252             // UseCompactObjectHeaders=false                      UseCompactObjectHeaders=true
253             // B_adr = base + 16 + 8*(i-1)  ->  always            B_adr = base + 12 + 8*(i-1)  ->  never
254             // L_adr = base + 16 + 8*i      ->  always            L_adr = base + 16 + 8*i      ->  always
255             // -> vectorize                                       -> no vectorization
256         }
257     }
258 
259     @Test
260     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
261         applyIfOr = {"UseCompactObjectHeaders", "false", "AlignVector", "false"},
262         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
263         applyIfPlatform = {"64-bit", "true"})
264     // 32-bit: address has ConvL2I for cast of long to address, not supported.
265     public static void testByteLong2b(byte[] dest, long[] src) {
266         for (int i = 1; i < src.length; i++) {
267             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i - 1), handleByteOrder(src[i]));
268             // With AlignVector, we need 8-byte alignment of vector loads/stores.
269             // UseCompactObjectHeaders=false                      UseCompactObjectHeaders=true
270             // B_adr = base + 16 + 8*(i-1)  ->  always            B_adr = base + 12 + 8*(i-1)  ->  never
271             // L_adr = base + 16 + 8*i      ->  always            L_adr = base + 16 + 8*i      ->  always
272             // -> vectorize                                       -> no vectorization
273         }
274     }
275 
276     @Run(test = {"testByteLong2a", "testByteLong2b"})
277     public static void testByteLong2_runner() {
278         runAndVerify(() -> testByteLong2a(byteArray, longArray), -8);
279         runAndVerify(() -> testByteLong2b(byteArray, longArray), -8);
280     }
281 
282     @Test
283     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
284         applyIfOr = {"UseCompactObjectHeaders", "false", "AlignVector", "false"},
285         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
286         applyIfPlatform = {"64-bit", "true"})
287     // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned).
288     //         might get fixed with JDK-8325155.
289     public static void testByteLong3a(byte[] dest, long[] src) {
290         for (int i = 0; i < src.length - 1; i++) {
291             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), handleByteOrder(src[i]));
292             // With AlignVector, we need 8-byte alignment of vector loads/stores.
293             // UseCompactObjectHeaders=false                      UseCompactObjectHeaders=true
294             // B_adr = base + 16 + 8*(i+1)  ->  always            B_adr = base + 12 + 8*(i+1)  ->  never
295             // L_adr = base + 16 + 8*i      ->  always            L_adr = base + 16 + 8*i      ->  always
296             // -> vectorize                                       -> no vectorization
297         }
298     }
299 
300     @Test
301     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
302         applyIfOr = {"UseCompactObjectHeaders", "false", "AlignVector", "false"},
303         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
304         applyIfPlatform = {"64-bit", "true"})
305     // 32-bit: address has ConvL2I for cast of long to address, not supported.
306     public static void testByteLong3b(byte[] dest, long[] src) {
307         for (int i = 0; i < src.length - 1; i++) {
308             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + 1), handleByteOrder(src[i]));
309             // With AlignVector, we need 8-byte alignment of vector loads/stores.
310             // UseCompactObjectHeaders=false                      UseCompactObjectHeaders=true
311             // B_adr = base + 16 + 8*(i+1)  ->  always            B_adr = base + 12 + 8*(i+1)  ->  never
312             // L_adr = base + 16 + 8*i      ->  always            L_adr = base + 16 + 8*i      ->  always
313             // -> vectorize                                       -> no vectorization
314         }
315     }
316 
317     @Run(test = {"testByteLong3a", "testByteLong3b"})
318     public static void testByteLong3_runner() {
319         runAndVerify(() -> testByteLong3a(byteArray, longArray), 8);
320         runAndVerify(() -> testByteLong3b(byteArray, longArray), 8);
321     }
322 
323     @Test
324     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
325         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
326         applyIfPlatform = {"64-bit", "true"},
327         applyIf = {"AlignVector", "false"})
328     // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned).
329     //         might get fixed with JDK-8325155.
330     // AlignVector cannot guarantee that invar is aligned.
331     public static void testByteLong4a(byte[] dest, long[] src, int start, int stop) {
332         for (int i = start; i < stop; i++) {
333             UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, handleByteOrder(src[i]));

339         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
340         applyIfPlatform = {"64-bit", "true"},
341         applyIf = {"AlignVector", "false"})
342     // 32-bit: address has ConvL2I for cast of long to address, not supported.
343     // AlignVector cannot guarantee that invar is aligned.
344     public static void testByteLong4b(byte[] dest, long[] src, int start, int stop) {
345         for (int i = start; i < stop; i++) {
346             UNSAFE.putLongUnaligned(dest, 8L * i + baseOffset, handleByteOrder(src[i]));
347         }
348     }
349 
350     @Run(test = {"testByteLong4a", "testByteLong4b"})
351     public static void testByteLong4_runner() {
352         baseOffset = UNSAFE.ARRAY_BYTE_BASE_OFFSET;
353         runAndVerify(() -> testByteLong4a(byteArray, longArray, 0, size), 0);
354         runAndVerify(() -> testByteLong4b(byteArray, longArray, 0, size), 0);
355     }
356 
357     @Test
358     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
359         applyIfOr = {"UseCompactObjectHeaders", "false", "AlignVector", "false"},
360         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
361         applyIfPlatform = {"64-bit", "true"})
362     // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned).
363     //         might get fixed with JDK-8325155.
364     public static void testByteLong5a(byte[] dest, long[] src, int start, int stop) {
365         for (int i = start; i < stop; i++) {
366             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), handleByteOrder(src[i]));
367             // With AlignVector, we need 8-byte alignment of vector loads/stores.
368             // UseCompactObjectHeaders=false                      UseCompactObjectHeaders=true
369             // B_adr = base + 16 + 8*(i+x)  ->  always            B_adr = base + 12 + 8*(i+x)  ->  never
370             // L_adr = base + 16 + 8*i      ->  always            L_adr = base + 16 + 8*i      ->  always
371             // -> vectorize                                       -> no vectorization
372         }
373     }
374 
375     @Test
376     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
377         applyIfOr = {"UseCompactObjectHeaders", "false", "AlignVector", "false"},
378         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
379         applyIfPlatform = {"64-bit", "true"})
380     // 32-bit: address has ConvL2I for cast of long to address, not supported.
381     public static void testByteLong5b(byte[] dest, long[] src, int start, int stop) {
382         for (int i = start; i < stop; i++) {
383             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + baseOffset), handleByteOrder(src[i]));
384             // With AlignVector, we need 8-byte alignment of vector loads/stores.
385             // UseCompactObjectHeaders=false                      UseCompactObjectHeaders=true
386             // B_adr = base + 16 + 8*(i+x)  ->  always            B_adr = base + 12 + 8*(i+x)  ->  never
387             // L_adr = base + 16 + 8*i      ->  always            L_adr = base + 16 + 8*i      ->  always
388             // -> vectorize                                       -> no vectorization
389         }
390     }
391 
392     @Run(test = {"testByteLong5a", "testByteLong5b"})
393     public static void testByteLong5_runner() {
394         baseOffset = 1;
395         runAndVerify(() -> testByteLong5a(byteArray, longArray, 0, size-1), 8);
396         runAndVerify(() -> testByteLong5b(byteArray, longArray, 0, size-1), 8);
397     }
398 
399     @Test
400     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
401         applyIfOr = {"UseCompactObjectHeaders", "false", "AlignVector", "false"},
402         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
403         applyIfPlatform = {"64-bit", "true"})
404     // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned).
405     //         might get fixed with JDK-8325155.
406     public static void testByteByte1a(byte[] dest, byte[] src) {
407         for (int i = 0; i < src.length / 8; i++) {
408             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
409             // With AlignVector, we need 8-byte alignment of vector loads/stores.
410             // UseCompactObjectHeaders=false                    UseCompactObjectHeaders=true
411             // src_adr = base + 16 + 8*i  ->  always            src_adr = base + 12 + 8*i  ->  never
412             // dst_adr = base + 16 + 8*i  ->  always            dst_adr = base + 12 + 8*i  ->  never
413             // -> vectorize                                     -> no vectorization
414         }
415     }
416 
417     @Test
418     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
419         applyIfOr = {"UseCompactObjectHeaders", "false", "AlignVector", "false"},
420         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
421         applyIfPlatform = {"64-bit", "true"})
422     // 32-bit: address has ConvL2I for cast of long to address, not supported.
423     public static void testByteByte1b(byte[] dest, byte[] src) {
424         for (int i = 0; i < src.length / 8; i++) {
425             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * i, UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * i));
426             // With AlignVector, we need 8-byte alignment of vector loads/stores.
427             // UseCompactObjectHeaders=false                    UseCompactObjectHeaders=true
428             // src_adr = base + 16 + 8*i  ->  always            src_adr = base + 12 + 8*i  ->  never
429             // dst_adr = base + 16 + 8*i  ->  always            dst_adr = base + 12 + 8*i  ->  never
430             // -> vectorize                                     -> no vectorization
431         }
432     }
433 
434     @Run(test = {"testByteByte1a", "testByteByte1b"})
435     public static void testByteByte1_runner() {
436         runAndVerify2(() -> testByteByte1a(byteArray, byteArray), 0);
437         runAndVerify2(() -> testByteByte1b(byteArray, byteArray), 0);
438     }
439 
440     @Test
441     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
442         applyIfOr = {"UseCompactObjectHeaders", "false", "AlignVector", "false"},
443         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
444         applyIfPlatform = {"64-bit", "true"})
445     // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned).
446     //         might get fixed with JDK-8325155.
447     public static void testByteByte2a(byte[] dest, byte[] src) {
448         for (int i = 1; i < src.length / 8; i++) {
449             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
450             // With AlignVector, we need 8-byte alignment of vector loads/stores.
451             // UseCompactObjectHeaders=false                        UseCompactObjectHeaders=true
452             // src_adr = base + 16 + 8*i      ->  always            src_adr = base + 12 + 8*i      ->  never
453             // dst_adr = base + 16 + 8*(i-1)  ->  always            dst_adr = base + 12 + 8*(i-1)  ->  never
454             // -> vectorize                                         -> no vectorization
455         }
456     }
457 
458     @Test
459     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
460         applyIfOr = {"UseCompactObjectHeaders", "false", "AlignVector", "false"},
461         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
462         applyIfPlatform = {"64-bit", "true"})
463     // 32-bit: address has ConvL2I for cast of long to address, not supported.
464     public static void testByteByte2b(byte[] dest, byte[] src) {
465         for (int i = 1; i < src.length / 8; i++) {
466             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i - 1), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * i));
467             // With AlignVector, we need 8-byte alignment of vector loads/stores.
468             // UseCompactObjectHeaders=false                        UseCompactObjectHeaders=true
469             // src_adr = base + 16 + 8*i      ->  always            src_adr = base + 12 + 8*i      ->  never
470             // dst_adr = base + 16 + 8*(i-1)  ->  always            dst_adr = base + 12 + 8*(i-1)  ->  never
471             // -> vectorize                                         -> no vectorization
472         }
473     }
474 
475     @Run(test = {"testByteByte2a", "testByteByte2b"})
476     public static void testByteByte2_runner() {
477         runAndVerify2(() -> testByteByte2a(byteArray, byteArray), -8);
478         runAndVerify2(() -> testByteByte2b(byteArray, byteArray), -8);
479     }
480 
481     @Test
482     @IR(failOn = { IRNode.LOAD_VECTOR_L, IRNode.STORE_VECTOR })
483     public static void testByteByte3a(byte[] dest, byte[] src) {
484         for (int i = 0; i < src.length / 8 - 1; i++) {
485             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
486         }
487     }
488 
489     @Test
490     @IR(failOn = { IRNode.LOAD_VECTOR_L, IRNode.STORE_VECTOR })
491     public static void testByteByte3b(byte[] dest, byte[] src) {

148         int i;
149         for (i = 0; i < Math.max(offset, 0); i++) {
150             if (UNSAFE.getByte(null, baseOffHeap + i) != 0) {
151                 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != 0");
152             }
153         }
154         for (; i < Math.min(size * 8 + offset, size * 8); i++) {
155             if (UNSAFE.getByte(null, baseOffHeap + i) != verifyByteArray[i - offset]) {
156                 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != " + verifyByteArray[i-offset]);
157             }
158         }
159         for (; i < byteArray.length; i++) {
160             if (UNSAFE.getByte(null, baseOffHeap + i) != 0) {
161                 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != 0");
162             }
163         }
164     }
165 
166     @Test
167     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },

168         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
169         applyIfPlatform = {"64-bit", "true"})
170     // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned).
171     //         might get fixed with JDK-8325155.
172     public static void testByteLong1a(byte[] dest, long[] src) {
173         for (int i = 0; i < src.length; i++) {
174             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, handleByteOrder(src[i]));





175         }
176     }
177 
178     @Test
179     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },

180         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
181         applyIfPlatform = {"64-bit", "true"})
182     // 32-bit: address has ConvL2I for cast of long to address, not supported.
183     public static void testByteLong1b(byte[] dest, long[] src) {
184         for (int i = 0; i < src.length; i++) {
185             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * i, handleByteOrder(src[i]));





186         }
187     }
188 
189     @Test
190     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
191         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"})
192     public static void testByteLong1c(byte[] dest, long[] src) {
193         long base = 64; // make sure it is big enough and 8 byte aligned (required for 32-bit)
194         for (int i = 0; i < src.length - 8; i++) {
195             UNSAFE.putLongUnaligned(dest, base + 8 * i, handleByteOrder(src[i]));





196         }
197     }
198 
199     @Test
200     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
201         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
202         applyIfPlatform = {"64-bit", "true"})
203     // 32-bit: address has ConvL2I for cast of long to address, not supported.
204     public static void testByteLong1d(byte[] dest, long[] src) {
205         long base = 64; // make sure it is big enough and 8 byte aligned (required for 32-bit)
206         for (int i = 0; i < src.length - 8; i++) {
207             UNSAFE.putLongUnaligned(dest, base + 8L * i, handleByteOrder(src[i]));





208         }
209     }
210 
211     @Run(test = {"testByteLong1a", "testByteLong1b", "testByteLong1c", "testByteLong1d"})
212     public static void testByteLong1_runner() {
213         runAndVerify(() -> testByteLong1a(byteArray, longArray), 0);
214         runAndVerify(() -> testByteLong1b(byteArray, longArray), 0);
215         testByteLong1c(byteArray, longArray);
216         testByteLong1d(byteArray, longArray);
217     }
218 
219     @Test
220     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },

221         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
222         applyIfPlatform = {"64-bit", "true"})
223     // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned).
224     //         might get fixed with JDK-8325155.
225     public static void testByteLong2a(byte[] dest, long[] src) {
226         for (int i = 1; i < src.length; i++) {
227             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), handleByteOrder(src[i]));





228         }
229     }
230 
231     @Test
232     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },

233         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
234         applyIfPlatform = {"64-bit", "true"})
235     // 32-bit: address has ConvL2I for cast of long to address, not supported.
236     public static void testByteLong2b(byte[] dest, long[] src) {
237         for (int i = 1; i < src.length; i++) {
238             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i - 1), handleByteOrder(src[i]));





239         }
240     }
241 
242     @Run(test = {"testByteLong2a", "testByteLong2b"})
243     public static void testByteLong2_runner() {
244         runAndVerify(() -> testByteLong2a(byteArray, longArray), -8);
245         runAndVerify(() -> testByteLong2b(byteArray, longArray), -8);
246     }
247 
248     @Test
249     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },

250         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
251         applyIfPlatform = {"64-bit", "true"})
252     // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned).
253     //         might get fixed with JDK-8325155.
254     public static void testByteLong3a(byte[] dest, long[] src) {
255         for (int i = 0; i < src.length - 1; i++) {
256             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), handleByteOrder(src[i]));





257         }
258     }
259 
260     @Test
261     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },

262         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
263         applyIfPlatform = {"64-bit", "true"})
264     // 32-bit: address has ConvL2I for cast of long to address, not supported.
265     public static void testByteLong3b(byte[] dest, long[] src) {
266         for (int i = 0; i < src.length - 1; i++) {
267             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + 1), handleByteOrder(src[i]));





268         }
269     }
270 
271     @Run(test = {"testByteLong3a", "testByteLong3b"})
272     public static void testByteLong3_runner() {
273         runAndVerify(() -> testByteLong3a(byteArray, longArray), 8);
274         runAndVerify(() -> testByteLong3b(byteArray, longArray), 8);
275     }
276 
277     @Test
278     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
279         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
280         applyIfPlatform = {"64-bit", "true"},
281         applyIf = {"AlignVector", "false"})
282     // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned).
283     //         might get fixed with JDK-8325155.
284     // AlignVector cannot guarantee that invar is aligned.
285     public static void testByteLong4a(byte[] dest, long[] src, int start, int stop) {
286         for (int i = start; i < stop; i++) {
287             UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, handleByteOrder(src[i]));

293         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
294         applyIfPlatform = {"64-bit", "true"},
295         applyIf = {"AlignVector", "false"})
296     // 32-bit: address has ConvL2I for cast of long to address, not supported.
297     // AlignVector cannot guarantee that invar is aligned.
298     public static void testByteLong4b(byte[] dest, long[] src, int start, int stop) {
299         for (int i = start; i < stop; i++) {
300             UNSAFE.putLongUnaligned(dest, 8L * i + baseOffset, handleByteOrder(src[i]));
301         }
302     }
303 
304     @Run(test = {"testByteLong4a", "testByteLong4b"})
305     public static void testByteLong4_runner() {
306         baseOffset = UNSAFE.ARRAY_BYTE_BASE_OFFSET;
307         runAndVerify(() -> testByteLong4a(byteArray, longArray, 0, size), 0);
308         runAndVerify(() -> testByteLong4b(byteArray, longArray, 0, size), 0);
309     }
310 
311     @Test
312     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },

313         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
314         applyIfPlatform = {"64-bit", "true"})
315     // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned).
316     //         might get fixed with JDK-8325155.
317     public static void testByteLong5a(byte[] dest, long[] src, int start, int stop) {
318         for (int i = start; i < stop; i++) {
319             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), handleByteOrder(src[i]));





320         }
321     }
322 
323     @Test
324     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },

325         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
326         applyIfPlatform = {"64-bit", "true"})
327     // 32-bit: address has ConvL2I for cast of long to address, not supported.
328     public static void testByteLong5b(byte[] dest, long[] src, int start, int stop) {
329         for (int i = start; i < stop; i++) {
330             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + baseOffset), handleByteOrder(src[i]));





331         }
332     }
333 
334     @Run(test = {"testByteLong5a", "testByteLong5b"})
335     public static void testByteLong5_runner() {
336         baseOffset = 1;
337         runAndVerify(() -> testByteLong5a(byteArray, longArray, 0, size-1), 8);
338         runAndVerify(() -> testByteLong5b(byteArray, longArray, 0, size-1), 8);
339     }
340 
341     @Test
342     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },

343         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
344         applyIfPlatform = {"64-bit", "true"})
345     // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned).
346     //         might get fixed with JDK-8325155.
347     public static void testByteByte1a(byte[] dest, byte[] src) {
348         for (int i = 0; i < src.length / 8; i++) {
349             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));





350         }
351     }
352 
353     @Test
354     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },

355         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
356         applyIfPlatform = {"64-bit", "true"})
357     // 32-bit: address has ConvL2I for cast of long to address, not supported.
358     public static void testByteByte1b(byte[] dest, byte[] src) {
359         for (int i = 0; i < src.length / 8; i++) {
360             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * i, UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * i));





361         }
362     }
363 
364     @Run(test = {"testByteByte1a", "testByteByte1b"})
365     public static void testByteByte1_runner() {
366         runAndVerify2(() -> testByteByte1a(byteArray, byteArray), 0);
367         runAndVerify2(() -> testByteByte1b(byteArray, byteArray), 0);
368     }
369 
370     @Test
371     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },

372         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
373         applyIfPlatform = {"64-bit", "true"})
374     // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned).
375     //         might get fixed with JDK-8325155.
376     public static void testByteByte2a(byte[] dest, byte[] src) {
377         for (int i = 1; i < src.length / 8; i++) {
378             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));





379         }
380     }
381 
382     @Test
383     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },

384         applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"},
385         applyIfPlatform = {"64-bit", "true"})
386     // 32-bit: address has ConvL2I for cast of long to address, not supported.
387     public static void testByteByte2b(byte[] dest, byte[] src) {
388         for (int i = 1; i < src.length / 8; i++) {
389             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i - 1), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * i));





390         }
391     }
392 
393     @Run(test = {"testByteByte2a", "testByteByte2b"})
394     public static void testByteByte2_runner() {
395         runAndVerify2(() -> testByteByte2a(byteArray, byteArray), -8);
396         runAndVerify2(() -> testByteByte2b(byteArray, byteArray), -8);
397     }
398 
399     @Test
400     @IR(failOn = { IRNode.LOAD_VECTOR_L, IRNode.STORE_VECTOR })
401     public static void testByteByte3a(byte[] dest, byte[] src) {
402         for (int i = 0; i < src.length / 8 - 1; i++) {
403             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
404         }
405     }
406 
407     @Test
408     @IR(failOn = { IRNode.LOAD_VECTOR_L, IRNode.STORE_VECTOR })
409     public static void testByteByte3b(byte[] dest, byte[] src) {
< prev index next >