comparison test/compiler/6340864/TestShortVect.java @ 6893:b2c669fd8114

8001183: incorrect results of char vectors right shift operaiton Summary: do vector right shift operation for small int types only after loads Reviewed-by: jrose, dlong
author kvn
date Tue, 23 Oct 2012 13:06:37 -0700
parents 006050192a5a
children
comparison
equal deleted inserted replaced
6892:fd1d564dd460 6893:b2c669fd8114
73 test_addv(a0, a1, (short)VALUE); 73 test_addv(a0, a1, (short)VALUE);
74 test_adda(a0, a1, a2); 74 test_adda(a0, a1, a2);
75 test_subc(a0, a1); 75 test_subc(a0, a1);
76 test_subv(a0, a1, (short)VALUE); 76 test_subv(a0, a1, (short)VALUE);
77 test_suba(a0, a1, a2); 77 test_suba(a0, a1, a2);
78
78 test_mulc(a0, a1); 79 test_mulc(a0, a1);
79 test_mulv(a0, a1, (short)VALUE); 80 test_mulv(a0, a1, (short)VALUE);
80 test_mula(a0, a1, a2); 81 test_mula(a0, a1, a2);
81 test_divc(a0, a1); 82 test_divc(a0, a1);
82 test_divv(a0, a1, (short)VALUE); 83 test_divv(a0, a1, (short)VALUE);
85 test_mulv(a0, a1, (short)-VALUE); 86 test_mulv(a0, a1, (short)-VALUE);
86 test_mula(a0, a1, a3); 87 test_mula(a0, a1, a3);
87 test_divc_n(a0, a1); 88 test_divc_n(a0, a1);
88 test_divv(a0, a1, (short)-VALUE); 89 test_divv(a0, a1, (short)-VALUE);
89 test_diva(a0, a1, a3); 90 test_diva(a0, a1, a3);
91
90 test_andc(a0, a1); 92 test_andc(a0, a1);
91 test_andv(a0, a1, (short)BIT_MASK); 93 test_andv(a0, a1, (short)BIT_MASK);
92 test_anda(a0, a1, a4); 94 test_anda(a0, a1, a4);
93 test_orc(a0, a1); 95 test_orc(a0, a1);
94 test_orv(a0, a1, (short)BIT_MASK); 96 test_orv(a0, a1, (short)BIT_MASK);
95 test_ora(a0, a1, a4); 97 test_ora(a0, a1, a4);
96 test_xorc(a0, a1); 98 test_xorc(a0, a1);
97 test_xorv(a0, a1, (short)BIT_MASK); 99 test_xorv(a0, a1, (short)BIT_MASK);
98 test_xora(a0, a1, a4); 100 test_xora(a0, a1, a4);
101
99 test_sllc(a0, a1); 102 test_sllc(a0, a1);
100 test_sllv(a0, a1, VALUE); 103 test_sllv(a0, a1, VALUE);
101 test_srlc(a0, a1); 104 test_srlc(a0, a1);
102 test_srlv(a0, a1, VALUE); 105 test_srlv(a0, a1, VALUE);
103 test_srac(a0, a1); 106 test_srac(a0, a1);
104 test_srav(a0, a1, VALUE); 107 test_srav(a0, a1, VALUE);
108
105 test_sllc_n(a0, a1); 109 test_sllc_n(a0, a1);
106 test_sllv(a0, a1, -VALUE); 110 test_sllv(a0, a1, -VALUE);
107 test_srlc_n(a0, a1); 111 test_srlc_n(a0, a1);
108 test_srlv(a0, a1, -VALUE); 112 test_srlv(a0, a1, -VALUE);
109 test_srac_n(a0, a1); 113 test_srac_n(a0, a1);
110 test_srav(a0, a1, -VALUE); 114 test_srav(a0, a1, -VALUE);
115
111 test_sllc_o(a0, a1); 116 test_sllc_o(a0, a1);
112 test_sllv(a0, a1, SHIFT); 117 test_sllv(a0, a1, SHIFT);
113 test_srlc_o(a0, a1); 118 test_srlc_o(a0, a1);
114 test_srlv(a0, a1, SHIFT); 119 test_srlv(a0, a1, SHIFT);
115 test_srac_o(a0, a1); 120 test_srac_o(a0, a1);
116 test_srav(a0, a1, SHIFT); 121 test_srav(a0, a1, SHIFT);
122
117 test_sllc_on(a0, a1); 123 test_sllc_on(a0, a1);
118 test_sllv(a0, a1, -SHIFT); 124 test_sllv(a0, a1, -SHIFT);
119 test_srlc_on(a0, a1); 125 test_srlc_on(a0, a1);
120 test_srlv(a0, a1, -SHIFT); 126 test_srlv(a0, a1, -SHIFT);
121 test_srac_on(a0, a1); 127 test_srac_on(a0, a1);
122 test_srav(a0, a1, -SHIFT); 128 test_srav(a0, a1, -SHIFT);
129
130 test_sllc_add(a0, a1);
131 test_sllv_add(a0, a1, ADD_INIT);
132 test_srlc_add(a0, a1);
133 test_srlv_add(a0, a1, ADD_INIT);
134 test_srac_add(a0, a1);
135 test_srav_add(a0, a1, ADD_INIT);
136
137 test_sllc_and(a0, a1);
138 test_sllv_and(a0, a1, BIT_MASK);
139 test_srlc_and(a0, a1);
140 test_srlv_and(a0, a1, BIT_MASK);
141 test_srac_and(a0, a1);
142 test_srav_and(a0, a1, BIT_MASK);
143
123 test_pack2(p2, a1); 144 test_pack2(p2, a1);
124 test_unpack2(a0, p2); 145 test_unpack2(a0, p2);
125 test_pack2_swap(p2, a1); 146 test_pack2_swap(p2, a1);
126 test_unpack2_swap(a0, p2); 147 test_unpack2_swap(a0, p2);
127 test_pack4(p4, a1); 148 test_pack4(p4, a1);
362 test_srav(a0, a1, -SHIFT); 383 test_srav(a0, a1, -SHIFT);
363 for (int i=0; i<ARRLEN; i++) { 384 for (int i=0; i<ARRLEN; i++) {
364 errn += verify("test_srav_on: ", i, a0[i], (short)((short)(ADD_INIT+i)>>(-SHIFT))); 385 errn += verify("test_srav_on: ", i, a0[i], (short)((short)(ADD_INIT+i)>>(-SHIFT)));
365 } 386 }
366 387
388 test_sllc_add(a0, a1);
389 for (int i=0; i<ARRLEN; i++) {
390 errn += verify("test_sllc_add: ", i, a0[i], (short)(((short)(ADD_INIT+i) + ADD_INIT)<<VALUE));
391 }
392 test_sllv_add(a0, a1, ADD_INIT);
393 for (int i=0; i<ARRLEN; i++) {
394 errn += verify("test_sllv_add: ", i, a0[i], (short)(((short)(ADD_INIT+i) + ADD_INIT)<<VALUE));
395 }
396
397 test_srlc_add(a0, a1);
398 for (int i=0; i<ARRLEN; i++) {
399 errn += verify("test_srlc_add: ", i, a0[i], (short)(((short)(ADD_INIT+i) + ADD_INIT)>>>VALUE));
400 }
401 test_srlv_add(a0, a1, ADD_INIT);
402 for (int i=0; i<ARRLEN; i++) {
403 errn += verify("test_srlv_add: ", i, a0[i], (short)(((short)(ADD_INIT+i) + ADD_INIT)>>>VALUE));
404 }
405
406 test_srac_add(a0, a1);
407 for (int i=0; i<ARRLEN; i++) {
408 errn += verify("test_srac_add: ", i, a0[i], (short)(((short)(ADD_INIT+i) + ADD_INIT)>>VALUE));
409 }
410 test_srav_add(a0, a1, ADD_INIT);
411 for (int i=0; i<ARRLEN; i++) {
412 errn += verify("test_srav_add: ", i, a0[i], (short)(((short)(ADD_INIT+i) + ADD_INIT)>>VALUE));
413 }
414
415 test_sllc_and(a0, a1);
416 for (int i=0; i<ARRLEN; i++) {
417 errn += verify("test_sllc_and: ", i, a0[i], (short)(((short)(ADD_INIT+i) & BIT_MASK)<<VALUE));
418 }
419 test_sllv_and(a0, a1, BIT_MASK);
420 for (int i=0; i<ARRLEN; i++) {
421 errn += verify("test_sllv_and: ", i, a0[i], (short)(((short)(ADD_INIT+i) & BIT_MASK)<<VALUE));
422 }
423
424 test_srlc_and(a0, a1);
425 for (int i=0; i<ARRLEN; i++) {
426 errn += verify("test_srlc_and: ", i, a0[i], (short)(((short)(ADD_INIT+i) & BIT_MASK)>>>VALUE));
427 }
428 test_srlv_and(a0, a1, BIT_MASK);
429 for (int i=0; i<ARRLEN; i++) {
430 errn += verify("test_srlv_and: ", i, a0[i], (short)(((short)(ADD_INIT+i) & BIT_MASK)>>>VALUE));
431 }
432
433 test_srac_and(a0, a1);
434 for (int i=0; i<ARRLEN; i++) {
435 errn += verify("test_srac_and: ", i, a0[i], (short)(((short)(ADD_INIT+i) & BIT_MASK)>>VALUE));
436 }
437 test_srav_and(a0, a1, BIT_MASK);
438 for (int i=0; i<ARRLEN; i++) {
439 errn += verify("test_srav_and: ", i, a0[i], (short)(((short)(ADD_INIT+i) & BIT_MASK)>>VALUE));
440 }
441
367 test_pack2(p2, a1); 442 test_pack2(p2, a1);
368 for (int i=0; i<ARRLEN/2; i++) { 443 for (int i=0; i<ARRLEN/2; i++) {
369 errn += verify("test_pack2: ", i, p2[i], ((int)(ADD_INIT+2*i) & 0xFFFF) | ((int)(ADD_INIT+2*i+1) << 16)); 444 errn += verify("test_pack2: ", i, p2[i], ((int)(ADD_INIT+2*i) & 0xFFFF) | ((int)(ADD_INIT+2*i+1) << 16));
370 } 445 }
371 for (int i=0; i<ARRLEN; i++) { 446 for (int i=0; i<ARRLEN; i++) {
760 end = System.currentTimeMillis(); 835 end = System.currentTimeMillis();
761 System.out.println("test_srav_on: " + (end - start)); 836 System.out.println("test_srav_on: " + (end - start));
762 837
763 start = System.currentTimeMillis(); 838 start = System.currentTimeMillis();
764 for (int i=0; i<ITERS; i++) { 839 for (int i=0; i<ITERS; i++) {
840 test_sllc_add(a0, a1);
841 }
842 end = System.currentTimeMillis();
843 System.out.println("test_sllc_add: " + (end - start));
844 start = System.currentTimeMillis();
845 for (int i=0; i<ITERS; i++) {
846 test_sllv_add(a0, a1, ADD_INIT);
847 }
848 end = System.currentTimeMillis();
849 System.out.println("test_sllv_add: " + (end - start));
850
851 start = System.currentTimeMillis();
852 for (int i=0; i<ITERS; i++) {
853 test_srlc_add(a0, a1);
854 }
855 end = System.currentTimeMillis();
856 System.out.println("test_srlc_add: " + (end - start));
857 start = System.currentTimeMillis();
858 for (int i=0; i<ITERS; i++) {
859 test_srlv_add(a0, a1, ADD_INIT);
860 }
861 end = System.currentTimeMillis();
862 System.out.println("test_srlv_add: " + (end - start));
863
864 start = System.currentTimeMillis();
865 for (int i=0; i<ITERS; i++) {
866 test_srac_add(a0, a1);
867 }
868 end = System.currentTimeMillis();
869 System.out.println("test_srac_add: " + (end - start));
870 start = System.currentTimeMillis();
871 for (int i=0; i<ITERS; i++) {
872 test_srav_add(a0, a1, ADD_INIT);
873 }
874 end = System.currentTimeMillis();
875 System.out.println("test_srav_add: " + (end - start));
876
877 start = System.currentTimeMillis();
878 for (int i=0; i<ITERS; i++) {
879 test_sllc_and(a0, a1);
880 }
881 end = System.currentTimeMillis();
882 System.out.println("test_sllc_and: " + (end - start));
883 start = System.currentTimeMillis();
884 for (int i=0; i<ITERS; i++) {
885 test_sllv_and(a0, a1, BIT_MASK);
886 }
887 end = System.currentTimeMillis();
888 System.out.println("test_sllv_and: " + (end - start));
889
890 start = System.currentTimeMillis();
891 for (int i=0; i<ITERS; i++) {
892 test_srlc_and(a0, a1);
893 }
894 end = System.currentTimeMillis();
895 System.out.println("test_srlc_and: " + (end - start));
896 start = System.currentTimeMillis();
897 for (int i=0; i<ITERS; i++) {
898 test_srlv_and(a0, a1, BIT_MASK);
899 }
900 end = System.currentTimeMillis();
901 System.out.println("test_srlv_and: " + (end - start));
902
903 start = System.currentTimeMillis();
904 for (int i=0; i<ITERS; i++) {
905 test_srac_and(a0, a1);
906 }
907 end = System.currentTimeMillis();
908 System.out.println("test_srac_and: " + (end - start));
909 start = System.currentTimeMillis();
910 for (int i=0; i<ITERS; i++) {
911 test_srav_and(a0, a1, BIT_MASK);
912 }
913 end = System.currentTimeMillis();
914 System.out.println("test_srav_and: " + (end - start));
915
916 start = System.currentTimeMillis();
917 for (int i=0; i<ITERS; i++) {
765 test_pack2(p2, a1); 918 test_pack2(p2, a1);
766 } 919 }
767 end = System.currentTimeMillis(); 920 end = System.currentTimeMillis();
768 System.out.println("test_pack2: " + (end - start)); 921 System.out.println("test_pack2: " + (end - start));
769 start = System.currentTimeMillis(); 922 start = System.currentTimeMillis();
966 static void test_sllv(short[] a0, short[] a1, int b) { 1119 static void test_sllv(short[] a0, short[] a1, int b) {
967 for (int i = 0; i < a0.length; i+=1) { 1120 for (int i = 0; i < a0.length; i+=1) {
968 a0[i] = (short)(a1[i]<<b); 1121 a0[i] = (short)(a1[i]<<b);
969 } 1122 }
970 } 1123 }
1124 static void test_sllc_add(short[] a0, short[] a1) {
1125 for (int i = 0; i < a0.length; i+=1) {
1126 a0[i] = (short)((a1[i] + ADD_INIT)<<VALUE);
1127 }
1128 }
1129 static void test_sllv_add(short[] a0, short[] a1, int b) {
1130 for (int i = 0; i < a0.length; i+=1) {
1131 a0[i] = (short)((a1[i] + b)<<VALUE);
1132 }
1133 }
1134 static void test_sllc_and(short[] a0, short[] a1) {
1135 for (int i = 0; i < a0.length; i+=1) {
1136 a0[i] = (short)((a1[i] & BIT_MASK)<<VALUE);
1137 }
1138 }
1139 static void test_sllv_and(short[] a0, short[] a1, int b) {
1140 for (int i = 0; i < a0.length; i+=1) {
1141 a0[i] = (short)((a1[i] & b)<<VALUE);
1142 }
1143 }
971 1144
972 static void test_srlc(short[] a0, short[] a1) { 1145 static void test_srlc(short[] a0, short[] a1) {
973 for (int i = 0; i < a0.length; i+=1) { 1146 for (int i = 0; i < a0.length; i+=1) {
974 a0[i] = (short)(a1[i]>>>VALUE); 1147 a0[i] = (short)(a1[i]>>>VALUE);
975 } 1148 }
992 static void test_srlv(short[] a0, short[] a1, int b) { 1165 static void test_srlv(short[] a0, short[] a1, int b) {
993 for (int i = 0; i < a0.length; i+=1) { 1166 for (int i = 0; i < a0.length; i+=1) {
994 a0[i] = (short)(a1[i]>>>b); 1167 a0[i] = (short)(a1[i]>>>b);
995 } 1168 }
996 } 1169 }
1170 static void test_srlc_add(short[] a0, short[] a1) {
1171 for (int i = 0; i < a0.length; i+=1) {
1172 a0[i] = (short)((a1[i] + ADD_INIT)>>>VALUE);
1173 }
1174 }
1175 static void test_srlv_add(short[] a0, short[] a1, int b) {
1176 for (int i = 0; i < a0.length; i+=1) {
1177 a0[i] = (short)((a1[i] + b)>>>VALUE);
1178 }
1179 }
1180 static void test_srlc_and(short[] a0, short[] a1) {
1181 for (int i = 0; i < a0.length; i+=1) {
1182 a0[i] = (short)((a1[i] & BIT_MASK)>>>VALUE);
1183 }
1184 }
1185 static void test_srlv_and(short[] a0, short[] a1, int b) {
1186 for (int i = 0; i < a0.length; i+=1) {
1187 a0[i] = (short)((a1[i] & b)>>>VALUE);
1188 }
1189 }
997 1190
998 static void test_srac(short[] a0, short[] a1) { 1191 static void test_srac(short[] a0, short[] a1) {
999 for (int i = 0; i < a0.length; i+=1) { 1192 for (int i = 0; i < a0.length; i+=1) {
1000 a0[i] = (short)(a1[i]>>VALUE); 1193 a0[i] = (short)(a1[i]>>VALUE);
1001 } 1194 }
1016 } 1209 }
1017 } 1210 }
1018 static void test_srav(short[] a0, short[] a1, int b) { 1211 static void test_srav(short[] a0, short[] a1, int b) {
1019 for (int i = 0; i < a0.length; i+=1) { 1212 for (int i = 0; i < a0.length; i+=1) {
1020 a0[i] = (short)(a1[i]>>b); 1213 a0[i] = (short)(a1[i]>>b);
1214 }
1215 }
1216 static void test_srac_add(short[] a0, short[] a1) {
1217 for (int i = 0; i < a0.length; i+=1) {
1218 a0[i] = (short)((a1[i] + ADD_INIT)>>VALUE);
1219 }
1220 }
1221 static void test_srav_add(short[] a0, short[] a1, int b) {
1222 for (int i = 0; i < a0.length; i+=1) {
1223 a0[i] = (short)((a1[i] + b)>>VALUE);
1224 }
1225 }
1226 static void test_srac_and(short[] a0, short[] a1) {
1227 for (int i = 0; i < a0.length; i+=1) {
1228 a0[i] = (short)((a1[i] & BIT_MASK)>>VALUE);
1229 }
1230 }
1231 static void test_srav_and(short[] a0, short[] a1, int b) {
1232 for (int i = 0; i < a0.length; i+=1) {
1233 a0[i] = (short)((a1[i] & b)>>VALUE);
1021 } 1234 }
1022 } 1235 }
1023 1236
1024 static void test_pack2(int[] p2, short[] a1) { 1237 static void test_pack2(int[] p2, short[] a1) {
1025 if (p2.length*2 > a1.length) return; 1238 if (p2.length*2 > a1.length) return;