< prev index next >

test/compiler/loopopts/superword/TestVectorizationWithInvariant.java

Print this page




  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 
  25 /**
  26  * @test
  27  * @bug 8078497
  28  * @summary Tests correct alignment of vectors with loop invariant offset.
  29  * @modules java.base/jdk.internal.misc
  30  * @library /test/lib
  31  * @run main compiler.loopopts.superword.TestVectorizationWithInvariant
  32  */
  33 
  34 package compiler.loopopts.superword;
  35 
  36 import jdk.internal.misc.Unsafe;
  37 import jdk.test.lib.unsafe.UnsafeHelper;
  38 
  39 public class TestVectorizationWithInvariant {
  40 
  41     private static Unsafe unsafe;
  42     private static final long BYTE_ARRAY_OFFSET;
  43     private static final long CHAR_ARRAY_OFFSET;
  44 
  45     static {
  46         unsafe = UnsafeHelper.getUnsafe();
  47         BYTE_ARRAY_OFFSET = unsafe.arrayBaseOffset(byte[].class);
  48         CHAR_ARRAY_OFFSET = unsafe.arrayBaseOffset(char[].class);
  49     }
  50 
  51     public static void main(String[] args) throws Exception {
  52         byte[] byte_array1 = new byte[1000];
  53         byte[] byte_array2 = new byte[1000];
  54         char[] char_array = new char[1000];
  55 
  56         for (int i = 0; i < 20_000; ++i) {
  57             copyByteToChar(byte_array1, byte_array2, char_array, 1);
  58             copyCharToByte(char_array, byte_array1, 1);
  59             copyCharToByteAligned(char_array, byte_array1);
  60             copyCharToByteUnaligned(char_array, byte_array1);
  61         }
  62     }
  63 
  64     /*
  65      * Copy multiple consecutive chars from a byte array to a given offset in a char array
  66      * to trigger C2's superword optimization. The offset in the byte array is independent




  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 
  25 /**
  26  * @test
  27  * @bug 8078497
  28  * @summary Tests correct alignment of vectors with loop invariant offset.
  29  * @modules java.base/jdk.internal.misc
  30  * @library /test/lib
  31  * @run main compiler.loopopts.superword.TestVectorizationWithInvariant
  32  */
  33 
  34 package compiler.loopopts.superword;
  35 
  36 import jdk.internal.misc.Unsafe;

  37 
  38 public class TestVectorizationWithInvariant {
  39 
  40     private static Unsafe unsafe;
  41     private static final long BYTE_ARRAY_OFFSET;
  42     private static final long CHAR_ARRAY_OFFSET;
  43 
  44     static {
  45         unsafe = Unsafe.getUnsafe();
  46         BYTE_ARRAY_OFFSET = unsafe.arrayBaseOffset(byte[].class);
  47         CHAR_ARRAY_OFFSET = unsafe.arrayBaseOffset(char[].class);
  48     }
  49 
  50     public static void main(String[] args) throws Exception {
  51         byte[] byte_array1 = new byte[1000];
  52         byte[] byte_array2 = new byte[1000];
  53         char[] char_array = new char[1000];
  54 
  55         for (int i = 0; i < 20_000; ++i) {
  56             copyByteToChar(byte_array1, byte_array2, char_array, 1);
  57             copyCharToByte(char_array, byte_array1, 1);
  58             copyCharToByteAligned(char_array, byte_array1);
  59             copyCharToByteUnaligned(char_array, byte_array1);
  60         }
  61     }
  62 
  63     /*
  64      * Copy multiple consecutive chars from a byte array to a given offset in a char array
  65      * to trigger C2's superword optimization. The offset in the byte array is independent


< prev index next >