4 public class SimdTests {
5 public static unsafe int test_vector2ul_slr () {
6 Vector2ul a = new Vector2ul (1, 6);
14 public static unsafe int test_vector2l_cmp_gt () {
15 Vector2l a = new Vector2l (10, 5);
16 Vector2l b = new Vector2l (-1, 5);
18 Vector2l c = Vector2l.CompareGreaterThan (a, b);
27 public static unsafe int test_vector2l_cmp_eq () {
28 Vector2l a = new Vector2l (0xFF, 5);
29 Vector2l b = new Vector2l (0xFF000000FFL, 5);
31 Vector2l c = Vector2l.CompareEqual (a, b);
40 public static unsafe int test_vector2l_srl () {
41 Vector2l a = new Vector2l (1, 6);
43 Vector2l c = Vector2l.ShiftRightLogic (a, 1);
52 public static unsafe int test_vector2l_unpack_high () {
53 Vector2l a = new Vector2l (1, 6);
54 Vector2l b = new Vector2l (3, 4);
56 Vector2l c = Vector2l.UnpackHigh (a, b);
65 public static unsafe int test_vector2l_unpack_low () {
66 Vector2l a = new Vector2l (1, 6);
67 Vector2l b = new Vector2l (3, 4);
69 Vector2l c = Vector2l.UnpackLow (a, b);
78 public static unsafe int test_vector2l_xor () {
79 Vector2l a = new Vector2l (1, 6);
80 Vector2l b = new Vector2l (3, 4);
91 public static unsafe int test_vector2l_or () {
92 Vector2l a = new Vector2l (1, 6);
93 Vector2l b = new Vector2l (3, 4);
104 public static unsafe int test_vector2l_and () {
105 Vector2l a = new Vector2l (1, 6);
106 Vector2l b = new Vector2l (3, 4);
117 public static unsafe int test_vector2l_shl() {
118 Vector2l a = new Vector2l (1, 6);
128 public static unsafe int test_vector2l_sub() {
129 Vector2l a = new Vector2l (1, 6);
130 Vector2l b = new Vector2l (3, 4);
141 public static unsafe int test_vector2l_add () {
142 Vector2l a = new Vector2l (1, 2);
143 Vector2l b = new Vector2l (3, 4);
154 public static unsafe int test_0_vector2d_dup () {
155 Vector2d a = new Vector2d (3, 2);
157 Vector2d c = Vector2d.Duplicate (a);
166 public static unsafe int test_0_vector2d_cmp_eq () {
167 Vector2d a = new Vector2d (3, 2);
168 Vector2d b = new Vector2d (3, 4);
170 Vector4ui c = (Vector4ui)Vector2d.CompareEqual (a, b);
172 if (c.X != 0xFFFFFFFF)
174 if (c.Y != 0xFFFFFFFF)
183 public static unsafe int test_0_vector2d_unpack_low () {
184 Vector2d a = new Vector2d (1, 2);
185 Vector2d b = new Vector2d (4, 5);
187 Vector2d c = Vector2d.InterleaveLow (a, b);
196 public static unsafe int test_0_vector2d_unpack_high () {
197 Vector2d a = new Vector2d (1, 2);
198 Vector2d b = new Vector2d (4, 5);
200 Vector2d c = Vector2d.InterleaveHigh (a, b);
208 public static unsafe int test_0_vector2d_addsub () {
209 Vector2d a = new Vector2d (1, 2);
210 Vector2d b = new Vector2d (4, 1);
212 Vector2d c = Vector2d.AddSub (a, b);
220 public static unsafe int test_0_vector2d_hsub () {
221 Vector2d a = new Vector2d (1, 2);
222 Vector2d b = new Vector2d (4, 1);
224 Vector2d c = Vector2d.HorizontalSub (a, b);
233 public static unsafe int test_0_vector2d_hadd () {
234 Vector2d a = new Vector2d (1, 2);
235 Vector2d b = new Vector2d (4, 0);
237 Vector2d c = Vector2d.HorizontalAdd (a, b);
246 public static unsafe int test_0_vector2d_min () {
247 Vector2d a = new Vector2d (1, 2);
248 Vector2d b = new Vector2d (4, 0);
250 Vector2d c = Vector2d.Min (a, b);
259 public static unsafe int test_0_vector2d_max () {
260 Vector2d a = new Vector2d (1, 2);
261 Vector2d b = new Vector2d (4, 0);
263 Vector2d c = Vector2d.Max (a, b);
273 public static unsafe int test_0_vector2d_andnot () {
274 Vector2d a = new Vector2d (1, 2);
275 Vector2d b = new Vector2d (3, 4);
277 Vector4ui c = (Vector4ui)Vector2d.AndNot (a, b);
281 if (c.Y != 1074266112)
290 public static unsafe int test_0_vector2d_div () {
291 Vector2d a = new Vector2d (1, 2);
292 Vector2d b = new Vector2d (4, 5);
303 public static unsafe int test_0_vector2d_mul () {
304 Vector2d a = new Vector2d (1, 2);
305 Vector2d b = new Vector2d (3, 5);
315 public static unsafe int test_0_vector2d_sub () {
316 Vector2d a = new Vector2d (1, 2);
317 Vector2d b = new Vector2d (3, 5);
327 public static unsafe int test_0_vector2d_add () {
328 Vector2d a = new Vector2d (1, 2);
329 Vector2d b = new Vector2d (3, 4);
339 public static unsafe int test_0_vector2d_xor () {
340 Vector2d a = new Vector2d (1, 2);
341 Vector2d b = new Vector2d (3, 4);
343 Vector4ui c = (Vector4ui)(a ^ b);
347 if (c.Y != 2146959360)
356 public static unsafe int test_0_vector2d_or () {
357 Vector2d a = new Vector2d (1, 2);
358 Vector2d b = new Vector2d (3, 4);
360 Vector4ui c = (Vector4ui)(a | b);
364 if (c.Y != 2146959360)
368 if (c.W != 1074790400)
373 public static unsafe int test_0_vector2d_and () {
374 Vector2d a = new Vector2d (1, 2);
375 Vector2d b = new Vector2d (3, 4);
377 Vector4ui c = (Vector4ui)(a & b);
385 if (c.W != 1073741824)
390 public static unsafe int test_vector8s_pack_signed_sat () {
391 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
392 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
394 Vector16sb c = Vector8s.PackWithSignedSaturation (a, b);
404 public static unsafe int test_vector16sb_sub_sat () {
405 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
406 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
408 Vector16sb c = Vector16sb.SubWithSaturation (a, b);
429 public static unsafe int test_vector16sb_add_sat () {
430 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
431 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
433 Vector16sb c = Vector16sb.AddWithSaturation (a, b);
454 public static unsafe int test_vector16sb_cmp_gt () {
455 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
456 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
458 Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
478 public static int test_0_vector4ui_pack_with_sat () {
479 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
480 Vector4ui b = new Vector4ui (5,6,7,8);
482 Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
503 public static int test_0_vector8us_pack_with_sat () {
504 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
505 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
506 Vector16b c = Vector8us.SignedPackWithUnsignedSaturation (a, b);
521 public static int test_0_vector8us_mul_high () {
522 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
523 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
524 Vector8us c = Vector8us.MultiplyStoreHigh (a, b);
545 public static int test_0_vector8us_cmpeq () {
546 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
547 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
548 Vector8us c = Vector8us.CompareEqual (a, b);
570 public static int test_0_vector4ui_cmpeq () {
571 Vector4ui a = new Vector4ui (6,1,6,3);
572 Vector4ui b = new Vector4ui (3,4,6,7);
573 Vector4ui c = Vector4ui.CompareEqual (a, b);
579 if (c.Z != 0xFFFFFFFF)
586 public static int test_0_vector4ui_shuffle () {
587 Vector4ui a = new Vector4ui (1,2,3,4);
588 Vector4ui c = Vector4ui.Shuffle (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
601 public static int test_0_vector4ui_extract_mask () {
602 Vector4ui a = new Vector4ui (0xFF00FF00,0x0F0FAA99,0,0);
603 int c = Vector4ui.ExtractByteMask (a);
610 public static int test_0_vector4ui_min () {
611 Vector4ui a = new Vector4ui (6,1,6,3);
612 Vector4ui b = new Vector4ui (3,4,6,7);
613 Vector4ui c = Vector4ui.Min (a, b);
626 public static int test_0_vector4ui_max () {
627 Vector4ui a = new Vector4ui (6,1,6,3);
628 Vector4ui b = new Vector4ui (3,4,6,7);
629 Vector4ui c = Vector4ui.Max (a, b);
642 public static int vector16b_cmpeq () {
643 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
644 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
645 Vector16b c = Vector16b.CompareEqual (a, b);
683 public static int vector16b_sum_abs_diff () {
684 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
685 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
686 Vector8us c = Vector16b.SumOfAbsoluteDifferences (a, b);
708 public static int test_0_vector16b_extract_mask () {
709 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
710 int c = Vector16b.ExtractByteMask (a);
717 public static int test_0_vector16b_min () {
718 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
719 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
720 Vector16b c = Vector16b.Min (a, b);
757 public static int test_0_vector16b_max () {
758 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
759 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
760 Vector16b c = Vector16b.Max (a, b);
796 public static int test_0_vector16b_avg () {
797 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
798 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
799 Vector16b c = Vector16b.Average (a, b);
837 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
838 Vector8us res = new Vector8us ();
839 byte *a = (byte*)&va;
840 byte *b = (byte*)&vb;
843 for (int i = 0; i < 8; ++i)
844 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
845 res.V0 = (ushort)tmp;
848 for (int i = 0; i < 8; ++i)
849 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
850 res.V4 = (ushort)tmp;
854 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
855 public static int test_2_local_simplifier_regression_other_blocks () {
856 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
857 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
858 Vector8us res = bad_method_regression_2 (a,b);
859 return (int)res.V0 + res.V4;
862 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
863 Vector8us res = new Vector8us ();
864 byte *a = (byte*)&va;
865 byte *b = (byte*)&vb;
866 *((ushort*)&res) = 10;
877 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
878 public static int test_10_local_simplifier_regression_first_block () {
879 Vector16b a = new Vector16b ();
880 Vector16b b = new Vector16b ();
881 Vector8us res = bad_method_regression (a,b);
886 public static int test_0_vecto8us_extract_mask () {
887 Vector8us a = new Vector8us (0xF0F0, 0x700F, 0xAABB, 0x0000, 0x00F0, 0xF0F0, 0, 0);
888 int c = Vector8us.ExtractByteMask (a);
895 public static int test_0_vecto8us_shuffle_low () {
896 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
897 Vector8us c = Vector8us.ShuffleLow (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
918 public static int test_0_vecto8us_shuffle_high () {
919 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
920 Vector8us c = Vector8us.ShuffleHigh (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
942 public static int test_0_vecto8us_max () {
943 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
944 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
945 Vector8us c = Vector8us.Max (a, b);
967 public static int test_0_vecto8us_min () {
968 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
969 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
970 Vector8us c = Vector8us.Min (a, b);
991 public static int test_0_vecto8us_avg () {
992 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
993 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
994 Vector8us c = Vector8us.Average (a, b);
1015 static void store_helper (ref Vector4f x) {
1017 k = new Vector4f(9,9,9,9);
1021 public static int test_0_vector4f_byref_store ()
1024 k = new Vector4f(1,2,3,4);
1025 store_helper (ref k);
1031 public static int test_0_vector4f_init_array_element ()
1033 Vector4f[] v = new Vector4f[1];
1034 v[0] = new Vector4f(9,9,9,9);
1040 public static int test_0_vector4f_dup_high () {
1041 Vector4f a = new Vector4f (1, 2, 3, 4);
1042 Vector4f c = Vector4f.DuplicateHigh(a);
1055 public static int test_0_vector4f_dup_low () {
1056 Vector4f a = new Vector4f (1, 2, 3, 4);
1057 Vector4f c = Vector4f.DuplicateLow (a);
1071 public static int test_0_vector4f_interleave_high () {
1072 Vector4f a = new Vector4f (1, 2, 3, 4);
1073 Vector4f b = new Vector4f (5, 6, 7, 8);
1074 Vector4f c = Vector4f.InterleaveHigh (a, b);
1087 public static int test_0_vector4f_interleave_low () {
1088 Vector4f a = new Vector4f (1, 2, 3, 4);
1089 Vector4f b = new Vector4f (5, 6, 7, 8);
1090 Vector4f c = Vector4f.InterleaveLow (a, b);
1103 public static int test_0_vector4f_rcp () {
1104 Vector4f a = new Vector4f (1, 2, 4, 8);
1105 Vector4f c = Vector4f.Reciprocal (a);
1107 //Test with ranges due to the terrible precision.
1108 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
1110 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
1112 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
1114 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
1119 public static int test_0_vector4f_xor () {
1120 Vector4f a = new Vector4f (1, 2, 3, 4);
1121 Vector4f b = new Vector4f (1, 3, 3, 8);
1124 if (((Vector4ui)c).X != 0)
1126 if (((Vector4ui)c).Y != 0x400000)
1128 if (((Vector4ui)c).Z != 0)
1130 if (((Vector4ui)c).W != 0x1800000)
1135 public static int test_0_vector4f_or () {
1136 Vector4f a = new Vector4f (1, 2, 3, 4);
1137 Vector4f b = new Vector4f (1, 3, 3, 8);
1140 if (((Vector4ui)c).X != 0x3F800000)
1142 if (((Vector4ui)c).Y != 0x40400000)
1144 if (((Vector4ui)c).Z != 0x40400000)
1146 if (((Vector4ui)c).W != 0x41800000)
1150 public static int test_0_vector4f_andn () {
1151 Vector4f a = new Vector4f (1, 2, 3, 4);
1152 Vector4f b = new Vector4f (1, 3, 3, 8);
1153 Vector4f c = Vector4f.AndNot (a ,b);
1155 if (((Vector4ui)c).X != 0)
1157 if (((Vector4ui)c).Y != 0x400000)
1159 if (((Vector4ui)c).Z != 0)
1161 if (((Vector4ui)c).W != 0x1000000)
1166 public static int test_0_vector4f_and () {
1167 Vector4f a = new Vector4f (1, 2, 3, 4);
1168 Vector4f b = new Vector4f (1, 3, 3, 8);
1171 if (((Vector4ui)c).X != 0x3F800000)
1173 if (((Vector4ui)c).Y != 0x40000000)
1175 if (((Vector4ui)c).Z != 0x40400000)
1177 if (((Vector4ui)c).W != 0x40000000)
1182 public static int test_0_vector4f_cmpord () {
1183 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1184 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1185 Vector4f c = Vector4f.CompareOrdered (a, b);
1187 if (((Vector4ui)c).X != 0)
1189 if (((Vector4ui)c).Y != 0)
1191 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1193 if (((Vector4ui)c).W != 0xFFFFFFFF)
1198 public static int test_0_vector4f_cmpnle () {
1199 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1200 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1201 Vector4f c = Vector4f.CompareNotLessEqual (a, b);
1203 if (((Vector4ui)c).X != 0xFFFFFFFF)
1205 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1207 if (((Vector4ui)c).Z != 0)
1209 if (((Vector4ui)c).W != 0)
1214 public static int test_0_vector4f_cmpnlt () {
1215 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1216 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1217 Vector4f c = Vector4f.CompareNotLessThan (a, b);
1219 if (((Vector4ui)c).X != 0xFFFFFFFF)
1221 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1223 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1225 if (((Vector4ui)c).W != 0)
1230 public static int test_0_vector4f_cmpneq () {
1231 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1232 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1233 Vector4f c = Vector4f.CompareNotEqual (a, b);
1235 if (((Vector4ui)c).X != 0xFFFFFFFF)
1237 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1239 if (((Vector4ui)c).Z != 0)
1241 if (((Vector4ui)c).W != 0xFFFFFFFF)
1246 public static int test_0_vector4f_cmpunord () {
1247 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1248 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1249 Vector4f c = Vector4f.CompareUnordered (a, b);
1251 if (((Vector4ui)c).X != 0xFFFFFFFF)
1253 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1255 if (((Vector4ui)c).Z != 0)
1257 if (((Vector4ui)c).W != 0)
1262 public static int test_0_vector4f_cmple () {
1263 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1264 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1265 Vector4f c = Vector4f.CompareLessEqual (a, b);
1267 if (((Vector4ui)c).X != 0)
1269 if (((Vector4ui)c).Y != 0)
1271 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1273 if (((Vector4ui)c).W != 0xFFFFFFFF)
1278 public static int test_0_vector4f_cmplt () {
1279 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1280 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1281 Vector4f c = Vector4f.CompareLessThan (a, b);
1283 if (((Vector4ui)c).X != 0)
1285 if (((Vector4ui)c).Y != 0)
1287 if (((Vector4ui)c).Z != 0)
1289 if (((Vector4ui)c).W != 0xFFFFFFFF)
1294 public static int test_0_vector4f_cmpeq () {
1295 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
1296 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
1297 Vector4f c = Vector4f.CompareEqual (a, b);
1299 if (((Vector4ui)c).X != 0)
1301 if (((Vector4ui)c).Y != 0)
1303 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1305 if (((Vector4ui)c).W != 0)
1310 public static int test_0_vector4ui_sar () {
1311 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1313 Vector4ui c = Vector4ui.ShiftRightArithmetic (a, 2);
1315 if (c.X != 0xFC000000)
1326 public static int test_0_vector4ui_unpack_high () {
1327 Vector4ui a = new Vector4ui (1,2,3,4);
1328 Vector4ui b = new Vector4ui (5,6,7,8);
1330 Vector4ui c = Vector4ui.UnpackHigh(a, b);
1343 public static int test_0_vector4ui_unpack_low () {
1344 Vector4ui a = new Vector4ui (1,2,3,4);
1345 Vector4ui b = new Vector4ui (5,6,7,8);
1347 Vector4ui c = Vector4ui.UnpackLow (a, b);
1360 public static int test_0_vector4ui_xor () {
1361 Vector4ui a = new Vector4ui (1,2,3,4);
1362 Vector4ui b = new Vector4ui (7,5,3,1);
1364 Vector4ui c = a ^ b;
1377 public static int test_0_vector4ui_or () {
1378 Vector4ui a = new Vector4ui (1,2,3,4);
1379 Vector4ui b = new Vector4ui (7,5,3,1);
1381 Vector4ui c = a | b;
1393 public static int test_0_vector4ui_and () {
1394 Vector4ui a = new Vector4ui (1,2,3,4);
1395 Vector4ui b = new Vector4ui (7,5,3,1);
1397 Vector4ui c = a & b;
1410 public static int test_0_vector4ui_shr () {
1411 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1413 Vector4ui c = a >> 2;
1415 if (c.X != 0x3C000000)
1426 public static int test_0_vector4ui_shl () {
1427 Vector4ui a = new Vector4ui (10,20,3,40);
1429 Vector4ui c = a << 2;
1442 public static int test_0_vector4ui_mul () {
1443 Vector4ui a = new Vector4ui (0x8888,20,3,40);
1444 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1446 Vector4ui c = a * b;
1448 if (c.X != 0xffff7800)
1458 public static int test_0_vector4ui_sub () {
1459 Vector4ui a = new Vector4ui (1,20,3,40);
1460 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1462 Vector4ui c = a - b;
1464 if (c.X != 0xff0101)
1475 public static int test_0_vector4ui_add () {
1476 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
1477 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1479 Vector4ui c = a + b;
1481 if (c.X != 0xfe01fe00)
1493 static int test_0_vector4ui_accessors () {
1494 Vector4ui a = new Vector4ui (1,2,3,4);
1520 static int test_0_vector8us_sub_sat () {
1521 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
1522 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1523 Vector8us c = Vector8us.SubWithSaturation (a, b);
1544 static int test_0_vector8us_add_sat () {
1545 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1546 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1547 Vector8us c = Vector8us.AddWithSaturation (a, b);
1568 static int test_0_vector8us_unpack_low () {
1569 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1570 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1571 Vector8us c = Vector8us.UnpackLow (a, b);
1593 static int test_0_vector8us_shift_left () {
1594 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1596 Vector8us c = a << amt;
1607 static int test_0_vector8us_shift_right_arithmetic () {
1608 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1610 Vector8us c = Vector8us.ShiftRightArithmetic (a, amt);
1621 static int test_0_vector8us_shift_variable_offset () {
1623 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1625 Vector8us c = b >> off;
1642 static int test_0_vector8us_shift_operand_is_live_after_op () {
1643 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1645 Vector8us c = b >> 2;
1661 static int test_0_vector8us_shr_constant () {
1662 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1663 Vector8us c = a >> 2;
1674 static int test_0_vector8us_mul () {
1675 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
1676 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
1678 Vector8us c = a * b;
1688 static int test_0_vector8us_add () {
1689 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1690 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
1692 Vector8us c = a + b;
1703 static int test_0_vector8us_sub () {
1704 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
1705 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
1707 Vector8us c = a - b;
1719 static int test_0_vector8us_accessors () {
1720 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1768 static int test_0_vector16b_unpack_high () {
1769 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1770 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1771 Vector16b c = Vector16b.UnpackHigh (a, b);
1792 static int test_0_vector16b_unpack_low () {
1793 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1794 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1795 Vector16b c = Vector16b.UnpackLow (a, b);
1816 static int test_0_vector16b_sub_sat () {
1817 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1818 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1819 Vector16b c = Vector16b.SubWithSaturation (a, b);
1830 static int test_0_vector16b_add_sat () {
1831 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1832 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1833 Vector16b c = Vector16b.AddWithSaturation (a, b);
1844 static int test_0_vector16b_add_ovf () {
1845 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1846 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1847 Vector16b c = a + b;
1858 static int test_0_vector16b_accessors () {
1859 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1946 public static int test_0_accessors () {
1947 Vector4f a = new Vector4f (1, 2, 3, 4);
1959 public static int test_0_packed_add_with_stack_tmp () {
1960 Vector4f a = new Vector4f (1, 2, 3, 4);
1961 Vector4f b = new Vector4f (5, 6, 7, 8);
1962 Vector4f c = new Vector4f (-1, -3, -4, -5);
1963 Vector4f d = a + b + c;
1975 public static int test_0_simple_packed_add () {
1976 Vector4f a = new Vector4f (1, 2, 3, 4);
1977 Vector4f b = new Vector4f (5, 6, 7, 8);
1991 public static int test_0_simple_packed_sub () {
1992 Vector4f a = new Vector4f (1, 2, 3, 4);
1993 Vector4f b = new Vector4f (5, 6, 7, 8);
2006 public static int test_0_simple_packed_mul () {
2007 Vector4f a = new Vector4f (1, 2, 3, 4);
2008 Vector4f b = new Vector4f (5, 6, 7, 8);
2021 public static int test_0_simple_packed_div () {
2022 Vector4f a = new Vector4f (2, 2, 3, 4);
2023 Vector4f b = new Vector4f (20, 10, 33, 12);
2036 public static int test_0_simple_packed_sqrt () {
2037 Vector4f a = new Vector4f (16, 4, 9, 25);
2038 a = Vector4f.Sqrt (a);
2050 public static int test_0_simple_packed_invsqrt () {
2051 Vector4f a = new Vector4f (16, 4, 100, 25);
2052 //this function has VERY low precision
2053 a = Vector4f.InvSqrt (a);
2054 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
2056 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
2058 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
2060 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
2065 public static int test_0_simple_packed_min () {
2066 Vector4f a = new Vector4f (16, -4, 9, 25);
2067 Vector4f b = new Vector4f (5, 3, 9, 0);
2068 Vector4f c = Vector4f.Min (a, b);
2080 public static int test_0_simple_packed_max () {
2081 Vector4f a = new Vector4f (16, -4, 9, 25);
2082 Vector4f b = new Vector4f (5, 3, 9, 0);
2083 Vector4f c = Vector4f.Max (a, b);
2095 public static int test_0_simple_packed_hadd () {
2096 Vector4f a = new Vector4f (5, 5, 6, 6);
2097 Vector4f b = new Vector4f (7, 7, 8, 8);
2098 Vector4f c = Vector4f.HorizontalAdd (a, b);
2110 public static int test_0_simple_packed_hsub () {
2111 Vector4f a = new Vector4f (5, 2, 6, 1);
2112 Vector4f b = new Vector4f (7, 0, 8, 3);
2113 Vector4f c = Vector4f.HorizontalSub (a, b);
2125 public static int test_0_simple_packed_addsub () {
2126 Vector4f a = new Vector4f (5, 2, 6, 1);
2127 Vector4f b = new Vector4f (7, 0, 8, 3);
2128 Vector4f c = Vector4f.AddSub (a, b);
2140 public static int test_0_simple_packed_shuffle () {
2141 Vector4f a = new Vector4f (1, 2, 3, 4);
2142 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2154 public static int test_0_packed_shuffle_with_reg_pressure () {
2155 Vector4f v = new Vector4f (1, 2, 3, 4);
2156 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
2157 if (ff) v = v + v -v ;
2159 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2160 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2161 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2162 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2163 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2171 Vector4f result = r0 + r1 + r2 + r3;
2181 if (result.Y != result.Y)
2186 public static int test_24_regs_pressure_a () {
2187 Vector4f a = new Vector4f (1, 2, 3, 4);
2195 public static int test_54_regs_pressure_b () {
2196 Vector4f a = new Vector4f (1, 2, 3, 4);
2200 Vector4f e = a + b + c;
2201 Vector4f f = d - b + a - c;
2202 Vector4f g = a - d * f - c + b;
2203 Vector4f h = a * b - c + e;
2204 Vector4f i = h - g - f - e - d - c - b - a;
2205 Vector4f j = a + b + c + d + e + f + g + h + i;
2210 public static int test_3_single_block_var_is_properly_promoted () {
2211 Vector4f a = new Vector4f (4, 5, 6, 7);
2215 Vector4f b = new Vector4f (1, 2, 3, 4);
2226 static float float_val = 45f;
2228 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
2229 Vector4f v = new Vector4f (1, 2, 3, 4);
2230 float f = float_val;
2239 public static int Main () {
2240 return TestDriver.RunTests (typeof (SimdTests));