test/compiler/6340864/TestByteVect.java

changeset 4204
b2c669fd8114
parent 4001
006050192a5a
child 6876
710a3c8b516e
equal deleted inserted replaced
4203:fd1d564dd460 4204:b2c669fd8114
31 */ 31 */
32 32
33 public class TestByteVect { 33 public class TestByteVect {
34 private static final int ARRLEN = 997; 34 private static final int ARRLEN = 997;
35 private static final int ITERS = 11000; 35 private static final int ITERS = 11000;
36 private static final int ADD_INIT = 0; 36 private static final int ADD_INIT = 63;
37 private static final int BIT_MASK = 0xB7; 37 private static final int BIT_MASK = 0xB7;
38 private static final int VALUE = 3; 38 private static final int VALUE = 3;
39 private static final int SHIFT = 8; 39 private static final int SHIFT = 8;
40 40
41 public static void main(String args[]) { 41 public static void main(String args[]) {
74 test_addv(a0, a1, (byte)VALUE); 74 test_addv(a0, a1, (byte)VALUE);
75 test_adda(a0, a1, a2); 75 test_adda(a0, a1, a2);
76 test_subc(a0, a1); 76 test_subc(a0, a1);
77 test_subv(a0, a1, (byte)VALUE); 77 test_subv(a0, a1, (byte)VALUE);
78 test_suba(a0, a1, a2); 78 test_suba(a0, a1, a2);
79
79 test_mulc(a0, a1); 80 test_mulc(a0, a1);
80 test_mulv(a0, a1, (byte)VALUE); 81 test_mulv(a0, a1, (byte)VALUE);
81 test_mula(a0, a1, a2); 82 test_mula(a0, a1, a2);
82 test_divc(a0, a1); 83 test_divc(a0, a1);
83 test_divv(a0, a1, (byte)VALUE); 84 test_divv(a0, a1, (byte)VALUE);
86 test_mulv(a0, a1, (byte)-VALUE); 87 test_mulv(a0, a1, (byte)-VALUE);
87 test_mula(a0, a1, a3); 88 test_mula(a0, a1, a3);
88 test_divc_n(a0, a1); 89 test_divc_n(a0, a1);
89 test_divv(a0, a1, (byte)-VALUE); 90 test_divv(a0, a1, (byte)-VALUE);
90 test_diva(a0, a1, a3); 91 test_diva(a0, a1, a3);
92
91 test_andc(a0, a1); 93 test_andc(a0, a1);
92 test_andv(a0, a1, (byte)BIT_MASK); 94 test_andv(a0, a1, (byte)BIT_MASK);
93 test_anda(a0, a1, a4); 95 test_anda(a0, a1, a4);
94 test_orc(a0, a1); 96 test_orc(a0, a1);
95 test_orv(a0, a1, (byte)BIT_MASK); 97 test_orv(a0, a1, (byte)BIT_MASK);
96 test_ora(a0, a1, a4); 98 test_ora(a0, a1, a4);
97 test_xorc(a0, a1); 99 test_xorc(a0, a1);
98 test_xorv(a0, a1, (byte)BIT_MASK); 100 test_xorv(a0, a1, (byte)BIT_MASK);
99 test_xora(a0, a1, a4); 101 test_xora(a0, a1, a4);
102
100 test_sllc(a0, a1); 103 test_sllc(a0, a1);
101 test_sllv(a0, a1, VALUE); 104 test_sllv(a0, a1, VALUE);
102 test_srlc(a0, a1); 105 test_srlc(a0, a1);
103 test_srlv(a0, a1, VALUE); 106 test_srlv(a0, a1, VALUE);
104 test_srac(a0, a1); 107 test_srac(a0, a1);
105 test_srav(a0, a1, VALUE); 108 test_srav(a0, a1, VALUE);
109
106 test_sllc_n(a0, a1); 110 test_sllc_n(a0, a1);
107 test_sllv(a0, a1, -VALUE); 111 test_sllv(a0, a1, -VALUE);
108 test_srlc_n(a0, a1); 112 test_srlc_n(a0, a1);
109 test_srlv(a0, a1, -VALUE); 113 test_srlv(a0, a1, -VALUE);
110 test_srac_n(a0, a1); 114 test_srac_n(a0, a1);
111 test_srav(a0, a1, -VALUE); 115 test_srav(a0, a1, -VALUE);
116
112 test_sllc_o(a0, a1); 117 test_sllc_o(a0, a1);
113 test_sllv(a0, a1, SHIFT); 118 test_sllv(a0, a1, SHIFT);
114 test_srlc_o(a0, a1); 119 test_srlc_o(a0, a1);
115 test_srlv(a0, a1, SHIFT); 120 test_srlv(a0, a1, SHIFT);
116 test_srac_o(a0, a1); 121 test_srac_o(a0, a1);
117 test_srav(a0, a1, SHIFT); 122 test_srav(a0, a1, SHIFT);
123
118 test_sllc_on(a0, a1); 124 test_sllc_on(a0, a1);
119 test_sllv(a0, a1, -SHIFT); 125 test_sllv(a0, a1, -SHIFT);
120 test_srlc_on(a0, a1); 126 test_srlc_on(a0, a1);
121 test_srlv(a0, a1, -SHIFT); 127 test_srlv(a0, a1, -SHIFT);
122 test_srac_on(a0, a1); 128 test_srac_on(a0, a1);
123 test_srav(a0, a1, -SHIFT); 129 test_srav(a0, a1, -SHIFT);
130
131 test_sllc_add(a0, a1);
132 test_sllv_add(a0, a1, ADD_INIT);
133 test_srlc_add(a0, a1);
134 test_srlv_add(a0, a1, ADD_INIT);
135 test_srac_add(a0, a1);
136 test_srav_add(a0, a1, ADD_INIT);
137
138 test_sllc_and(a0, a1);
139 test_sllv_and(a0, a1, BIT_MASK);
140 test_srlc_and(a0, a1);
141 test_srlv_and(a0, a1, BIT_MASK);
142 test_srac_and(a0, a1);
143 test_srav_and(a0, a1, BIT_MASK);
144
124 test_pack2(p2, a1); 145 test_pack2(p2, a1);
125 test_unpack2(a0, p2); 146 test_unpack2(a0, p2);
126 test_pack2_swap(p2, a1); 147 test_pack2_swap(p2, a1);
127 test_unpack2_swap(a0, p2); 148 test_unpack2_swap(a0, p2);
128 test_pack4(p4, a1); 149 test_pack4(p4, a1);
367 test_srav(a0, a1, -SHIFT); 388 test_srav(a0, a1, -SHIFT);
368 for (int i=0; i<ARRLEN; i++) { 389 for (int i=0; i<ARRLEN; i++) {
369 errn += verify("test_srav_on: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>(-SHIFT))); 390 errn += verify("test_srav_on: ", i, a0[i], (byte)((byte)(ADD_INIT+i)>>(-SHIFT)));
370 } 391 }
371 392
393 test_sllc_add(a0, a1);
394 for (int i=0; i<ARRLEN; i++) {
395 errn += verify("test_sllc_add: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) + ADD_INIT)<<VALUE));
396 }
397 test_sllv_add(a0, a1, ADD_INIT);
398 for (int i=0; i<ARRLEN; i++) {
399 errn += verify("test_sllv_add: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) + ADD_INIT)<<VALUE));
400 }
401
402 test_srlc_add(a0, a1);
403 for (int i=0; i<ARRLEN; i++) {
404 errn += verify("test_srlc_add: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) + ADD_INIT)>>>VALUE));
405 }
406 test_srlv_add(a0, a1, ADD_INIT);
407 for (int i=0; i<ARRLEN; i++) {
408 errn += verify("test_srlv_add: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) + ADD_INIT)>>>VALUE));
409 }
410
411 test_srac_add(a0, a1);
412 for (int i=0; i<ARRLEN; i++) {
413 errn += verify("test_srac_add: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) + ADD_INIT)>>VALUE));
414 }
415 test_srav_add(a0, a1, ADD_INIT);
416 for (int i=0; i<ARRLEN; i++) {
417 errn += verify("test_srav_add: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) + ADD_INIT)>>VALUE));
418 }
419
420 test_sllc_and(a0, a1);
421 for (int i=0; i<ARRLEN; i++) {
422 errn += verify("test_sllc_and: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) & BIT_MASK)<<VALUE));
423 }
424 test_sllv_and(a0, a1, BIT_MASK);
425 for (int i=0; i<ARRLEN; i++) {
426 errn += verify("test_sllv_and: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) & BIT_MASK)<<VALUE));
427 }
428
429 test_srlc_and(a0, a1);
430 for (int i=0; i<ARRLEN; i++) {
431 errn += verify("test_srlc_and: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) & BIT_MASK)>>>VALUE));
432 }
433 test_srlv_and(a0, a1, BIT_MASK);
434 for (int i=0; i<ARRLEN; i++) {
435 errn += verify("test_srlv_and: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) & BIT_MASK)>>>VALUE));
436 }
437
438 test_srac_and(a0, a1);
439 for (int i=0; i<ARRLEN; i++) {
440 errn += verify("test_srac_and: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) & BIT_MASK)>>VALUE));
441 }
442 test_srav_and(a0, a1, BIT_MASK);
443 for (int i=0; i<ARRLEN; i++) {
444 errn += verify("test_srav_and: ", i, a0[i], (byte)(((byte)(ADD_INIT+i) & BIT_MASK)>>VALUE));
445 }
446
372 test_pack2(p2, a1); 447 test_pack2(p2, a1);
373 for (int i=0; i<ARRLEN/2; i++) { 448 for (int i=0; i<ARRLEN/2; i++) {
374 errn += verify("test_pack2: ", i, p2[i], (short)(((short)(ADD_INIT+2*i) & 0xFF) | ((short)(ADD_INIT+2*i+1) << 8))); 449 errn += verify("test_pack2: ", i, p2[i], (short)(((short)(ADD_INIT+2*i) & 0xFF) | ((short)(ADD_INIT+2*i+1) << 8)));
375 } 450 }
376 for (int i=0; i<ARRLEN; i++) { 451 for (int i=0; i<ARRLEN; i++) {
803 end = System.currentTimeMillis(); 878 end = System.currentTimeMillis();
804 System.out.println("test_srav_on: " + (end - start)); 879 System.out.println("test_srav_on: " + (end - start));
805 880
806 start = System.currentTimeMillis(); 881 start = System.currentTimeMillis();
807 for (int i=0; i<ITERS; i++) { 882 for (int i=0; i<ITERS; i++) {
883 test_sllc_add(a0, a1);
884 }
885 end = System.currentTimeMillis();
886 System.out.println("test_sllc_add: " + (end - start));
887 start = System.currentTimeMillis();
888 for (int i=0; i<ITERS; i++) {
889 test_sllv_add(a0, a1, ADD_INIT);
890 }
891 end = System.currentTimeMillis();
892 System.out.println("test_sllv_add: " + (end - start));
893
894 start = System.currentTimeMillis();
895 for (int i=0; i<ITERS; i++) {
896 test_srlc_add(a0, a1);
897 }
898 end = System.currentTimeMillis();
899 System.out.println("test_srlc_add: " + (end - start));
900 start = System.currentTimeMillis();
901 for (int i=0; i<ITERS; i++) {
902 test_srlv_add(a0, a1, ADD_INIT);
903 }
904 end = System.currentTimeMillis();
905 System.out.println("test_srlv_add: " + (end - start));
906
907 start = System.currentTimeMillis();
908 for (int i=0; i<ITERS; i++) {
909 test_srac_add(a0, a1);
910 }
911 end = System.currentTimeMillis();
912 System.out.println("test_srac_add: " + (end - start));
913 start = System.currentTimeMillis();
914 for (int i=0; i<ITERS; i++) {
915 test_srav_add(a0, a1, ADD_INIT);
916 }
917 end = System.currentTimeMillis();
918 System.out.println("test_srav_add: " + (end - start));
919
920 start = System.currentTimeMillis();
921 for (int i=0; i<ITERS; i++) {
922 test_sllc_and(a0, a1);
923 }
924 end = System.currentTimeMillis();
925 System.out.println("test_sllc_and: " + (end - start));
926 start = System.currentTimeMillis();
927 for (int i=0; i<ITERS; i++) {
928 test_sllv_and(a0, a1, BIT_MASK);
929 }
930 end = System.currentTimeMillis();
931 System.out.println("test_sllv_and: " + (end - start));
932
933 start = System.currentTimeMillis();
934 for (int i=0; i<ITERS; i++) {
935 test_srlc_and(a0, a1);
936 }
937 end = System.currentTimeMillis();
938 System.out.println("test_srlc_and: " + (end - start));
939 start = System.currentTimeMillis();
940 for (int i=0; i<ITERS; i++) {
941 test_srlv_and(a0, a1, BIT_MASK);
942 }
943 end = System.currentTimeMillis();
944 System.out.println("test_srlv_and: " + (end - start));
945
946 start = System.currentTimeMillis();
947 for (int i=0; i<ITERS; i++) {
948 test_srac_and(a0, a1);
949 }
950 end = System.currentTimeMillis();
951 System.out.println("test_srac_and: " + (end - start));
952 start = System.currentTimeMillis();
953 for (int i=0; i<ITERS; i++) {
954 test_srav_and(a0, a1, BIT_MASK);
955 }
956 end = System.currentTimeMillis();
957 System.out.println("test_srav_and: " + (end - start));
958
959 start = System.currentTimeMillis();
960 for (int i=0; i<ITERS; i++) {
808 test_pack2(p2, a1); 961 test_pack2(p2, a1);
809 } 962 }
810 end = System.currentTimeMillis(); 963 end = System.currentTimeMillis();
811 System.out.println("test_pack2: " + (end - start)); 964 System.out.println("test_pack2: " + (end - start));
812 start = System.currentTimeMillis(); 965 start = System.currentTimeMillis();
1034 static void test_sllv(byte[] a0, byte[] a1, int b) { 1187 static void test_sllv(byte[] a0, byte[] a1, int b) {
1035 for (int i = 0; i < a0.length; i+=1) { 1188 for (int i = 0; i < a0.length; i+=1) {
1036 a0[i] = (byte)(a1[i]<<b); 1189 a0[i] = (byte)(a1[i]<<b);
1037 } 1190 }
1038 } 1191 }
1192 static void test_sllc_add(byte[] a0, byte[] a1) {
1193 for (int i = 0; i < a0.length; i+=1) {
1194 a0[i] = (byte)((a1[i] + ADD_INIT)<<VALUE);
1195 }
1196 }
1197 static void test_sllv_add(byte[] a0, byte[] a1, int b) {
1198 for (int i = 0; i < a0.length; i+=1) {
1199 a0[i] = (byte)((a1[i] + b)<<VALUE);
1200 }
1201 }
1202 static void test_sllc_and(byte[] a0, byte[] a1) {
1203 for (int i = 0; i < a0.length; i+=1) {
1204 a0[i] = (byte)((a1[i] & BIT_MASK)<<VALUE);
1205 }
1206 }
1207 static void test_sllv_and(byte[] a0, byte[] a1, int b) {
1208 for (int i = 0; i < a0.length; i+=1) {
1209 a0[i] = (byte)((a1[i] & b)<<VALUE);
1210 }
1211 }
1039 1212
1040 static void test_srlc(byte[] a0, byte[] a1) { 1213 static void test_srlc(byte[] a0, byte[] a1) {
1041 for (int i = 0; i < a0.length; i+=1) { 1214 for (int i = 0; i < a0.length; i+=1) {
1042 a0[i] = (byte)(a1[i]>>>VALUE); 1215 a0[i] = (byte)(a1[i]>>>VALUE);
1043 } 1216 }
1060 static void test_srlv(byte[] a0, byte[] a1, int b) { 1233 static void test_srlv(byte[] a0, byte[] a1, int b) {
1061 for (int i = 0; i < a0.length; i+=1) { 1234 for (int i = 0; i < a0.length; i+=1) {
1062 a0[i] = (byte)(a1[i]>>>b); 1235 a0[i] = (byte)(a1[i]>>>b);
1063 } 1236 }
1064 } 1237 }
1238 static void test_srlc_add(byte[] a0, byte[] a1) {
1239 for (int i = 0; i < a0.length; i+=1) {
1240 a0[i] = (byte)((a1[i] + ADD_INIT)>>>VALUE);
1241 }
1242 }
1243 static void test_srlv_add(byte[] a0, byte[] a1, int b) {
1244 for (int i = 0; i < a0.length; i+=1) {
1245 a0[i] = (byte)((a1[i] + b)>>>VALUE);
1246 }
1247 }
1248 static void test_srlc_and(byte[] a0, byte[] a1) {
1249 for (int i = 0; i < a0.length; i+=1) {
1250 a0[i] = (byte)((a1[i] & BIT_MASK)>>>VALUE);
1251 }
1252 }
1253 static void test_srlv_and(byte[] a0, byte[] a1, int b) {
1254 for (int i = 0; i < a0.length; i+=1) {
1255 a0[i] = (byte)((a1[i] & b)>>>VALUE);
1256 }
1257 }
1065 1258
1066 static void test_srac(byte[] a0, byte[] a1) { 1259 static void test_srac(byte[] a0, byte[] a1) {
1067 for (int i = 0; i < a0.length; i+=1) { 1260 for (int i = 0; i < a0.length; i+=1) {
1068 a0[i] = (byte)(a1[i]>>VALUE); 1261 a0[i] = (byte)(a1[i]>>VALUE);
1069 } 1262 }
1084 } 1277 }
1085 } 1278 }
1086 static void test_srav(byte[] a0, byte[] a1, int b) { 1279 static void test_srav(byte[] a0, byte[] a1, int b) {
1087 for (int i = 0; i < a0.length; i+=1) { 1280 for (int i = 0; i < a0.length; i+=1) {
1088 a0[i] = (byte)(a1[i]>>b); 1281 a0[i] = (byte)(a1[i]>>b);
1282 }
1283 }
1284 static void test_srac_add(byte[] a0, byte[] a1) {
1285 for (int i = 0; i < a0.length; i+=1) {
1286 a0[i] = (byte)((a1[i] + ADD_INIT)>>VALUE);
1287 }
1288 }
1289 static void test_srav_add(byte[] a0, byte[] a1, int b) {
1290 for (int i = 0; i < a0.length; i+=1) {
1291 a0[i] = (byte)((a1[i] + b)>>VALUE);
1292 }
1293 }
1294 static void test_srac_and(byte[] a0, byte[] a1) {
1295 for (int i = 0; i < a0.length; i+=1) {
1296 a0[i] = (byte)((a1[i] & BIT_MASK)>>VALUE);
1297 }
1298 }
1299 static void test_srav_and(byte[] a0, byte[] a1, int b) {
1300 for (int i = 0; i < a0.length; i+=1) {
1301 a0[i] = (byte)((a1[i] & b)>>VALUE);
1089 } 1302 }
1090 } 1303 }
1091 1304
1092 static void test_pack2(short[] p2, byte[] a1) { 1305 static void test_pack2(short[] p2, byte[] a1) {
1093 if (p2.length*2 > a1.length) return; 1306 if (p2.length*2 > a1.length) return;

mercurial