3969N/A/*
3969N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
3969N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3969N/A *
3969N/A * This code is free software; you can redistribute it and/or modify it
3969N/A * under the terms of the GNU General Public License version 2 only, as
3969N/A * published by the Free Software Foundation.
3969N/A *
3969N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3969N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3969N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3969N/A * version 2 for more details (a copy is included in the LICENSE file that
3969N/A * accompanied this code).
3969N/A *
3969N/A * You should have received a copy of the GNU General Public License version
3969N/A * 2 along with this work; if not, write to the Free Software Foundation,
3969N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3969N/A *
3969N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3969N/A * or visit www.oracle.com if you need additional information or have any
3969N/A * questions.
3969N/A *
3969N/A */
3969N/A
3969N/A/**
3969N/A * @test
3969N/A * @bug 7192963
3969N/A * @summary assert(_in[req-1] == this) failed: Must pass arg count to 'new'
3969N/A *
3969N/A * @run main/othervm/timeout=400 -Xbatch -Xmx64m TestShortVect
3969N/A */
3969N/A
3969N/Apublic class TestShortVect {
3969N/A private static final int ARRLEN = 997;
3969N/A private static final int ITERS = 11000;
3969N/A public static void main(String args[]) {
3969N/A System.out.println("Testing Short vectors");
3969N/A int errn = test();
3969N/A if (errn > 0) {
3969N/A System.err.println("FAILED: " + errn + " errors");
3969N/A System.exit(97);
3969N/A }
3969N/A System.out.println("PASSED");
3969N/A }
3969N/A
3969N/A static int test() {
3969N/A short[] a0 = new short[ARRLEN];
3969N/A short[] a1 = new short[ARRLEN];
3969N/A // Initialize
3969N/A for (int i=0; i<ARRLEN; i++) {
3969N/A a1[i] = (short)i;
3969N/A }
3969N/A System.out.println("Warmup");
3969N/A for (int i=0; i<ITERS; i++) {
3969N/A test_init(a0);
3969N/A test_addi(a0, a1);
3969N/A test_lsai(a0, a1);
3969N/A test_unrl_init(a0);
3969N/A test_unrl_addi(a0, a1);
3969N/A test_unrl_lsai(a0, a1);
3969N/A }
3969N/A // Test and verify results
3969N/A System.out.println("Verification");
3969N/A int errn = 0;
3969N/A {
3969N/A test_init(a0);
3969N/A for (int i=0; i<ARRLEN; i++) {
3969N/A errn += verify("test_init: ", i, a0[i], (short)(i&3));
3969N/A }
3969N/A test_addi(a0, a1);
3969N/A for (int i=0; i<ARRLEN; i++) {
3969N/A errn += verify("test_addi: ", i, a0[i], (short)(i+(i&3)));
3969N/A }
3969N/A test_lsai(a0, a1);
3969N/A for (int i=0; i<ARRLEN; i++) {
3969N/A errn += verify("test_lsai: ", i, a0[i], (short)(i<<(i&3)));
3969N/A }
3969N/A test_unrl_init(a0);
3969N/A for (int i=0; i<ARRLEN; i++) {
3969N/A errn += verify("test_unrl_init: ", i, a0[i], (short)(i&3));
3969N/A }
3969N/A test_unrl_addi(a0, a1);
3969N/A for (int i=0; i<ARRLEN; i++) {
3969N/A errn += verify("test_unrl_addi: ", i, a0[i], (short)(i+(i&3)));
3969N/A }
3969N/A test_unrl_lsai(a0, a1);
3969N/A for (int i=0; i<ARRLEN; i++) {
3969N/A errn += verify("test_unrl_lsai: ", i, a0[i], (short)(i<<(i&3)));
3969N/A }
3969N/A }
3969N/A
3969N/A if (errn > 0)
3969N/A return errn;
3969N/A
3969N/A System.out.println("Time");
3969N/A long start, end;
3969N/A
3969N/A start = System.currentTimeMillis();
3969N/A for (int i=0; i<ITERS; i++) {
3969N/A test_init(a0);
3969N/A }
3969N/A end = System.currentTimeMillis();
3969N/A System.out.println("test_init: " + (end - start));
3969N/A
3969N/A start = System.currentTimeMillis();
3969N/A for (int i=0; i<ITERS; i++) {
3969N/A test_addi(a0, a1);
3969N/A }
3969N/A end = System.currentTimeMillis();
3969N/A System.out.println("test_addi: " + (end - start));
3969N/A
3969N/A start = System.currentTimeMillis();
3969N/A for (int i=0; i<ITERS; i++) {
3969N/A test_lsai(a0, a1);
3969N/A }
3969N/A end = System.currentTimeMillis();
3969N/A System.out.println("test_lsai: " + (end - start));
3969N/A
3969N/A start = System.currentTimeMillis();
3969N/A for (int i=0; i<ITERS; i++) {
3969N/A test_unrl_init(a0);
3969N/A }
3969N/A end = System.currentTimeMillis();
3969N/A System.out.println("test_unrl_init: " + (end - start));
3969N/A
3969N/A start = System.currentTimeMillis();
3969N/A for (int i=0; i<ITERS; i++) {
3969N/A test_unrl_addi(a0, a1);
3969N/A }
3969N/A end = System.currentTimeMillis();
3969N/A System.out.println("test_unrl_addi: " + (end - start));
3969N/A
3969N/A start = System.currentTimeMillis();
3969N/A for (int i=0; i<ITERS; i++) {
3969N/A test_unrl_lsai(a0, a1);
3969N/A }
3969N/A end = System.currentTimeMillis();
3969N/A System.out.println("test_unrl_lsai: " + (end - start));
3969N/A
3969N/A return errn;
3969N/A }
3969N/A
3969N/A static void test_init(short[] a0) {
3969N/A for (int i = 0; i < a0.length; i+=1) {
3969N/A a0[i] = (short)(i&3);
3969N/A }
3969N/A }
3969N/A static void test_addi(short[] a0, short[] a1) {
3969N/A for (int i = 0; i < a0.length; i+=1) {
3969N/A a0[i] = (short)(a1[i]+(i&3));
3969N/A }
3969N/A }
3969N/A static void test_lsai(short[] a0, short[] a1) {
3969N/A for (int i = 0; i < a0.length; i+=1) {
3969N/A a0[i] = (short)(a1[i]<<(i&3));
3969N/A }
3969N/A }
3969N/A static void test_unrl_init(short[] a0) {
3969N/A int i = 0;
3969N/A for (; i < a0.length-4; i+=4) {
3969N/A a0[i+0] = 0;
3969N/A a0[i+1] = 1;
3969N/A a0[i+2] = 2;
3969N/A a0[i+3] = 3;
3969N/A }
3969N/A for (; i < a0.length; i++) {
3969N/A a0[i] = (short)(i&3);
3969N/A }
3969N/A }
3969N/A static void test_unrl_addi(short[] a0, short[] a1) {
3969N/A int i = 0;
3969N/A for (; i < a0.length-4; i+=4) {
3969N/A a0[i+0] = (short)(a1[i+0]+0);
3969N/A a0[i+1] = (short)(a1[i+1]+1);
3969N/A a0[i+2] = (short)(a1[i+2]+2);
3969N/A a0[i+3] = (short)(a1[i+3]+3);
3969N/A }
3969N/A for (; i < a0.length; i++) {
3969N/A a0[i] = (short)(a1[i]+(i&3));
3969N/A }
3969N/A }
3969N/A static void test_unrl_lsai(short[] a0, short[] a1) {
3969N/A int i = 0;
3969N/A for (; i < a0.length-4; i+=4) {
3969N/A a0[i+0] = (short)(a1[i+0]<<0);
3969N/A a0[i+1] = (short)(a1[i+1]<<1);
3969N/A a0[i+2] = (short)(a1[i+2]<<2);
3969N/A a0[i+3] = (short)(a1[i+3]<<3);
3969N/A }
3969N/A for (; i < a0.length; i++) {
3969N/A a0[i] = (short)(a1[i]<<(i&3));
3969N/A }
3969N/A }
3969N/A
3969N/A static int verify(String text, int i, short elem, short val) {
3969N/A if (elem != val) {
3969N/A System.err.println(text + "[" + i + "] = " + elem + " != " + val);
3969N/A return 1;
3969N/A }
3969N/A return 0;
3969N/A }
3969N/A}
3969N/A