Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/compiler/6340864/TestByteVect.java
32285 views
/*1* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324/**25* @test26* @bug 634086427* @summary Implement vectorization optimizations in hotspot-server28*29* @run main/othervm/timeout=400 -Xbatch -Xmx64m TestByteVect30*/3132public class TestByteVect {33private static final int ARRLEN = 997;34private static final int ITERS = 11000;35private static final int ADD_INIT = 63;36private static final int BIT_MASK = 0xB7;37private static final int VALUE = 3;38private static final int SHIFT = 8;3940public static void main(String args[]) {41System.out.println("Testing Byte vectors");42int errn = test();43if (errn > 0) {44System.err.println("FAILED: " + errn + " errors");45System.exit(97);46}47System.out.println("PASSED");48}4950static int test() {51byte[] a0 = new byte[ARRLEN];52byte[] a1 = new byte[ARRLEN];53byte[] a2 = new byte[ARRLEN];54byte[] a3 = new byte[ARRLEN];55byte[] a4 = new byte[ARRLEN];56short[] p2 = new short[ARRLEN/2];57int[] p4 = new int[ARRLEN/4];58long[] p8 = new long[ARRLEN/8];59// Initialize60int gold_sum = 0;61for (int i=0; i<ARRLEN; i++) {62byte val = (byte)(ADD_INIT+i);63gold_sum += val;64a1[i] = val;65a2[i] = (byte)VALUE;66a3[i] = (byte)-VALUE;67a4[i] = (byte)BIT_MASK;68}69System.out.println("Warmup");70for (int i=0; i<ITERS; i++) {71test_sum(a1);72test_addc(a0, a1);73test_addv(a0, a1, (byte)VALUE);74test_adda(a0, a1, a2);75test_subc(a0, a1);76test_subv(a0, a1, (byte)VALUE);77test_suba(a0, a1, a2);7879test_mulc(a0, a1);80test_mulv(a0, a1, (byte)VALUE);81test_mula(a0, a1, a2);82test_divc(a0, a1);83test_divv(a0, a1, (byte)VALUE);84test_diva(a0, a1, a2);85test_mulc_n(a0, a1);86test_mulv(a0, a1, (byte)-VALUE);87test_mula(a0, a1, a3);88test_divc_n(a0, a1);89test_divv(a0, a1, (byte)-VALUE);90test_diva(a0, a1, a3);9192test_andc(a0, a1);93test_andv(a0, a1, (byte)BIT_MASK);94test_anda(a0, a1, a4);95test_orc(a0, a1);96test_orv(a0, a1, (byte)BIT_MASK);97test_ora(a0, a1, a4);98test_xorc(a0, a1);99test_xorv(a0, a1, (byte)BIT_MASK);100test_xora(a0, a1, a4);101102test_sllc(a0, a1);103test_sllv(a0, a1, VALUE);104test_srlc(a0, a1);105test_srlv(a0, a1, VALUE);106test_srac(a0, a1);107test_srav(a0, a1, VALUE);108109test_sllc_n(a0, a1);110test_sllv(a0, a1, -VALUE);111test_srlc_n(a0, a1);112test_srlv(a0, a1, -VALUE);113test_srac_n(a0, a1);114test_srav(a0, a1, -VALUE);115116test_sllc_o(a0, a1);117test_sllv(a0, a1, SHIFT);118test_srlc_o(a0, a1);119test_srlv(a0, a1, SHIFT);120test_srac_o(a0, a1);121test_srav(a0, a1, SHIFT);122123test_sllc_on(a0, a1);124test_sllv(a0, a1, -SHIFT);125test_srlc_on(a0, a1);126test_srlv(a0, a1, -SHIFT);127test_srac_on(a0, a1);128test_srav(a0, a1, -SHIFT);129130test_sllc_add(a0, a1);131test_sllv_add(a0, a1, ADD_INIT);132test_srlc_add(a0, a1);133test_srlv_add(a0, a1, ADD_INIT);134test_srac_add(a0, a1);135test_srav_add(a0, a1, ADD_INIT);136137test_sllc_and(a0, a1);138test_sllv_and(a0, a1, BIT_MASK);139test_srlc_and(a0, a1);140test_srlv_and(a0, a1, BIT_MASK);141test_srac_and(a0, a1);142test_srav_and(a0, a1, BIT_MASK);143144test_pack2(p2, a1);145test_unpack2(a0, p2);146test_pack2_swap(p2, a1);147test_unpack2_swap(a0, p2);148test_pack4(p4, a1);149test_unpack4(a0, p4);150test_pack4_swap(p4, a1);151test_unpack4_swap(a0, p4);152test_pack8(p8, a1);153test_unpack8(a0, p8);154test_pack8_swap(p8, a1);155test_unpack8_swap(a0, p8);156}157// Test and verify results158System.out.println("Verification");159int errn = 0;160{161int sum = test_sum(a1);162if (sum != gold_sum) {163System.err.println("test_sum: " + sum + " != " + gold_sum);164errn++;165}166167test_addc(a0, a1);168for (int i=0; i<ARRLEN; i++) {169errn += verify("test_addc: ", i, a0[i], (byte)((byte)(ADD_INIT+i)+VALUE));170}171test_addv(a0, a1, (byte)VALUE);172for (int i=0; i<ARRLEN; i++) {173errn += verify("test_addv: ", i, a0[i], (byte)((byte)(ADD_INIT+i)+VALUE));174}175test_adda(a0, a1, a2);176for (int i=0; i<ARRLEN; i++) {177errn += verify("test_adda: ", i, a0[i], (byte)((byte)(ADD_INIT+i)+VALUE));178}179180test_subc(a0, a1);181for (int i=0; i<ARRLEN; i++) {182errn += verify("test_subc: ", i, a0[i], (byte)((byte)(ADD_INIT+i)-VALUE));183}184test_subv(a0, a1, (byte)VALUE);185for (int i=0; i<ARRLEN; i++) {186errn += verify("test_subv: ", i, a0[i], (byte)((byte)(ADD_INIT+i)-VALUE));187}188test_suba(a0, a1, a2);189for (int i=0; i<ARRLEN; i++) {190errn += verify("test_suba: ", i, a0[i], (byte)((byte)(ADD_INIT+i)-VALUE));191}192193test_mulc(a0, a1);194for (int i=0; i<ARRLEN; i++) {195errn += verify("test_mulc: ", i, a0[i], (byte)((byte)(ADD_INIT+i)*VALUE));196}197test_mulv(a0, a1, (byte)VALUE);198for (int i=0; i<ARRLEN; i++) {199errn += verify("test_mulv: ", i, a0[i], (byte)((byte)(ADD_INIT+i)*VALUE));200}201test_mula(a0, a1, a2);202for (int i=0; i<ARRLEN; i++) {203errn += verify("test_mula: ", i, a0[i], (byte)((byte)(ADD_INIT+i)*VALUE));204}205206test_divc(a0, a1);207for (int i=0; i<ARRLEN; i++) {208errn += verify("test_divc: ", i, a0[i], (byte)((byte)(ADD_INIT+i)/VALUE));209}210test_divv(a0, a1, (byte)VALUE);211for (int i=0; i<ARRLEN; i++) {212errn += verify("test_divv: ", i, a0[i], (byte)((byte)(ADD_INIT+i)/VALUE));213}214test_diva(a0, a1, a2);215for (int i=0; i<ARRLEN; i++) {216errn += verify("test_diva: ", i, a0[i], (byte)((byte)(ADD_INIT+i)/VALUE));217}218219test_mulc_n(a0, a1);220for (int i=0; i<ARRLEN; i++) {221errn += verify("test_mulc_n: ", i, a0[i], (byte)((byte)(ADD_INIT+i)*(-VALUE)));222}223test_mulv(a0, a1, (byte)-VALUE);224for (int i=0; i<ARRLEN; i++) {225errn += verify("test_mulv_n: ", i, a0[i], (byte)((byte)(ADD_INIT+i)*(-VALUE)));226}227test_mula(a0, a1, a3);228for (int i=0; i<ARRLEN; i++) {229errn += verify("test_mula_n: ", i, a0[i], (byte)((byte)(ADD_INIT+i)*(-VALUE)));230}231232test_divc_n(a0, a1);233for (int i=0; i<ARRLEN; i++) {234errn += verify("test_divc_n: ", i, a0[i], (byte)((byte)(ADD_INIT+i)/(-VALUE)));235}236test_divv(a0, a1, (byte)-VALUE);237for (int i=0; i<ARRLEN; i++) {238errn += verify("test_divv_n: ", i, a0[i], (byte)((byte)(ADD_INIT+i)/(-VALUE)));239}240test_diva(a0, a1, a3);241for (int i=0; i<ARRLEN; i++) {242errn += verify("test_diva_n: ", i, a0[i], (byte)((byte)(ADD_INIT+i)/(-VALUE)));243}244245test_andc(a0, a1);246for (int i=0; i<ARRLEN; i++) {247errn += verify("test_andc: ", i, a0[i], (byte)((byte)(ADD_INIT+i)&BIT_MASK));248}249test_andv(a0, a1, (byte)BIT_MASK);250for (int i=0; i<ARRLEN; i++) {251errn += verify("test_andv: ", i, a0[i], (byte)((byte)(ADD_INIT+i)&BIT_MASK));252}253test_anda(a0, a1, a4);254for (int i=0; i<ARRLEN; i++) {255errn += verify("test_anda: ", i, a0[i], (byte)((byte)(ADD_INIT+i)&BIT_MASK));256}257258test_orc(a0, a1);259for (int i=0; i<ARRLEN; i++) {260errn += verify("test_orc: ", i, a0[i], (byte)((byte)(ADD_INIT+i)|BIT_MASK));261}262test_orv(a0, a1, (byte)BIT_MASK);263for (int i=0; i<ARRLEN; i++) {264errn += verify("test_orv: ", i, a0[i], (byte)((byte)(ADD_INIT+i)|BIT_MASK));265}266test_ora(a0, a1, a4);267for (int i=0; i<ARRLEN; i++) {268errn += verify("test_ora: ", i, a0[i], (byte)((byte)(ADD_INIT+i)|BIT_MASK));269}270271test_xorc(a0, a1);272for (int i=0; i<ARRLEN; i++) {273errn += verify("test_xorc: ", i, a0[i], (byte)((byte)(ADD_INIT+i)^BIT_MASK));274}275test_xorv(a0, a1, (byte)BIT_MASK);276for (int i=0; i<ARRLEN; i++) {277errn += verify("test_xorv: ", i, a0[i], (byte)((byte)(ADD_INIT+i)^BIT_MASK));278}279test_xora(a0, a1, a4);280for (int i=0; i<ARRLEN; i++) {281errn += verify("test_xora: ", i, a0[i], (byte)((byte)(ADD_INIT+i)^BIT_MASK));282}283284test_sllc(a0, a1);285for (int i=0; i<ARRLEN; i++) {286errn += verify("test_sllc: ", i, a0[i], (byte)((byte)(ADD_INIT+i)<<VALUE));287}288test_sllv(a0, a1, VALUE);289for (int i=0; i<ARRLEN; i++) {290errn += verify("test_sllv: ", i, a0[i], (byte)((byte)(ADD_INIT+i)<<VALUE));291}292293test_srlc(a0, a1);294for (int i=0; i<ARRLEN; i++) {295errn += verify("test_srlc: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>>VALUE));296}297test_srlv(a0, a1, VALUE);298for (int i=0; i<ARRLEN; i++) {299errn += verify("test_srlv: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>>VALUE));300}301302test_srac(a0, a1);303for (int i=0; i<ARRLEN; i++) {304errn += verify("test_srac: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>VALUE));305}306test_srav(a0, a1, VALUE);307for (int i=0; i<ARRLEN; i++) {308errn += verify("test_srav: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>VALUE));309}310311test_sllc_n(a0, a1);312for (int i=0; i<ARRLEN; i++) {313errn += verify("test_sllc_n: ", i, a0[i], (byte)((byte)(ADD_INIT+i)<<(-VALUE)));314}315test_sllv(a0, a1, -VALUE);316for (int i=0; i<ARRLEN; i++) {317errn += verify("test_sllv_n: ", i, a0[i], (byte)((byte)(ADD_INIT+i)<<(-VALUE)));318}319320test_srlc_n(a0, a1);321for (int i=0; i<ARRLEN; i++) {322errn += verify("test_srlc_n: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>>(-VALUE)));323}324test_srlv(a0, a1, -VALUE);325for (int i=0; i<ARRLEN; i++) {326errn += verify("test_srlv_n: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>>(-VALUE)));327}328329test_srac_n(a0, a1);330for (int i=0; i<ARRLEN; i++) {331errn += verify("test_srac_n: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>(-VALUE)));332}333test_srav(a0, a1, -VALUE);334for (int i=0; i<ARRLEN; i++) {335errn += verify("test_srav_n: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>(-VALUE)));336}337338test_sllc_o(a0, a1);339for (int i=0; i<ARRLEN; i++) {340errn += verify("test_sllc_o: ", i, a0[i], (byte)((byte)(ADD_INIT+i)<<SHIFT));341}342test_sllv(a0, a1, SHIFT);343for (int i=0; i<ARRLEN; i++) {344errn += verify("test_sllv_o: ", i, a0[i], (byte)((byte)(ADD_INIT+i)<<SHIFT));345}346347test_srlc_o(a0, a1);348for (int i=0; i<ARRLEN; i++) {349errn += verify("test_srlc_o: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>>SHIFT));350}351test_srlv(a0, a1, SHIFT);352for (int i=0; i<ARRLEN; i++) {353errn += verify("test_srlv_o: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>>SHIFT));354}355356test_srac_o(a0, a1);357for (int i=0; i<ARRLEN; i++) {358errn += verify("test_srac_o: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>SHIFT));359}360test_srav(a0, a1, SHIFT);361for (int i=0; i<ARRLEN; i++) {362errn += verify("test_srav_o: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>SHIFT));363}364365test_sllc_on(a0, a1);366for (int i=0; i<ARRLEN; i++) {367errn += verify("test_sllc_on: ", i, a0[i], (byte)((byte)(ADD_INIT+i)<<(-SHIFT)));368}369test_sllv(a0, a1, -SHIFT);370for (int i=0; i<ARRLEN; i++) {371errn += verify("test_sllv_on: ", i, a0[i], (byte)((byte)(ADD_INIT+i)<<(-SHIFT)));372}373374test_srlc_on(a0, a1);375for (int i=0; i<ARRLEN; i++) {376errn += verify("test_srlc_on: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>>(-SHIFT)));377}378test_srlv(a0, a1, -SHIFT);379for (int i=0; i<ARRLEN; i++) {380errn += verify("test_srlv_on: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>>(-SHIFT)));381}382383test_srac_on(a0, a1);384for (int i=0; i<ARRLEN; i++) {385errn += verify("test_srac_on: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>(-SHIFT)));386}387test_srav(a0, a1, -SHIFT);388for (int i=0; i<ARRLEN; i++) {389errn += verify("test_srav_on: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>(-SHIFT)));390}391392test_sllc_add(a0, a1);393for (int i=0; i<ARRLEN; i++) {394errn += verify("test_sllc_add: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) + ADD_INIT)<<VALUE));395}396test_sllv_add(a0, a1, ADD_INIT);397for (int i=0; i<ARRLEN; i++) {398errn += verify("test_sllv_add: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) + ADD_INIT)<<VALUE));399}400401test_srlc_add(a0, a1);402for (int i=0; i<ARRLEN; i++) {403errn += verify("test_srlc_add: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) + ADD_INIT)>>>VALUE));404}405test_srlv_add(a0, a1, ADD_INIT);406for (int i=0; i<ARRLEN; i++) {407errn += verify("test_srlv_add: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) + ADD_INIT)>>>VALUE));408}409410test_srac_add(a0, a1);411for (int i=0; i<ARRLEN; i++) {412errn += verify("test_srac_add: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) + ADD_INIT)>>VALUE));413}414test_srav_add(a0, a1, ADD_INIT);415for (int i=0; i<ARRLEN; i++) {416errn += verify("test_srav_add: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) + ADD_INIT)>>VALUE));417}418419test_sllc_and(a0, a1);420for (int i=0; i<ARRLEN; i++) {421errn += verify("test_sllc_and: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) & BIT_MASK)<<VALUE));422}423test_sllv_and(a0, a1, BIT_MASK);424for (int i=0; i<ARRLEN; i++) {425errn += verify("test_sllv_and: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) & BIT_MASK)<<VALUE));426}427428test_srlc_and(a0, a1);429for (int i=0; i<ARRLEN; i++) {430errn += verify("test_srlc_and: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) & BIT_MASK)>>>VALUE));431}432test_srlv_and(a0, a1, BIT_MASK);433for (int i=0; i<ARRLEN; i++) {434errn += verify("test_srlv_and: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) & BIT_MASK)>>>VALUE));435}436437test_srac_and(a0, a1);438for (int i=0; i<ARRLEN; i++) {439errn += verify("test_srac_and: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) & BIT_MASK)>>VALUE));440}441test_srav_and(a0, a1, BIT_MASK);442for (int i=0; i<ARRLEN; i++) {443errn += verify("test_srav_and: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) & BIT_MASK)>>VALUE));444}445446test_pack2(p2, a1);447for (int i=0; i<ARRLEN/2; i++) {448errn += verify("test_pack2: ", i, p2[i], (short)(((short)(ADD_INIT+2*i) & 0xFF) | ((short)(ADD_INIT+2*i+1) << 8)));449}450for (int i=0; i<ARRLEN; i++) {451a0[i] = -1;452}453test_unpack2(a0, p2);454for (int i=0; i<(ARRLEN&(-2)); i++) {455errn += verify("test_unpack2: ", i, a0[i], (byte)(ADD_INIT+i));456}457458test_pack2_swap(p2, a1);459for (int i=0; i<ARRLEN/2; i++) {460errn += verify("test_pack2_swap: ", i, p2[i], (short)(((short)(ADD_INIT+2*i+1) & 0xFF) | ((short)(ADD_INIT+2*i) << 8)));461}462for (int i=0; i<ARRLEN; i++) {463a0[i] = -1;464}465test_unpack2_swap(a0, p2);466for (int i=0; i<(ARRLEN&(-2)); i++) {467errn += verify("test_unpack2_swap: ", i, a0[i], (byte)(ADD_INIT+i));468}469470test_pack4(p4, a1);471for (int i=0; i<ARRLEN/4; i++) {472errn += verify("test_pack4: ", i, p4[i], ((int)(ADD_INIT+4*i+0) & 0xFF) |473(((int)(ADD_INIT+4*i+1) & 0xFF) << 8) |474(((int)(ADD_INIT+4*i+2) & 0xFF) << 16) |475(((int)(ADD_INIT+4*i+3) & 0xFF) << 24));476}477for (int i=0; i<ARRLEN; i++) {478a0[i] = -1;479}480test_unpack4(a0, p4);481for (int i=0; i<(ARRLEN&(-4)); i++) {482errn += verify("test_unpack4: ", i, a0[i], (byte)(ADD_INIT+i));483}484485test_pack4_swap(p4, a1);486for (int i=0; i<ARRLEN/4; i++) {487errn += verify("test_pack4_swap: ", i, p4[i], ((int)(ADD_INIT+4*i+3) & 0xFF) |488(((int)(ADD_INIT+4*i+2) & 0xFF) << 8) |489(((int)(ADD_INIT+4*i+1) & 0xFF) << 16) |490(((int)(ADD_INIT+4*i+0) & 0xFF) << 24));491}492for (int i=0; i<ARRLEN; i++) {493a0[i] = -1;494}495test_unpack4_swap(a0, p4);496for (int i=0; i<(ARRLEN&(-4)); i++) {497errn += verify("test_unpack4_swap: ", i, a0[i], (byte)(ADD_INIT+i));498}499500test_pack8(p8, a1);501for (int i=0; i<ARRLEN/8; i++) {502errn += verify("test_pack8: ", i, p8[i], ((long)(ADD_INIT+8*i+0) & 0xFFl) |503(((long)(ADD_INIT+8*i+1) & 0xFFl) << 8) |504(((long)(ADD_INIT+8*i+2) & 0xFFl) << 16) |505(((long)(ADD_INIT+8*i+3) & 0xFFl) << 24) |506(((long)(ADD_INIT+8*i+4) & 0xFFl) << 32) |507(((long)(ADD_INIT+8*i+5) & 0xFFl) << 40) |508(((long)(ADD_INIT+8*i+6) & 0xFFl) << 48) |509(((long)(ADD_INIT+8*i+7) & 0xFFl) << 56));510}511for (int i=0; i<ARRLEN; i++) {512a0[i] = -1;513}514test_unpack8(a0, p8);515for (int i=0; i<(ARRLEN&(-8)); i++) {516errn += verify("test_unpack8: ", i, a0[i], (byte)(ADD_INIT+i));517}518519test_pack8_swap(p8, a1);520for (int i=0; i<ARRLEN/8; i++) {521errn += verify("test_pack8_swap: ", i, p8[i], ((long)(ADD_INIT+8*i+7) & 0xFFl) |522(((long)(ADD_INIT+8*i+6) & 0xFFl) << 8) |523(((long)(ADD_INIT+8*i+5) & 0xFFl) << 16) |524(((long)(ADD_INIT+8*i+4) & 0xFFl) << 24) |525(((long)(ADD_INIT+8*i+3) & 0xFFl) << 32) |526(((long)(ADD_INIT+8*i+2) & 0xFFl) << 40) |527(((long)(ADD_INIT+8*i+1) & 0xFFl) << 48) |528(((long)(ADD_INIT+8*i+0) & 0xFFl) << 56));529}530for (int i=0; i<ARRLEN; i++) {531a0[i] = -1;532}533test_unpack8_swap(a0, p8);534for (int i=0; i<(ARRLEN&(-8)); i++) {535errn += verify("test_unpack8_swap: ", i, a0[i], (byte)(ADD_INIT+i));536}537538}539540if (errn > 0)541return errn;542543System.out.println("Time");544long start, end;545546start = System.currentTimeMillis();547for (int i=0; i<ITERS; i++) {548test_sum(a1);549}550end = System.currentTimeMillis();551System.out.println("test_sum: " + (end - start));552553start = System.currentTimeMillis();554for (int i=0; i<ITERS; i++) {555test_addc(a0, a1);556}557end = System.currentTimeMillis();558System.out.println("test_addc: " + (end - start));559start = System.currentTimeMillis();560for (int i=0; i<ITERS; i++) {561test_addv(a0, a1, (byte)VALUE);562}563end = System.currentTimeMillis();564System.out.println("test_addv: " + (end - start));565start = System.currentTimeMillis();566for (int i=0; i<ITERS; i++) {567test_adda(a0, a1, a2);568}569end = System.currentTimeMillis();570System.out.println("test_adda: " + (end - start));571572start = System.currentTimeMillis();573for (int i=0; i<ITERS; i++) {574test_subc(a0, a1);575}576end = System.currentTimeMillis();577System.out.println("test_subc: " + (end - start));578start = System.currentTimeMillis();579for (int i=0; i<ITERS; i++) {580test_subv(a0, a1, (byte)VALUE);581}582end = System.currentTimeMillis();583System.out.println("test_subv: " + (end - start));584start = System.currentTimeMillis();585for (int i=0; i<ITERS; i++) {586test_suba(a0, a1, a2);587}588end = System.currentTimeMillis();589System.out.println("test_suba: " + (end - start));590591start = System.currentTimeMillis();592for (int i=0; i<ITERS; i++) {593test_mulc(a0, a1);594}595end = System.currentTimeMillis();596System.out.println("test_mulc: " + (end - start));597start = System.currentTimeMillis();598for (int i=0; i<ITERS; i++) {599test_mulv(a0, a1, (byte)VALUE);600}601end = System.currentTimeMillis();602System.out.println("test_mulv: " + (end - start));603start = System.currentTimeMillis();604for (int i=0; i<ITERS; i++) {605test_mula(a0, a1, a2);606}607end = System.currentTimeMillis();608System.out.println("test_mula: " + (end - start));609610start = System.currentTimeMillis();611for (int i=0; i<ITERS; i++) {612test_divc(a0, a1);613}614end = System.currentTimeMillis();615System.out.println("test_divc: " + (end - start));616start = System.currentTimeMillis();617for (int i=0; i<ITERS; i++) {618test_divv(a0, a1, (byte)VALUE);619}620end = System.currentTimeMillis();621System.out.println("test_divv: " + (end - start));622start = System.currentTimeMillis();623for (int i=0; i<ITERS; i++) {624test_diva(a0, a1, a2);625}626end = System.currentTimeMillis();627System.out.println("test_diva: " + (end - start));628629start = System.currentTimeMillis();630for (int i=0; i<ITERS; i++) {631test_mulc_n(a0, a1);632}633end = System.currentTimeMillis();634System.out.println("test_mulc_n: " + (end - start));635start = System.currentTimeMillis();636for (int i=0; i<ITERS; i++) {637test_mulv(a0, a1, (byte)-VALUE);638}639end = System.currentTimeMillis();640System.out.println("test_mulv_n: " + (end - start));641start = System.currentTimeMillis();642for (int i=0; i<ITERS; i++) {643test_mula(a0, a1, a3);644}645end = System.currentTimeMillis();646System.out.println("test_mula_n: " + (end - start));647648start = System.currentTimeMillis();649for (int i=0; i<ITERS; i++) {650test_divc_n(a0, a1);651}652end = System.currentTimeMillis();653System.out.println("test_divc_n: " + (end - start));654start = System.currentTimeMillis();655for (int i=0; i<ITERS; i++) {656test_divv(a0, a1, (byte)-VALUE);657}658end = System.currentTimeMillis();659System.out.println("test_divv_n: " + (end - start));660start = System.currentTimeMillis();661for (int i=0; i<ITERS; i++) {662test_diva(a0, a1, a3);663}664end = System.currentTimeMillis();665System.out.println("test_diva_n: " + (end - start));666667start = System.currentTimeMillis();668for (int i=0; i<ITERS; i++) {669test_andc(a0, a1);670}671end = System.currentTimeMillis();672System.out.println("test_andc: " + (end - start));673start = System.currentTimeMillis();674for (int i=0; i<ITERS; i++) {675test_andv(a0, a1, (byte)BIT_MASK);676}677end = System.currentTimeMillis();678System.out.println("test_andv: " + (end - start));679start = System.currentTimeMillis();680for (int i=0; i<ITERS; i++) {681test_anda(a0, a1, a4);682}683end = System.currentTimeMillis();684System.out.println("test_anda: " + (end - start));685686start = System.currentTimeMillis();687for (int i=0; i<ITERS; i++) {688test_orc(a0, a1);689}690end = System.currentTimeMillis();691System.out.println("test_orc: " + (end - start));692start = System.currentTimeMillis();693for (int i=0; i<ITERS; i++) {694test_orv(a0, a1, (byte)BIT_MASK);695}696end = System.currentTimeMillis();697System.out.println("test_orv: " + (end - start));698start = System.currentTimeMillis();699for (int i=0; i<ITERS; i++) {700test_ora(a0, a1, a4);701}702end = System.currentTimeMillis();703System.out.println("test_ora: " + (end - start));704705start = System.currentTimeMillis();706for (int i=0; i<ITERS; i++) {707test_xorc(a0, a1);708}709end = System.currentTimeMillis();710System.out.println("test_xorc: " + (end - start));711start = System.currentTimeMillis();712for (int i=0; i<ITERS; i++) {713test_xorv(a0, a1, (byte)BIT_MASK);714}715end = System.currentTimeMillis();716System.out.println("test_xorv: " + (end - start));717start = System.currentTimeMillis();718for (int i=0; i<ITERS; i++) {719test_xora(a0, a1, a4);720}721end = System.currentTimeMillis();722System.out.println("test_xora: " + (end - start));723724start = System.currentTimeMillis();725for (int i=0; i<ITERS; i++) {726test_sllc(a0, a1);727}728end = System.currentTimeMillis();729System.out.println("test_sllc: " + (end - start));730start = System.currentTimeMillis();731for (int i=0; i<ITERS; i++) {732test_sllv(a0, a1, VALUE);733}734end = System.currentTimeMillis();735System.out.println("test_sllv: " + (end - start));736737start = System.currentTimeMillis();738for (int i=0; i<ITERS; i++) {739test_srlc(a0, a1);740}741end = System.currentTimeMillis();742System.out.println("test_srlc: " + (end - start));743start = System.currentTimeMillis();744for (int i=0; i<ITERS; i++) {745test_srlv(a0, a1, VALUE);746}747end = System.currentTimeMillis();748System.out.println("test_srlv: " + (end - start));749750start = System.currentTimeMillis();751for (int i=0; i<ITERS; i++) {752test_srac(a0, a1);753}754end = System.currentTimeMillis();755System.out.println("test_srac: " + (end - start));756start = System.currentTimeMillis();757for (int i=0; i<ITERS; i++) {758test_srav(a0, a1, VALUE);759}760end = System.currentTimeMillis();761System.out.println("test_srav: " + (end - start));762763start = System.currentTimeMillis();764for (int i=0; i<ITERS; i++) {765test_sllc_n(a0, a1);766}767end = System.currentTimeMillis();768System.out.println("test_sllc_n: " + (end - start));769start = System.currentTimeMillis();770for (int i=0; i<ITERS; i++) {771test_sllv(a0, a1, -VALUE);772}773end = System.currentTimeMillis();774System.out.println("test_sllv_n: " + (end - start));775776start = System.currentTimeMillis();777for (int i=0; i<ITERS; i++) {778test_srlc_n(a0, a1);779}780end = System.currentTimeMillis();781System.out.println("test_srlc_n: " + (end - start));782start = System.currentTimeMillis();783for (int i=0; i<ITERS; i++) {784test_srlv(a0, a1, -VALUE);785}786end = System.currentTimeMillis();787System.out.println("test_srlv_n: " + (end - start));788789start = System.currentTimeMillis();790for (int i=0; i<ITERS; i++) {791test_srac_n(a0, a1);792}793end = System.currentTimeMillis();794System.out.println("test_srac_n: " + (end - start));795start = System.currentTimeMillis();796for (int i=0; i<ITERS; i++) {797test_srav(a0, a1, -VALUE);798}799end = System.currentTimeMillis();800System.out.println("test_srav_n: " + (end - start));801802start = System.currentTimeMillis();803for (int i=0; i<ITERS; i++) {804test_sllc_o(a0, a1);805}806end = System.currentTimeMillis();807System.out.println("test_sllc_o: " + (end - start));808start = System.currentTimeMillis();809for (int i=0; i<ITERS; i++) {810test_sllv(a0, a1, SHIFT);811}812end = System.currentTimeMillis();813System.out.println("test_sllv_o: " + (end - start));814815start = System.currentTimeMillis();816for (int i=0; i<ITERS; i++) {817test_srlc_o(a0, a1);818}819end = System.currentTimeMillis();820System.out.println("test_srlc_o: " + (end - start));821start = System.currentTimeMillis();822for (int i=0; i<ITERS; i++) {823test_srlv(a0, a1, SHIFT);824}825end = System.currentTimeMillis();826System.out.println("test_srlv_o: " + (end - start));827828start = System.currentTimeMillis();829for (int i=0; i<ITERS; i++) {830test_srac_o(a0, a1);831}832end = System.currentTimeMillis();833System.out.println("test_srac_o: " + (end - start));834start = System.currentTimeMillis();835for (int i=0; i<ITERS; i++) {836test_srav(a0, a1, SHIFT);837}838end = System.currentTimeMillis();839System.out.println("test_srav_o: " + (end - start));840841start = System.currentTimeMillis();842for (int i=0; i<ITERS; i++) {843test_sllc_on(a0, a1);844}845end = System.currentTimeMillis();846System.out.println("test_sllc_on: " + (end - start));847start = System.currentTimeMillis();848for (int i=0; i<ITERS; i++) {849test_sllv(a0, a1, -SHIFT);850}851end = System.currentTimeMillis();852System.out.println("test_sllv_on: " + (end - start));853854start = System.currentTimeMillis();855for (int i=0; i<ITERS; i++) {856test_srlc_on(a0, a1);857}858end = System.currentTimeMillis();859System.out.println("test_srlc_on: " + (end - start));860start = System.currentTimeMillis();861for (int i=0; i<ITERS; i++) {862test_srlv(a0, a1, -SHIFT);863}864end = System.currentTimeMillis();865System.out.println("test_srlv_on: " + (end - start));866867start = System.currentTimeMillis();868for (int i=0; i<ITERS; i++) {869test_srac_on(a0, a1);870}871end = System.currentTimeMillis();872System.out.println("test_srac_on: " + (end - start));873start = System.currentTimeMillis();874for (int i=0; i<ITERS; i++) {875test_srav(a0, a1, -SHIFT);876}877end = System.currentTimeMillis();878System.out.println("test_srav_on: " + (end - start));879880start = System.currentTimeMillis();881for (int i=0; i<ITERS; i++) {882test_sllc_add(a0, a1);883}884end = System.currentTimeMillis();885System.out.println("test_sllc_add: " + (end - start));886start = System.currentTimeMillis();887for (int i=0; i<ITERS; i++) {888test_sllv_add(a0, a1, ADD_INIT);889}890end = System.currentTimeMillis();891System.out.println("test_sllv_add: " + (end - start));892893start = System.currentTimeMillis();894for (int i=0; i<ITERS; i++) {895test_srlc_add(a0, a1);896}897end = System.currentTimeMillis();898System.out.println("test_srlc_add: " + (end - start));899start = System.currentTimeMillis();900for (int i=0; i<ITERS; i++) {901test_srlv_add(a0, a1, ADD_INIT);902}903end = System.currentTimeMillis();904System.out.println("test_srlv_add: " + (end - start));905906start = System.currentTimeMillis();907for (int i=0; i<ITERS; i++) {908test_srac_add(a0, a1);909}910end = System.currentTimeMillis();911System.out.println("test_srac_add: " + (end - start));912start = System.currentTimeMillis();913for (int i=0; i<ITERS; i++) {914test_srav_add(a0, a1, ADD_INIT);915}916end = System.currentTimeMillis();917System.out.println("test_srav_add: " + (end - start));918919start = System.currentTimeMillis();920for (int i=0; i<ITERS; i++) {921test_sllc_and(a0, a1);922}923end = System.currentTimeMillis();924System.out.println("test_sllc_and: " + (end - start));925start = System.currentTimeMillis();926for (int i=0; i<ITERS; i++) {927test_sllv_and(a0, a1, BIT_MASK);928}929end = System.currentTimeMillis();930System.out.println("test_sllv_and: " + (end - start));931932start = System.currentTimeMillis();933for (int i=0; i<ITERS; i++) {934test_srlc_and(a0, a1);935}936end = System.currentTimeMillis();937System.out.println("test_srlc_and: " + (end - start));938start = System.currentTimeMillis();939for (int i=0; i<ITERS; i++) {940test_srlv_and(a0, a1, BIT_MASK);941}942end = System.currentTimeMillis();943System.out.println("test_srlv_and: " + (end - start));944945start = System.currentTimeMillis();946for (int i=0; i<ITERS; i++) {947test_srac_and(a0, a1);948}949end = System.currentTimeMillis();950System.out.println("test_srac_and: " + (end - start));951start = System.currentTimeMillis();952for (int i=0; i<ITERS; i++) {953test_srav_and(a0, a1, BIT_MASK);954}955end = System.currentTimeMillis();956System.out.println("test_srav_and: " + (end - start));957958start = System.currentTimeMillis();959for (int i=0; i<ITERS; i++) {960test_pack2(p2, a1);961}962end = System.currentTimeMillis();963System.out.println("test_pack2: " + (end - start));964start = System.currentTimeMillis();965for (int i=0; i<ITERS; i++) {966test_unpack2(a0, p2);967}968end = System.currentTimeMillis();969System.out.println("test_unpack2: " + (end - start));970start = System.currentTimeMillis();971for (int i=0; i<ITERS; i++) {972test_pack2_swap(p2, a1);973}974end = System.currentTimeMillis();975System.out.println("test_pack2_swap: " + (end - start));976start = System.currentTimeMillis();977for (int i=0; i<ITERS; i++) {978test_unpack2_swap(a0, p2);979}980end = System.currentTimeMillis();981System.out.println("test_unpack2_swap: " + (end - start));982983start = System.currentTimeMillis();984for (int i=0; i<ITERS; i++) {985test_pack4(p4, a1);986}987end = System.currentTimeMillis();988System.out.println("test_pack4: " + (end - start));989start = System.currentTimeMillis();990for (int i=0; i<ITERS; i++) {991test_unpack4(a0, p4);992}993end = System.currentTimeMillis();994System.out.println("test_unpack4: " + (end - start));995start = System.currentTimeMillis();996for (int i=0; i<ITERS; i++) {997test_pack4_swap(p4, a1);998}999end = System.currentTimeMillis();1000System.out.println("test_pack4_swap: " + (end - start));1001start = System.currentTimeMillis();1002for (int i=0; i<ITERS; i++) {1003test_unpack4_swap(a0, p4);1004}1005end = System.currentTimeMillis();1006System.out.println("test_unpack4_swap: " + (end - start));10071008start = System.currentTimeMillis();1009for (int i=0; i<ITERS; i++) {1010test_pack8(p8, a1);1011}1012end = System.currentTimeMillis();1013System.out.println("test_pack8: " + (end - start));1014start = System.currentTimeMillis();1015for (int i=0; i<ITERS; i++) {1016test_unpack8(a0, p8);1017}1018end = System.currentTimeMillis();1019System.out.println("test_unpack8: " + (end - start));1020start = System.currentTimeMillis();1021for (int i=0; i<ITERS; i++) {1022test_pack8_swap(p8, a1);1023}1024end = System.currentTimeMillis();1025System.out.println("test_pack8_swap: " + (end - start));1026start = System.currentTimeMillis();1027for (int i=0; i<ITERS; i++) {1028test_unpack8_swap(a0, p8);1029}1030end = System.currentTimeMillis();1031System.out.println("test_unpack8_swap: " + (end - start));10321033return errn;1034}10351036static int test_sum(byte[] a1) {1037int sum = 0;1038for (int i = 0; i < a1.length; i+=1) {1039sum += a1[i];1040}1041return sum;1042}10431044static void test_addc(byte[] a0, byte[] a1) {1045for (int i = 0; i < a0.length; i+=1) {1046a0[i] = (byte)(a1[i]+VALUE);1047}1048}1049static void test_addv(byte[] a0, byte[] a1, byte b) {1050for (int i = 0; i < a0.length; i+=1) {1051a0[i] = (byte)(a1[i]+b);1052}1053}1054static void test_adda(byte[] a0, byte[] a1, byte[] a2) {1055for (int i = 0; i < a0.length; i+=1) {1056a0[i] = (byte)(a1[i]+a2[i]);1057}1058}10591060static void test_subc(byte[] a0, byte[] a1) {1061for (int i = 0; i < a0.length; i+=1) {1062a0[i] = (byte)(a1[i]-VALUE);1063}1064}1065static void test_subv(byte[] a0, byte[] a1, byte b) {1066for (int i = 0; i < a0.length; i+=1) {1067a0[i] = (byte)(a1[i]-b);1068}1069}1070static void test_suba(byte[] a0, byte[] a1, byte[] a2) {1071for (int i = 0; i < a0.length; i+=1) {1072a0[i] = (byte)(a1[i]-a2[i]);1073}1074}10751076static void test_mulc(byte[] a0, byte[] a1) {1077for (int i = 0; i < a0.length; i+=1) {1078a0[i] = (byte)(a1[i]*VALUE);1079}1080}1081static void test_mulc_n(byte[] a0, byte[] a1) {1082for (int i = 0; i < a0.length; i+=1) {1083a0[i] = (byte)(a1[i]*(-VALUE));1084}1085}1086static void test_mulv(byte[] a0, byte[] a1, byte b) {1087for (int i = 0; i < a0.length; i+=1) {1088a0[i] = (byte)(a1[i]*b);1089}1090}1091static void test_mula(byte[] a0, byte[] a1, byte[] a2) {1092for (int i = 0; i < a0.length; i+=1) {1093a0[i] = (byte)(a1[i]*a2[i]);1094}1095}10961097static void test_divc(byte[] a0, byte[] a1) {1098for (int i = 0; i < a0.length; i+=1) {1099a0[i] = (byte)(a1[i]/VALUE);1100}1101}1102static void test_divc_n(byte[] a0, byte[] a1) {1103for (int i = 0; i < a0.length; i+=1) {1104a0[i] = (byte)(a1[i]/(-VALUE));1105}1106}1107static void test_divv(byte[] a0, byte[] a1, byte b) {1108for (int i = 0; i < a0.length; i+=1) {1109a0[i] = (byte)(a1[i]/b);1110}1111}1112static void test_diva(byte[] a0, byte[] a1, byte[] a2) {1113for (int i = 0; i < a0.length; i+=1) {1114a0[i] = (byte)(a1[i]/a2[i]);1115}1116}11171118static void test_andc(byte[] a0, byte[] a1) {1119for (int i = 0; i < a0.length; i+=1) {1120a0[i] = (byte)(a1[i]&BIT_MASK);1121}1122}1123static void test_andv(byte[] a0, byte[] a1, byte b) {1124for (int i = 0; i < a0.length; i+=1) {1125a0[i] = (byte)(a1[i]&b);1126}1127}1128static void test_anda(byte[] a0, byte[] a1, byte[] a2) {1129for (int i = 0; i < a0.length; i+=1) {1130a0[i] = (byte)(a1[i]&a2[i]);1131}1132}11331134static void test_orc(byte[] a0, byte[] a1) {1135for (int i = 0; i < a0.length; i+=1) {1136a0[i] = (byte)(a1[i]|BIT_MASK);1137}1138}1139static void test_orv(byte[] a0, byte[] a1, byte b) {1140for (int i = 0; i < a0.length; i+=1) {1141a0[i] = (byte)(a1[i]|b);1142}1143}1144static void test_ora(byte[] a0, byte[] a1, byte[] a2) {1145for (int i = 0; i < a0.length; i+=1) {1146a0[i] = (byte)(a1[i]|a2[i]);1147}1148}11491150static void test_xorc(byte[] a0, byte[] a1) {1151for (int i = 0; i < a0.length; i+=1) {1152a0[i] = (byte)(a1[i]^BIT_MASK);1153}1154}1155static void test_xorv(byte[] a0, byte[] a1, byte b) {1156for (int i = 0; i < a0.length; i+=1) {1157a0[i] = (byte)(a1[i]^b);1158}1159}1160static void test_xora(byte[] a0, byte[] a1, byte[] a2) {1161for (int i = 0; i < a0.length; i+=1) {1162a0[i] = (byte)(a1[i]^a2[i]);1163}1164}11651166static void test_sllc(byte[] a0, byte[] a1) {1167for (int i = 0; i < a0.length; i+=1) {1168a0[i] = (byte)(a1[i]<<VALUE);1169}1170}1171static void test_sllc_n(byte[] a0, byte[] a1) {1172for (int i = 0; i < a0.length; i+=1) {1173a0[i] = (byte)(a1[i]<<(-VALUE));1174}1175}1176static void test_sllc_o(byte[] a0, byte[] a1) {1177for (int i = 0; i < a0.length; i+=1) {1178a0[i] = (byte)(a1[i]<<SHIFT);1179}1180}1181static void test_sllc_on(byte[] a0, byte[] a1) {1182for (int i = 0; i < a0.length; i+=1) {1183a0[i] = (byte)(a1[i]<<(-SHIFT));1184}1185}1186static void test_sllv(byte[] a0, byte[] a1, int b) {1187for (int i = 0; i < a0.length; i+=1) {1188a0[i] = (byte)(a1[i]<<b);1189}1190}1191static void test_sllc_add(byte[] a0, byte[] a1) {1192for (int i = 0; i < a0.length; i+=1) {1193a0[i] = (byte)((a1[i] + ADD_INIT)<<VALUE);1194}1195}1196static void test_sllv_add(byte[] a0, byte[] a1, int b) {1197for (int i = 0; i < a0.length; i+=1) {1198a0[i] = (byte)((a1[i] + b)<<VALUE);1199}1200}1201static void test_sllc_and(byte[] a0, byte[] a1) {1202for (int i = 0; i < a0.length; i+=1) {1203a0[i] = (byte)((a1[i] & BIT_MASK)<<VALUE);1204}1205}1206static void test_sllv_and(byte[] a0, byte[] a1, int b) {1207for (int i = 0; i < a0.length; i+=1) {1208a0[i] = (byte)((a1[i] & b)<<VALUE);1209}1210}12111212static void test_srlc(byte[] a0, byte[] a1) {1213for (int i = 0; i < a0.length; i+=1) {1214a0[i] = (byte)(a1[i]>>>VALUE);1215}1216}1217static void test_srlc_n(byte[] a0, byte[] a1) {1218for (int i = 0; i < a0.length; i+=1) {1219a0[i] = (byte)(a1[i]>>>(-VALUE));1220}1221}1222static void test_srlc_o(byte[] a0, byte[] a1) {1223for (int i = 0; i < a0.length; i+=1) {1224a0[i] = (byte)(a1[i]>>>SHIFT);1225}1226}1227static void test_srlc_on(byte[] a0, byte[] a1) {1228for (int i = 0; i < a0.length; i+=1) {1229a0[i] = (byte)(a1[i]>>>(-SHIFT));1230}1231}1232static void test_srlv(byte[] a0, byte[] a1, int b) {1233for (int i = 0; i < a0.length; i+=1) {1234a0[i] = (byte)(a1[i]>>>b);1235}1236}1237static void test_srlc_add(byte[] a0, byte[] a1) {1238for (int i = 0; i < a0.length; i+=1) {1239a0[i] = (byte)((a1[i] + ADD_INIT)>>>VALUE);1240}1241}1242static void test_srlv_add(byte[] a0, byte[] a1, int b) {1243for (int i = 0; i < a0.length; i+=1) {1244a0[i] = (byte)((a1[i] + b)>>>VALUE);1245}1246}1247static void test_srlc_and(byte[] a0, byte[] a1) {1248for (int i = 0; i < a0.length; i+=1) {1249a0[i] = (byte)((a1[i] & BIT_MASK)>>>VALUE);1250}1251}1252static void test_srlv_and(byte[] a0, byte[] a1, int b) {1253for (int i = 0; i < a0.length; i+=1) {1254a0[i] = (byte)((a1[i] & b)>>>VALUE);1255}1256}12571258static void test_srac(byte[] a0, byte[] a1) {1259for (int i = 0; i < a0.length; i+=1) {1260a0[i] = (byte)(a1[i]>>VALUE);1261}1262}1263static void test_srac_n(byte[] a0, byte[] a1) {1264for (int i = 0; i < a0.length; i+=1) {1265a0[i] = (byte)(a1[i]>>(-VALUE));1266}1267}1268static void test_srac_o(byte[] a0, byte[] a1) {1269for (int i = 0; i < a0.length; i+=1) {1270a0[i] = (byte)(a1[i]>>SHIFT);1271}1272}1273static void test_srac_on(byte[] a0, byte[] a1) {1274for (int i = 0; i < a0.length; i+=1) {1275a0[i] = (byte)(a1[i]>>(-SHIFT));1276}1277}1278static void test_srav(byte[] a0, byte[] a1, int b) {1279for (int i = 0; i < a0.length; i+=1) {1280a0[i] = (byte)(a1[i]>>b);1281}1282}1283static void test_srac_add(byte[] a0, byte[] a1) {1284for (int i = 0; i < a0.length; i+=1) {1285a0[i] = (byte)((a1[i] + ADD_INIT)>>VALUE);1286}1287}1288static void test_srav_add(byte[] a0, byte[] a1, int b) {1289for (int i = 0; i < a0.length; i+=1) {1290a0[i] = (byte)((a1[i] + b)>>VALUE);1291}1292}1293static void test_srac_and(byte[] a0, byte[] a1) {1294for (int i = 0; i < a0.length; i+=1) {1295a0[i] = (byte)((a1[i] & BIT_MASK)>>VALUE);1296}1297}1298static void test_srav_and(byte[] a0, byte[] a1, int b) {1299for (int i = 0; i < a0.length; i+=1) {1300a0[i] = (byte)((a1[i] & b)>>VALUE);1301}1302}13031304static void test_pack2(short[] p2, byte[] a1) {1305if (p2.length*2 > a1.length) return;1306for (int i = 0; i < p2.length; i+=1) {1307short l0 = (short)a1[i*2+0];1308short l1 = (short)a1[i*2+1];1309p2[i] = (short)((l1 << 8) | (l0 & 0xFF));1310}1311}1312static void test_unpack2(byte[] a0, short[] p2) {1313if (p2.length*2 > a0.length) return;1314for (int i = 0; i < p2.length; i+=1) {1315short l = p2[i];1316a0[i*2+0] = (byte)(l & 0xFF);1317a0[i*2+1] = (byte)(l >> 8);1318}1319}1320static void test_pack2_swap(short[] p2, byte[] a1) {1321if (p2.length*2 > a1.length) return;1322for (int i = 0; i < p2.length; i+=1) {1323short l0 = (short)a1[i*2+0];1324short l1 = (short)a1[i*2+1];1325p2[i] = (short)((l0 << 8) | (l1 & 0xFF));1326}1327}1328static void test_unpack2_swap(byte[] a0, short[] p2) {1329if (p2.length*2 > a0.length) return;1330for (int i = 0; i < p2.length; i+=1) {1331short l = p2[i];1332a0[i*2+0] = (byte)(l >> 8);1333a0[i*2+1] = (byte)(l & 0xFF);1334}1335}13361337static void test_pack4(int[] p4, byte[] a1) {1338if (p4.length*4 > a1.length) return;1339for (int i = 0; i < p4.length; i+=1) {1340int l0 = (int)a1[i*4+0];1341int l1 = (int)a1[i*4+1];1342int l2 = (int)a1[i*4+2];1343int l3 = (int)a1[i*4+3];1344p4[i] = (l0 & 0xFF) |1345((l1 & 0xFF) << 8) |1346((l2 & 0xFF) << 16) |1347((l3 & 0xFF) << 24);1348}1349}1350static void test_unpack4(byte[] a0, int[] p4) {1351if (p4.length*4 > a0.length) return;1352for (int i = 0; i < p4.length; i+=1) {1353int l = p4[i];1354a0[i*4+0] = (byte)(l & 0xFF);1355a0[i*4+1] = (byte)(l >> 8);1356a0[i*4+2] = (byte)(l >> 16);1357a0[i*4+3] = (byte)(l >> 24);1358}1359}1360static void test_pack4_swap(int[] p4, byte[] a1) {1361if (p4.length*4 > a1.length) return;1362for (int i = 0; i < p4.length; i+=1) {1363int l0 = (int)a1[i*4+0];1364int l1 = (int)a1[i*4+1];1365int l2 = (int)a1[i*4+2];1366int l3 = (int)a1[i*4+3];1367p4[i] = (l3 & 0xFF) |1368((l2 & 0xFF) << 8) |1369((l1 & 0xFF) << 16) |1370((l0 & 0xFF) << 24);1371}1372}1373static void test_unpack4_swap(byte[] a0, int[] p4) {1374if (p4.length*4 > a0.length) return;1375for (int i = 0; i < p4.length; i+=1) {1376int l = p4[i];1377a0[i*4+0] = (byte)(l >> 24);1378a0[i*4+1] = (byte)(l >> 16);1379a0[i*4+2] = (byte)(l >> 8);1380a0[i*4+3] = (byte)(l & 0xFF);1381}1382}13831384static void test_pack8(long[] p8, byte[] a1) {1385if (p8.length*8 > a1.length) return;1386for (int i = 0; i < p8.length; i+=1) {1387long l0 = (long)a1[i*8+0];1388long l1 = (long)a1[i*8+1];1389long l2 = (long)a1[i*8+2];1390long l3 = (long)a1[i*8+3];1391long l4 = (long)a1[i*8+4];1392long l5 = (long)a1[i*8+5];1393long l6 = (long)a1[i*8+6];1394long l7 = (long)a1[i*8+7];1395p8[i] = (l0 & 0xFFl) |1396((l1 & 0xFFl) << 8) |1397((l2 & 0xFFl) << 16) |1398((l3 & 0xFFl) << 24) |1399((l4 & 0xFFl) << 32) |1400((l5 & 0xFFl) << 40) |1401((l6 & 0xFFl) << 48) |1402((l7 & 0xFFl) << 56);1403}1404}1405static void test_unpack8(byte[] a0, long[] p8) {1406if (p8.length*8 > a0.length) return;1407for (int i = 0; i < p8.length; i+=1) {1408long l = p8[i];1409a0[i*8+0] = (byte)(l & 0xFFl);1410a0[i*8+1] = (byte)(l >> 8);1411a0[i*8+2] = (byte)(l >> 16);1412a0[i*8+3] = (byte)(l >> 24);1413a0[i*8+4] = (byte)(l >> 32);1414a0[i*8+5] = (byte)(l >> 40);1415a0[i*8+6] = (byte)(l >> 48);1416a0[i*8+7] = (byte)(l >> 56);1417}1418}1419static void test_pack8_swap(long[] p8, byte[] a1) {1420if (p8.length*8 > a1.length) return;1421for (int i = 0; i < p8.length; i+=1) {1422long l0 = (long)a1[i*8+0];1423long l1 = (long)a1[i*8+1];1424long l2 = (long)a1[i*8+2];1425long l3 = (long)a1[i*8+3];1426long l4 = (long)a1[i*8+4];1427long l5 = (long)a1[i*8+5];1428long l6 = (long)a1[i*8+6];1429long l7 = (long)a1[i*8+7];1430p8[i] = (l7 & 0xFFl) |1431((l6 & 0xFFl) << 8) |1432((l5 & 0xFFl) << 16) |1433((l4 & 0xFFl) << 24) |1434((l3 & 0xFFl) << 32) |1435((l2 & 0xFFl) << 40) |1436((l1 & 0xFFl) << 48) |1437((l0 & 0xFFl) << 56);1438}1439}1440static void test_unpack8_swap(byte[] a0, long[] p8) {1441if (p8.length*8 > a0.length) return;1442for (int i = 0; i < p8.length; i+=1) {1443long l = p8[i];1444a0[i*8+0] = (byte)(l >> 56);1445a0[i*8+1] = (byte)(l >> 48);1446a0[i*8+2] = (byte)(l >> 40);1447a0[i*8+3] = (byte)(l >> 32);1448a0[i*8+4] = (byte)(l >> 24);1449a0[i*8+5] = (byte)(l >> 16);1450a0[i*8+6] = (byte)(l >> 8);1451a0[i*8+7] = (byte)(l & 0xFFl);1452}1453}14541455static int verify(String text, int i, byte elem, byte val) {1456if (elem != val) {1457System.err.println(text + "[" + i + "] = " + elem + " != " + val);1458return 1;1459}1460return 0;1461}14621463static int verify(String text, int i, short elem, short val) {1464if (elem != val) {1465System.err.println(text + "[" + i + "] = " + elem + " != " + val);1466return 1;1467}1468return 0;1469}14701471static int verify(String text, int i, int elem, int val) {1472if (elem != val) {1473System.err.println(text + "[" + i + "] = " + Integer.toHexString(elem) + " != " + Integer.toHexString(val));1474return 1;1475}1476return 0;1477}14781479static int verify(String text, int i, long elem, long val) {1480if (elem != val) {1481System.err.println(text + "[" + i + "] = " + Long.toHexString(elem) + " != " + Long.toHexString(val));1482return 1;1483}1484return 0;1485}1486}148714881489