1 /*
 2  * Copyright (c) 2023, Red Hat, Inc. All rights reserved.
 3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  *
 5  * This code is free software; you can redistribute it and/or modify it
 6  * under the terms of the GNU General Public License version 2 only, as
 7  * published by the Free Software Foundation.
 8  *
 9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 package compiler.c2.irTests;
25 
26 import compiler.lib.ir_framework.*;
27 import jdk.test.lib.Utils;
28 import jdk.internal.misc.Unsafe;
29 import java.util.Objects;
30 import java.util.Random;
31 
32 /*
33  * @test
34  * @bug 8300256
35  * @requires (os.simpleArch == "x64") | (os.simpleArch == "aarch64")
36  * @modules java.base/jdk.internal.misc
37  * @library /test/lib /
38  * @run driver compiler.c2.irTests.TestVectorizationNotRun
39  */
40 
41 public class TestVectorizationNotRun {
42     private static final Unsafe UNSAFE = Unsafe.getUnsafe();
43 
44     public static void main(String[] args) {
45         TestFramework.runWithFlags("--add-modules", "java.base", "--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED");
46     }
47 
48     static int size = 1024;
49     static int sizeBytes = 8 * size;
50     static byte[] byteArray = new byte[sizeBytes];
51     static long[] longArray = new long[size];
52 
53     @Test
54     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
55         applyIf = {"UseCompactObjectHeaders", "false"})
56     public static void test(byte[] dest, long[] src) {
57         for (int i = 0; i < src.length; i++) {
58             if ((i < 0) || (8 > sizeBytes - i)) {
59                 throw new IndexOutOfBoundsException();
60             }
61             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + i * 8, src[i]);
62         }
63     }
64 
65     @Run(test = "test")
66     public static void test_runner() {
67         test(byteArray, longArray);
68     }
69 
70 }