From 237221d6262c18f86ce37d36efc6af0b79a5f28e Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Mon, 28 Oct 2024 15:19:06 +0530 Subject: [PATCH] enable --- .../TestVectorizationMismatchedAccess.java | 198 ++++++++++-------- 1 file changed, 111 insertions(+), 87 deletions(-) diff --git a/test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationMismatchedAccess.java b/test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationMismatchedAccess.java index 968ea31be9e8c..99d2013d7f3d8 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationMismatchedAccess.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationMismatchedAccess.java @@ -249,98 +249,122 @@ public static void testByteLong2_runner() { runAndVerify(() -> testByteLong2b(byteArray, longArray), -8); } -// @Test -// @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" }, -// applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"}, -// applyIfPlatform = {"64-bit", "true"}) -// // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned). -// // might get fixed with JDK-8325155. -// public static void testByteLong3a(byte[] dest, long[] src) { -// for (int i = 0; i < src.length - 1; i++) { -// UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), src[i]); -// } -// } + @Test + @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" }, + applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"}, + applyIfPlatform = {"64-bit", "true"}) + // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned). + // might get fixed with JDK-8325155. + public static void testByteLong3a(byte[] dest, long[] src) { + for (int i = 0; i < src.length - 1; i++) { + long value = src[i]; + if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) { + value = Long.reverseBytes(value); + } + UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), value); + } + } -// @Test -// @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" }, -// applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"}, -// applyIfPlatform = {"64-bit", "true"}) -// // 32-bit: address has ConvL2I for cast of long to address, not supported. -// public static void testByteLong3b(byte[] dest, long[] src) { -// for (int i = 0; i < src.length - 1; i++) { -// UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + 1), src[i]); -// } -// } + @Test + @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" }, + applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"}, + applyIfPlatform = {"64-bit", "true"}) + // 32-bit: address has ConvL2I for cast of long to address, not supported. + public static void testByteLong3b(byte[] dest, long[] src) { + for (int i = 0; i < src.length - 1; i++) { + long value = src[i]; + if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) { + value = Long.reverseBytes(value); + } + UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + 1), value); + } + } -// @Run(test = {"testByteLong3a", "testByteLong3b"}) -// public static void testByteLong3_runner() { -// //runAndVerify(() -> testByteLong3a(byteArray, longArray), 8); -// //runAndVerify(() -> testByteLong3b(byteArray, longArray), 8); -// } + @Run(test = {"testByteLong3a", "testByteLong3b"}) + public static void testByteLong3_runner() { + runAndVerify(() -> testByteLong3a(byteArray, longArray), 8); + runAndVerify(() -> testByteLong3b(byteArray, longArray), 8); + } -// @Test -// @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" }, -// applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"}, -// applyIfPlatform = {"64-bit", "true"}, -// applyIf = {"AlignVector", "false"}) -// // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned). -// // might get fixed with JDK-8325155. -// // AlignVector cannot guarantee that invar is aligned. -// public static void testByteLong4a(byte[] dest, long[] src, int start, int stop) { -// for (int i = start; i < stop; i++) { -// UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, src[i]); -// } -// } + @Test + @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" }, + applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"}, + applyIfPlatform = {"64-bit", "true"}, + applyIf = {"AlignVector", "false"}) + // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned). + // might get fixed with JDK-8325155. + // AlignVector cannot guarantee that invar is aligned. + public static void testByteLong4a(byte[] dest, long[] src, int start, int stop) { + for (int i = start; i < stop; i++) { + long value = src[i]; + if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) { + value = Long.reverseBytes(value); + } + UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, value); + } + } -// @Test -// @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" }, -// applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"}, -// applyIfPlatform = {"64-bit", "true"}, -// applyIf = {"AlignVector", "false"}) -// // 32-bit: address has ConvL2I for cast of long to address, not supported. -// // AlignVector cannot guarantee that invar is aligned. -// public static void testByteLong4b(byte[] dest, long[] src, int start, int stop) { -// for (int i = start; i < stop; i++) { -// UNSAFE.putLongUnaligned(dest, 8L * i + baseOffset, src[i]); -// } -// } -// -// @Run(test = {"testByteLong4a", "testByteLong4b"}) -// public static void testByteLong4_runner() { -// baseOffset = UNSAFE.ARRAY_BYTE_BASE_OFFSET; -// //runAndVerify(() -> testByteLong4a(byteArray, longArray, 0, size), 0); -// //runAndVerify(() -> testByteLong4b(byteArray, longArray, 0, size), 0); -// } + @Test + @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" }, + applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"}, + applyIfPlatform = {"64-bit", "true"}, + applyIf = {"AlignVector", "false"}) + // 32-bit: address has ConvL2I for cast of long to address, not supported. + // AlignVector cannot guarantee that invar is aligned. + public static void testByteLong4b(byte[] dest, long[] src, int start, int stop) { + for (int i = start; i < stop; i++) { + long value = src[i]; + if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) { + value = Long.reverseBytes(value); + } + UNSAFE.putLongUnaligned(dest, 8L * i + baseOffset, value); + } + } -// @Test -// @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" }, -// applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"}, -// applyIfPlatform = {"64-bit", "true"}) -// // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned). -// // might get fixed with JDK-8325155. -// public static void testByteLong5a(byte[] dest, long[] src, int start, int stop) { -// for (int i = start; i < stop; i++) { -// UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), src[i]); -// } -// } -// -// @Test -// @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" }, -// applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"}, -// applyIfPlatform = {"64-bit", "true"}) -// // 32-bit: address has ConvL2I for cast of long to address, not supported. -// public static void testByteLong5b(byte[] dest, long[] src, int start, int stop) { -// for (int i = start; i < stop; i++) { -// UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + baseOffset), src[i]); -// } -// } -// -// @Run(test = {"testByteLong5a", "testByteLong5b"}) -// public static void testByteLong5_runner() { -// baseOffset = 1; -// //runAndVerify(() -> testByteLong5a(byteArray, longArray, 0, size-1), 8); -// //runAndVerify(() -> testByteLong5b(byteArray, longArray, 0, size-1), 8); -// } + @Run(test = {"testByteLong4a", "testByteLong4b"}) + public static void testByteLong4_runner() { + baseOffset = UNSAFE.ARRAY_BYTE_BASE_OFFSET; + runAndVerify(() -> testByteLong4a(byteArray, longArray, 0, size), 0); + runAndVerify(() -> testByteLong4b(byteArray, longArray, 0, size), 0); + } + + @Test + @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" }, + applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"}, + applyIfPlatform = {"64-bit", "true"}) + // 32-bit: offsets are badly aligned (UNSAFE.ARRAY_BYTE_BASE_OFFSET is 4 byte aligned, but not 8 byte aligned). + // might get fixed with JDK-8325155. + public static void testByteLong5a(byte[] dest, long[] src, int start, int stop) { + for (int i = start; i < stop; i++) { + long value = src[i]; + if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) { + value = Long.reverseBytes(value); + } + UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), value); + } + } + + @Test + @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" }, + applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"}, + applyIfPlatform = {"64-bit", "true"}) + // 32-bit: address has ConvL2I for cast of long to address, not supported. + public static void testByteLong5b(byte[] dest, long[] src, int start, int stop) { + for (int i = start; i < stop; i++) { + long value = src[i]; + if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) { + value = Long.reverseBytes(value); + } + UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + baseOffset), value); + } + } + + @Run(test = {"testByteLong5a", "testByteLong5b"}) + public static void testByteLong5_runner() { + baseOffset = 1; + runAndVerify(() -> testByteLong5a(byteArray, longArray, 0, size-1), 8); + runAndVerify(() -> testByteLong5b(byteArray, longArray, 0, size-1), 8); + } // // @Test // @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },