4 public class SimdTests {
5 public static int test_0_accessor_vecto4i () {
6 Vector4i a = new Vector4i (0x70000000, -1, 3, 4);
33 public static int test_0_accessor_vecto4ui () {
34 Vector4ui a = new Vector4ui (0xF0000000, 0xF0000, 3, 4);
36 if (a.X != 0xF0000000)
61 static float use_getter_with_byref (ref Vector4f a) {
65 public static int test_0_accessor_and_byref_var () {
66 Vector4f a = new Vector4f (1, 2, 3, 4);
67 if (use_getter_with_byref (ref a) != 4)
72 public static unsafe int test_0_vector2ul_slr () {
73 Vector2ul a = new Vector2ul (1, 6);
83 public static unsafe int test_0_vector2l_cmp_gt () {
84 Vector2l a = new Vector2l (10, 5);
85 Vector2l b = new Vector2l (-1, 5);
87 Vector2l c = Vector2l.CompareGreaterThan (a, b);
96 public static unsafe int test_0_vector2l_cmp_eq () {
97 Vector2l a = new Vector2l (0xFF, 5);
98 Vector2l b = new Vector2l (0xFF000000FFL, 5);
100 Vector2l c = Vector2l.CompareEqual (a, b);
109 public static unsafe int test_0_vector2l_srl () {
110 Vector2l a = new Vector2l (1, 6);
112 Vector2l c = Vector2l.LogicalRightShift (a, 1);
121 public static unsafe int test_0_vector2l_unpack_high () {
122 Vector2l a = new Vector2l (1, 6);
123 Vector2l b = new Vector2l (3, 4);
125 Vector2l c = Vector2l.UnpackHigh (a, b);
134 public static unsafe int test_0_vector2l_unpack_low () {
135 Vector2l a = new Vector2l (1, 6);
136 Vector2l b = new Vector2l (3, 4);
138 Vector2l c = Vector2l.UnpackLow (a, b);
147 public static unsafe int test_0_vector2l_xor () {
148 Vector2l a = new Vector2l (1, 6);
149 Vector2l b = new Vector2l (3, 4);
160 public static unsafe int test_0_vector2l_or () {
161 Vector2l a = new Vector2l (1, 6);
162 Vector2l b = new Vector2l (3, 4);
173 public static unsafe int test_0_vector2l_and () {
174 Vector2l a = new Vector2l (1, 6);
175 Vector2l b = new Vector2l (3, 4);
186 public static unsafe int test_0_vector2l_shl() {
187 Vector2l a = new Vector2l (1, 6);
197 public static unsafe int test_0_vector2l_sub() {
198 Vector2l a = new Vector2l (1, 6);
199 Vector2l b = new Vector2l (3, 4);
210 public static unsafe int test_0_vector2l_add () {
211 Vector2l a = new Vector2l (1, 2);
212 Vector2l b = new Vector2l (3, 4);
223 public static unsafe int test_0_vector2d_dup () {
224 Vector2d a = new Vector2d (3, 2);
226 Vector2d c = Vector2d.Duplicate (a);
235 public static unsafe int test_0_vector2d_cmp_eq () {
236 Vector2d a = new Vector2d (3, 2);
237 Vector2d b = new Vector2d (3, 4);
239 Vector4ui c = (Vector4ui)Vector2d.CompareEqual (a, b);
241 if (c.X != 0xFFFFFFFF)
243 if (c.Y != 0xFFFFFFFF)
252 public static unsafe int test_0_vector2d_unpack_low () {
253 Vector2d a = new Vector2d (1, 2);
254 Vector2d b = new Vector2d (4, 5);
256 Vector2d c = Vector2d.InterleaveLow (a, b);
265 public static unsafe int test_0_vector2d_unpack_high () {
266 Vector2d a = new Vector2d (1, 2);
267 Vector2d b = new Vector2d (4, 5);
269 Vector2d c = Vector2d.InterleaveHigh (a, b);
277 public static unsafe int test_0_vector2d_addsub () {
278 Vector2d a = new Vector2d (1, 2);
279 Vector2d b = new Vector2d (4, 1);
281 Vector2d c = Vector2d.AddSub (a, b);
289 public static unsafe int test_0_vector2d_hsub () {
290 Vector2d a = new Vector2d (1, 2);
291 Vector2d b = new Vector2d (4, 1);
293 Vector2d c = Vector2d.HorizontalSub (a, b);
302 public static unsafe int test_0_vector2d_hadd () {
303 Vector2d a = new Vector2d (1, 2);
304 Vector2d b = new Vector2d (4, 0);
306 Vector2d c = Vector2d.HorizontalAdd (a, b);
315 public static unsafe int test_0_vector2d_min () {
316 Vector2d a = new Vector2d (1, 2);
317 Vector2d b = new Vector2d (4, 0);
319 Vector2d c = Vector2d.Min (a, b);
328 public static unsafe int test_0_vector2d_max () {
329 Vector2d a = new Vector2d (1, 2);
330 Vector2d b = new Vector2d (4, 0);
332 Vector2d c = Vector2d.Max (a, b);
342 public static unsafe int test_0_vector2d_andnot () {
343 Vector2d a = new Vector2d (1, 2);
344 Vector2d b = new Vector2d (3, 4);
346 Vector4ui c = (Vector4ui)Vector2d.AndNot (a, b);
350 if (c.Y != 1074266112)
359 public static unsafe int test_0_vector2d_div () {
360 Vector2d a = new Vector2d (1, 2);
361 Vector2d b = new Vector2d (4, 5);
372 public static unsafe int test_0_vector2d_mul () {
373 Vector2d a = new Vector2d (1, 2);
374 Vector2d b = new Vector2d (3, 5);
384 public static unsafe int test_0_vector2d_sub () {
385 Vector2d a = new Vector2d (1, 2);
386 Vector2d b = new Vector2d (3, 5);
396 public static unsafe int test_0_vector2d_add () {
397 Vector2d a = new Vector2d (1, 2);
398 Vector2d b = new Vector2d (3, 4);
408 public static unsafe int test_0_vector2d_xor () {
409 Vector2d a = new Vector2d (1, 2);
410 Vector2d b = new Vector2d (3, 4);
412 Vector4ui c = (Vector4ui)(a ^ b);
416 if (c.Y != 2146959360)
425 public static unsafe int test_0_vector2d_or () {
426 Vector2d a = new Vector2d (1, 2);
427 Vector2d b = new Vector2d (3, 4);
429 Vector4ui c = (Vector4ui)(a | b);
433 if (c.Y != 2146959360)
437 if (c.W != 1074790400)
442 public static unsafe int test_0_vector2d_and () {
443 Vector2d a = new Vector2d (1, 2);
444 Vector2d b = new Vector2d (3, 4);
446 Vector4ui c = (Vector4ui)(a & b);
454 if (c.W != 1073741824)
459 public static unsafe int test_vector8s_pack_signed_sat () {
460 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
461 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
463 Vector16sb c = Vector8s.PackWithSignedSaturation (a, b);
473 public static unsafe int test_vector16sb_sub_sat () {
474 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
475 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
477 Vector16sb c = Vector16sb.SubtractWithSaturation (a, b);
498 public static unsafe int test_vector16sb_add_sat () {
499 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
500 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
502 Vector16sb c = Vector16sb.AddWithSaturation (a, b);
523 public static unsafe int test_vector16sb_cmp_gt () {
524 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
525 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
527 Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
547 public static int test_0_vector4ui_pack_with_sat () {
548 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
549 Vector4ui b = new Vector4ui (5,6,7,8);
551 Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
572 public static int test_0_vector8us_pack_with_sat () {
573 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
574 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
575 Vector16b c = Vector8us.SignedPackWithUnsignedSaturation (a, b);
590 public static int test_0_vector8us_mul_high () {
591 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
592 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
593 Vector8us c = Vector8us.MultiplyStoreHigh (a, b);
614 public static int test_0_vector8us_cmpeq () {
615 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
616 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
617 Vector8us c = Vector8us.CompareEqual (a, b);
639 public static int test_0_vector4ui_cmpeq () {
640 Vector4ui a = new Vector4ui (6,1,6,3);
641 Vector4ui b = new Vector4ui (3,4,6,7);
642 Vector4ui c = Vector4ui.CompareEqual (a, b);
648 if (c.Z != 0xFFFFFFFF)
655 public static int test_0_vector4ui_shuffle () {
656 Vector4ui a = new Vector4ui (1,2,3,4);
657 Vector4ui c = Vector4ui.Shuffle (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
670 public static int test_0_vector4ui_extract_mask () {
671 Vector4ui a = new Vector4ui (0xFF00FF00,0x0F0FAA99,0,0);
672 int c = Vector4ui.ExtractByteMask (a);
679 public static int test_0_vector4ui_min () {
680 Vector4ui a = new Vector4ui (6,1,6,3);
681 Vector4ui b = new Vector4ui (3,4,6,7);
682 Vector4ui c = Vector4ui.Min (a, b);
695 public static int test_0_vector4ui_max () {
696 Vector4ui a = new Vector4ui (6,1,6,3);
697 Vector4ui b = new Vector4ui (3,4,6,7);
698 Vector4ui c = Vector4ui.Max (a, b);
711 public static int vector16b_cmpeq () {
712 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
713 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
714 Vector16b c = Vector16b.CompareEqual (a, b);
752 public static int vector16b_sum_abs_diff () {
753 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
754 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
755 Vector8us c = Vector16b.SumOfAbsoluteDifferences (a, b);
777 public static int test_0_vector16b_extract_mask () {
778 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
779 int c = Vector16b.ExtractByteMask (a);
786 public static int test_0_vector16b_min () {
787 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
788 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
789 Vector16b c = Vector16b.Min (a, b);
826 public static int test_0_vector16b_max () {
827 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
828 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
829 Vector16b c = Vector16b.Max (a, b);
865 public static int test_0_vector16b_avg () {
866 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
867 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
868 Vector16b c = Vector16b.Average (a, b);
906 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
907 Vector8us res = new Vector8us ();
908 byte *a = (byte*)&va;
909 byte *b = (byte*)&vb;
912 for (int i = 0; i < 8; ++i)
913 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
914 res.V0 = (ushort)tmp;
917 for (int i = 0; i < 8; ++i)
918 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
919 res.V4 = (ushort)tmp;
923 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
924 public static int test_2_local_simplifier_regression_other_blocks () {
925 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
926 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
927 Vector8us res = bad_method_regression_2 (a,b);
928 return (int)res.V0 + res.V4;
931 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
932 Vector8us res = new Vector8us ();
933 byte *a = (byte*)&va;
934 byte *b = (byte*)&vb;
935 *((ushort*)&res) = 10;
946 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
947 public static int test_10_local_simplifier_regression_first_block () {
948 Vector16b a = new Vector16b ();
949 Vector16b b = new Vector16b ();
950 Vector8us res = bad_method_regression (a,b);
955 public static int test_0_vecto8us_extract_mask () {
956 Vector8us a = new Vector8us (0xF0F0, 0x700F, 0xAABB, 0x0000, 0x00F0, 0xF0F0, 0, 0);
957 int c = Vector8us.ExtractByteMask (a);
964 public static int test_0_vecto8us_shuffle_low () {
965 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
966 Vector8us c = Vector8us.ShuffleLow (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
987 public static int test_0_vecto8us_shuffle_high () {
988 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
989 Vector8us c = Vector8us.ShuffleHigh (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1011 public static int test_0_vecto8us_max () {
1012 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1013 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
1014 Vector8us c = Vector8us.Max (a, b);
1036 public static int test_0_vecto8us_min () {
1037 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
1038 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1039 Vector8us c = Vector8us.Min (a, b);
1060 public static int test_0_vecto8us_avg () {
1061 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1062 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1063 Vector8us c = Vector8us.Average (a, b);
1084 static void store_helper (ref Vector4f x) {
1086 k = new Vector4f(9,9,9,9);
1090 public static int test_0_vector4f_byref_store ()
1093 k = new Vector4f(1,2,3,4);
1094 store_helper (ref k);
1100 public static int test_0_vector4f_init_array_element ()
1102 Vector4f[] v = new Vector4f[1];
1103 v[0] = new Vector4f(9,9,9,9);
1109 public static int test_0_vector4f_dup_high () {
1110 Vector4f a = new Vector4f (1, 2, 3, 4);
1111 Vector4f c = Vector4f.DuplicateHigh(a);
1124 public static int test_0_vector4f_dup_low () {
1125 Vector4f a = new Vector4f (1, 2, 3, 4);
1126 Vector4f c = Vector4f.DuplicateLow (a);
1140 public static int test_0_vector4f_interleave_high () {
1141 Vector4f a = new Vector4f (1, 2, 3, 4);
1142 Vector4f b = new Vector4f (5, 6, 7, 8);
1143 Vector4f c = Vector4f.InterleaveHigh (a, b);
1156 public static int test_0_vector4f_interleave_low () {
1157 Vector4f a = new Vector4f (1, 2, 3, 4);
1158 Vector4f b = new Vector4f (5, 6, 7, 8);
1159 Vector4f c = Vector4f.InterleaveLow (a, b);
1172 public static int test_0_vector4f_rcp () {
1173 Vector4f a = new Vector4f (1, 2, 4, 8);
1174 Vector4f c = Vector4f.Reciprocal (a);
1176 //Test with ranges due to the terrible precision.
1177 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
1179 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
1181 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
1183 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
1188 public static int test_0_vector4f_xor () {
1189 Vector4f a = new Vector4f (1, 2, 3, 4);
1190 Vector4f b = new Vector4f (1, 3, 3, 8);
1193 if (((Vector4ui)c).X != 0)
1195 if (((Vector4ui)c).Y != 0x400000)
1197 if (((Vector4ui)c).Z != 0)
1199 if (((Vector4ui)c).W != 0x1800000)
1204 public static int test_0_vector4f_or () {
1205 Vector4f a = new Vector4f (1, 2, 3, 4);
1206 Vector4f b = new Vector4f (1, 3, 3, 8);
1209 if (((Vector4ui)c).X != 0x3F800000)
1211 if (((Vector4ui)c).Y != 0x40400000)
1213 if (((Vector4ui)c).Z != 0x40400000)
1215 if (((Vector4ui)c).W != 0x41800000)
1219 public static int test_0_vector4f_andn () {
1220 Vector4f a = new Vector4f (1, 2, 3, 4);
1221 Vector4f b = new Vector4f (1, 3, 3, 8);
1222 Vector4f c = Vector4f.AndNot (a ,b);
1224 if (((Vector4ui)c).X != 0)
1226 if (((Vector4ui)c).Y != 0x400000)
1228 if (((Vector4ui)c).Z != 0)
1230 if (((Vector4ui)c).W != 0x1000000)
1235 public static int test_0_vector4f_and () {
1236 Vector4f a = new Vector4f (1, 2, 3, 4);
1237 Vector4f b = new Vector4f (1, 3, 3, 8);
1240 if (((Vector4ui)c).X != 0x3F800000)
1242 if (((Vector4ui)c).Y != 0x40000000)
1244 if (((Vector4ui)c).Z != 0x40400000)
1246 if (((Vector4ui)c).W != 0x40000000)
1251 public static int test_0_vector4f_cmpord () {
1252 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1253 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1254 Vector4f c = Vector4f.CompareOrdered (a, b);
1256 if (((Vector4ui)c).X != 0)
1258 if (((Vector4ui)c).Y != 0)
1260 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1262 if (((Vector4ui)c).W != 0xFFFFFFFF)
1267 public static int test_0_vector4f_cmpnle () {
1268 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1269 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1270 Vector4f c = Vector4f.CompareNotLessEqual (a, b);
1272 if (((Vector4ui)c).X != 0xFFFFFFFF)
1274 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1276 if (((Vector4ui)c).Z != 0)
1278 if (((Vector4ui)c).W != 0)
1283 public static int test_0_vector4f_cmpnlt () {
1284 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1285 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1286 Vector4f c = Vector4f.CompareNotLessThan (a, b);
1288 if (((Vector4ui)c).X != 0xFFFFFFFF)
1290 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1292 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1294 if (((Vector4ui)c).W != 0)
1299 public static int test_0_vector4f_cmpneq () {
1300 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1301 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1302 Vector4f c = Vector4f.CompareNotEqual (a, b);
1304 if (((Vector4ui)c).X != 0xFFFFFFFF)
1306 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1308 if (((Vector4ui)c).Z != 0)
1310 if (((Vector4ui)c).W != 0xFFFFFFFF)
1315 public static int test_0_vector4f_cmpunord () {
1316 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1317 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1318 Vector4f c = Vector4f.CompareUnordered (a, b);
1320 if (((Vector4ui)c).X != 0xFFFFFFFF)
1322 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1324 if (((Vector4ui)c).Z != 0)
1326 if (((Vector4ui)c).W != 0)
1331 public static int test_0_vector4f_cmple () {
1332 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1333 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1334 Vector4f c = Vector4f.CompareLessEqual (a, b);
1336 if (((Vector4ui)c).X != 0)
1338 if (((Vector4ui)c).Y != 0)
1340 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1342 if (((Vector4ui)c).W != 0xFFFFFFFF)
1347 public static int test_0_vector4f_cmplt () {
1348 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1349 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1350 Vector4f c = Vector4f.CompareLessThan (a, b);
1352 if (((Vector4ui)c).X != 0)
1354 if (((Vector4ui)c).Y != 0)
1356 if (((Vector4ui)c).Z != 0)
1358 if (((Vector4ui)c).W != 0xFFFFFFFF)
1363 public static int test_0_vector4f_cmpeq () {
1364 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
1365 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
1366 Vector4f c = Vector4f.CompareEqual (a, b);
1368 if (((Vector4ui)c).X != 0)
1370 if (((Vector4ui)c).Y != 0)
1372 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1374 if (((Vector4ui)c).W != 0)
1379 public static int test_0_vector4ui_sar () {
1380 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1382 Vector4ui c = Vector4ui.ArithmeticRightShift (a, 2);
1384 if (c.X != 0xFC000000)
1395 public static int test_0_vector4ui_unpack_high () {
1396 Vector4ui a = new Vector4ui (1,2,3,4);
1397 Vector4ui b = new Vector4ui (5,6,7,8);
1399 Vector4ui c = Vector4ui.UnpackHigh(a, b);
1412 public static int test_0_vector4ui_unpack_low () {
1413 Vector4ui a = new Vector4ui (1,2,3,4);
1414 Vector4ui b = new Vector4ui (5,6,7,8);
1416 Vector4ui c = Vector4ui.UnpackLow (a, b);
1429 public static int test_0_vector4ui_xor () {
1430 Vector4ui a = new Vector4ui (1,2,3,4);
1431 Vector4ui b = new Vector4ui (7,5,3,1);
1433 Vector4ui c = a ^ b;
1446 public static int test_0_vector4ui_or () {
1447 Vector4ui a = new Vector4ui (1,2,3,4);
1448 Vector4ui b = new Vector4ui (7,5,3,1);
1450 Vector4ui c = a | b;
1462 public static int test_0_vector4ui_and () {
1463 Vector4ui a = new Vector4ui (1,2,3,4);
1464 Vector4ui b = new Vector4ui (7,5,3,1);
1466 Vector4ui c = a & b;
1479 public static int test_0_vector4ui_shr () {
1480 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1482 Vector4ui c = a >> 2;
1484 if (c.X != 0x3C000000)
1495 public static int test_0_vector4ui_shl () {
1496 Vector4ui a = new Vector4ui (10,20,3,40);
1498 Vector4ui c = a << 2;
1511 public static int test_0_vector4ui_mul () {
1512 Vector4ui a = new Vector4ui (0x8888,20,3,40);
1513 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1515 Vector4ui c = a * b;
1517 if (c.X != 0xffff7800)
1527 public static int test_0_vector4ui_sub () {
1528 Vector4ui a = new Vector4ui (1,20,3,40);
1529 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1531 Vector4ui c = a - b;
1533 if (c.X != 0xff0101)
1544 public static int test_0_vector4ui_add () {
1545 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
1546 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1548 Vector4ui c = a + b;
1550 if (c.X != 0xfe01fe00)
1562 static int test_0_vector4ui_accessors () {
1563 Vector4ui a = new Vector4ui (1,2,3,4);
1589 static int test_0_vector8us_sub_sat () {
1590 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
1591 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1592 Vector8us c = Vector8us.SubtractWithSaturation (a, b);
1613 static int test_0_vector8us_add_sat () {
1614 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1615 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1616 Vector8us c = Vector8us.AddWithSaturation (a, b);
1637 static int test_0_vector8us_unpack_low () {
1638 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1639 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1640 Vector8us c = Vector8us.UnpackLow (a, b);
1662 static int test_0_vector8us_shift_left () {
1663 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1665 Vector8us c = a << amt;
1676 static int test_0_vector8us_shift_right_arithmetic () {
1677 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1679 Vector8us c = Vector8us.ArithmeticRightShift (a, amt);
1690 static int test_0_vector8us_shift_variable_offset () {
1692 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1694 Vector8us c = b >> off;
1711 static int test_0_vector8us_shift_operand_is_live_after_op () {
1712 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1714 Vector8us c = b >> 2;
1730 static int test_0_vector8us_shr_constant () {
1731 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1732 Vector8us c = a >> 2;
1743 static int test_0_vector8us_mul () {
1744 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
1745 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
1747 Vector8us c = a * b;
1757 static int test_0_vector8us_add () {
1758 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1759 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
1761 Vector8us c = a + b;
1772 static int test_0_vector8us_sub () {
1773 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
1774 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
1776 Vector8us c = a - b;
1788 static int test_0_vector8us_accessors () {
1789 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1837 static int test_0_vector16b_unpack_high () {
1838 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1839 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1840 Vector16b c = Vector16b.UnpackHigh (a, b);
1861 static int test_0_vector16b_unpack_low () {
1862 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1863 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1864 Vector16b c = Vector16b.UnpackLow (a, b);
1885 static int test_0_vector16b_sub_sat () {
1886 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1887 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1888 Vector16b c = Vector16b.SubtractWithSaturation (a, b);
1899 static int test_0_vector16b_add_sat () {
1900 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1901 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1902 Vector16b c = Vector16b.AddWithSaturation (a, b);
1913 static int test_0_vector16b_add_ovf () {
1914 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1915 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1916 Vector16b c = a + b;
1927 static int test_0_vector16b_accessors () {
1928 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2015 public static int test_0_accessors () {
2016 Vector4f a = new Vector4f (1, 2, 3, 4);
2028 public static int test_0_packed_add_with_stack_tmp () {
2029 Vector4f a = new Vector4f (1, 2, 3, 4);
2030 Vector4f b = new Vector4f (5, 6, 7, 8);
2031 Vector4f c = new Vector4f (-1, -3, -4, -5);
2032 Vector4f d = a + b + c;
2044 public static int test_0_simple_packed_add () {
2045 Vector4f a = new Vector4f (1, 2, 3, 4);
2046 Vector4f b = new Vector4f (5, 6, 7, 8);
2060 public static int test_0_simple_packed_sub () {
2061 Vector4f a = new Vector4f (1, 2, 3, 4);
2062 Vector4f b = new Vector4f (5, 6, 7, 8);
2075 public static int test_0_simple_packed_mul () {
2076 Vector4f a = new Vector4f (1, 2, 3, 4);
2077 Vector4f b = new Vector4f (5, 6, 7, 8);
2090 public static int test_0_simple_packed_div () {
2091 Vector4f a = new Vector4f (2, 2, 3, 4);
2092 Vector4f b = new Vector4f (20, 10, 33, 12);
2105 public static int test_0_simple_packed_sqrt () {
2106 Vector4f a = new Vector4f (16, 4, 9, 25);
2107 a = Vector4f.Sqrt (a);
2119 public static int test_0_simple_packed_invsqrt () {
2120 Vector4f a = new Vector4f (16, 4, 100, 25);
2121 //this function has VERY low precision
2122 a = Vector4f.InvSqrt (a);
2123 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
2125 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
2127 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
2129 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
2134 public static int test_0_simple_packed_min () {
2135 Vector4f a = new Vector4f (16, -4, 9, 25);
2136 Vector4f b = new Vector4f (5, 3, 9, 0);
2137 Vector4f c = Vector4f.Min (a, b);
2149 public static int test_0_simple_packed_max () {
2150 Vector4f a = new Vector4f (16, -4, 9, 25);
2151 Vector4f b = new Vector4f (5, 3, 9, 0);
2152 Vector4f c = Vector4f.Max (a, b);
2164 public static int test_0_simple_packed_hadd () {
2165 Vector4f a = new Vector4f (5, 5, 6, 6);
2166 Vector4f b = new Vector4f (7, 7, 8, 8);
2167 Vector4f c = Vector4f.HorizontalAdd (a, b);
2179 public static int test_0_simple_packed_hsub () {
2180 Vector4f a = new Vector4f (5, 2, 6, 1);
2181 Vector4f b = new Vector4f (7, 0, 8, 3);
2182 Vector4f c = Vector4f.HorizontalSub (a, b);
2194 public static int test_0_simple_packed_addsub () {
2195 Vector4f a = new Vector4f (5, 2, 6, 1);
2196 Vector4f b = new Vector4f (7, 0, 8, 3);
2197 Vector4f c = Vector4f.AddSub (a, b);
2209 public static int test_0_simple_packed_shuffle () {
2210 Vector4f a = new Vector4f (1, 2, 3, 4);
2211 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2223 public static int test_0_packed_shuffle_with_reg_pressure () {
2224 Vector4f v = new Vector4f (1, 2, 3, 4);
2225 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
2226 if (ff) v = v + v -v ;
2228 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2229 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2230 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2231 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2232 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2240 Vector4f result = r0 + r1 + r2 + r3;
2250 if (result.Y != result.Y)
2255 public static int test_24_regs_pressure_a () {
2256 Vector4f a = new Vector4f (1, 2, 3, 4);
2264 public static int test_54_regs_pressure_b () {
2265 Vector4f a = new Vector4f (1, 2, 3, 4);
2269 Vector4f e = a + b + c;
2270 Vector4f f = d - b + a - c;
2271 Vector4f g = a - d * f - c + b;
2272 Vector4f h = a * b - c + e;
2273 Vector4f i = h - g - f - e - d - c - b - a;
2274 Vector4f j = a + b + c + d + e + f + g + h + i;
2279 public static int test_3_single_block_var_is_properly_promoted () {
2280 Vector4f a = new Vector4f (4, 5, 6, 7);
2284 Vector4f b = new Vector4f (1, 2, 3, 4);
2295 static float float_val = 45f;
2297 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
2298 Vector4f v = new Vector4f (1, 2, 3, 4);
2299 float f = float_val;
2308 public static int Main () {
2309 return TestDriver.RunTests (typeof (SimdTests));