4 public class SimdTests {
5 public static unsafe int test_vector2ul_slr () {
6 Vector2ul a = new Vector2ul (1, 6);
10 Console.WriteLine (c.X);//0
11 Console.WriteLine (c.Y);//3
17 public static unsafe int test_vector2l_cmp_gt () {
18 Vector2l a = new Vector2l (10, 5);
19 Vector2l b = new Vector2l (-1, 5);
21 Vector2l c = Vector2l.CompareGreaterThan (a, b);
30 public static unsafe int test_vector2l_cmp_eq () {
31 Vector2l a = new Vector2l (0xFF, 5);
32 Vector2l b = new Vector2l (0xFF000000FFL, 5);
34 Vector2l c = Vector2l.CompareEqual (a, b);
43 public static unsafe int test_vector2l_srl () {
44 Vector2l a = new Vector2l (1, 6);
46 Vector2l c = Vector2l.ShiftRightLogic (a, 1);
55 public static unsafe int test_vector2l_unpack_high () {
56 Vector2l a = new Vector2l (1, 6);
57 Vector2l b = new Vector2l (3, 4);
59 Vector2l c = Vector2l.UnpackHigh (a, b);
68 public static unsafe int test_vector2l_unpack_low () {
69 Vector2l a = new Vector2l (1, 6);
70 Vector2l b = new Vector2l (3, 4);
72 Vector2l c = Vector2l.UnpackLow (a, b);
81 public static unsafe int test_vector2l_xor () {
82 Vector2l a = new Vector2l (1, 6);
83 Vector2l b = new Vector2l (3, 4);
94 public static unsafe int test_vector2l_or () {
95 Vector2l a = new Vector2l (1, 6);
96 Vector2l b = new Vector2l (3, 4);
107 public static unsafe int test_vector2l_and () {
108 Vector2l a = new Vector2l (1, 6);
109 Vector2l b = new Vector2l (3, 4);
120 public static unsafe int test_vector2l_shl() {
121 Vector2l a = new Vector2l (1, 6);
131 public static unsafe int test_vector2l_sub() {
132 Vector2l a = new Vector2l (1, 6);
133 Vector2l b = new Vector2l (3, 4);
144 public static unsafe int test_vector2l_add () {
145 Vector2l a = new Vector2l (1, 2);
146 Vector2l b = new Vector2l (3, 4);
157 public static unsafe int test_0_vector2d_dup () {
158 Vector2d a = new Vector2d (3, 2);
160 Vector2d c = Vector2d.Duplicate (a);
169 public static unsafe int test_0_vector2d_cmp_eq () {
170 Vector2d a = new Vector2d (3, 2);
171 Vector2d b = new Vector2d (3, 4);
173 Vector4ui c = (Vector4ui)Vector2d.CompareEqual (a, b);
175 if (c.X != 0xFFFFFFFF)
177 if (c.Y != 0xFFFFFFFF)
186 public static unsafe int test_0_vector2d_unpack_low () {
187 Vector2d a = new Vector2d (1, 2);
188 Vector2d b = new Vector2d (4, 5);
190 Vector2d c = Vector2d.InterleaveLow (a, b);
199 public static unsafe int test_0_vector2d_unpack_high () {
200 Vector2d a = new Vector2d (1, 2);
201 Vector2d b = new Vector2d (4, 5);
203 Vector2d c = Vector2d.InterleaveHigh (a, b);
211 public static unsafe int test_0_vector2d_addsub () {
212 Vector2d a = new Vector2d (1, 2);
213 Vector2d b = new Vector2d (4, 1);
215 Vector2d c = Vector2d.AddSub (a, b);
223 public static unsafe int test_0_vector2d_hsub () {
224 Vector2d a = new Vector2d (1, 2);
225 Vector2d b = new Vector2d (4, 1);
227 Vector2d c = Vector2d.HorizontalSub (a, b);
236 public static unsafe int test_0_vector2d_hadd () {
237 Vector2d a = new Vector2d (1, 2);
238 Vector2d b = new Vector2d (4, 0);
240 Vector2d c = Vector2d.HorizontalAdd (a, b);
249 public static unsafe int test_0_vector2d_min () {
250 Vector2d a = new Vector2d (1, 2);
251 Vector2d b = new Vector2d (4, 0);
253 Vector2d c = Vector2d.Min (a, b);
262 public static unsafe int test_0_vector2d_max () {
263 Vector2d a = new Vector2d (1, 2);
264 Vector2d b = new Vector2d (4, 0);
266 Vector2d c = Vector2d.Max (a, b);
276 public static unsafe int test_0_vector2d_andnot () {
277 Vector2d a = new Vector2d (1, 2);
278 Vector2d b = new Vector2d (3, 4);
280 Vector4ui c = (Vector4ui)Vector2d.AndNot (a, b);
284 if (c.Y != 1074266112)
293 public static unsafe int test_0_vector2d_div () {
294 Vector2d a = new Vector2d (1, 2);
295 Vector2d b = new Vector2d (4, 5);
306 public static unsafe int test_0_vector2d_mul () {
307 Vector2d a = new Vector2d (1, 2);
308 Vector2d b = new Vector2d (3, 5);
318 public static unsafe int test_0_vector2d_sub () {
319 Vector2d a = new Vector2d (1, 2);
320 Vector2d b = new Vector2d (3, 5);
330 public static unsafe int test_0_vector2d_add () {
331 Vector2d a = new Vector2d (1, 2);
332 Vector2d b = new Vector2d (3, 4);
342 public static unsafe int test_0_vector2d_xor () {
343 Vector2d a = new Vector2d (1, 2);
344 Vector2d b = new Vector2d (3, 4);
346 Vector4ui c = (Vector4ui)(a ^ b);
350 if (c.Y != 2146959360)
359 public static unsafe int test_0_vector2d_or () {
360 Vector2d a = new Vector2d (1, 2);
361 Vector2d b = new Vector2d (3, 4);
363 Vector4ui c = (Vector4ui)(a | b);
367 if (c.Y != 2146959360)
371 if (c.W != 1074790400)
376 public static unsafe int test_0_vector2d_and () {
377 Vector2d a = new Vector2d (1, 2);
378 Vector2d b = new Vector2d (3, 4);
380 Vector4ui c = (Vector4ui)(a & b);
388 if (c.W != 1073741824)
393 public static unsafe int test_vector8s_pack_signed_sat () {
394 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
395 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
397 Vector16sb c = Vector8s.PackWithSignedSaturation (a, b);
407 public static unsafe int test_vector16sb_sub_sat () {
408 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
409 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
411 Vector16sb c = Vector16sb.SubWithSaturation (a, b);
432 public static unsafe int test_vector16sb_add_sat () {
433 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
434 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
436 Vector16sb c = Vector16sb.AddWithSaturation (a, b);
457 public static unsafe int test_vector16sb_cmp_gt () {
458 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
459 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
461 Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
481 public static int test_0_vector4ui_pack_with_sat () {
482 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
483 Vector4ui b = new Vector4ui (5,6,7,8);
485 Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
506 public static int test_0_vector8us_pack_with_sat () {
507 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
508 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
509 Vector16b c = Vector8us.SignedPackWithUnsignedSaturation (a, b);
524 public static int test_0_vector8us_mul_high () {
525 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
526 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
527 Vector8us c = Vector8us.MultiplyStoreHigh (a, b);
548 public static int test_0_vector8us_cmpeq () {
549 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
550 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
551 Vector8us c = Vector8us.CompareEqual (a, b);
573 public static int test_0_vector4ui_cmpeq () {
574 Vector4ui a = new Vector4ui (6,1,6,3);
575 Vector4ui b = new Vector4ui (3,4,6,7);
576 Vector4ui c = Vector4ui.CompareEqual (a, b);
582 if (c.Z != 0xFFFFFFFF)
589 public static int test_0_vector4ui_shuffle () {
590 Vector4ui a = new Vector4ui (1,2,3,4);
591 Vector4ui c = Vector4ui.Shuffle (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
604 public static int test_0_vector4ui_extract_mask () {
605 Vector4ui a = new Vector4ui (0xFF00FF00,0x0F0FAA99,0,0);
606 int c = Vector4ui.ExtractByteMask (a);
613 public static int test_0_vector4ui_min () {
614 Vector4ui a = new Vector4ui (6,1,6,3);
615 Vector4ui b = new Vector4ui (3,4,6,7);
616 Vector4ui c = Vector4ui.Min (a, b);
629 public static int test_0_vector4ui_max () {
630 Vector4ui a = new Vector4ui (6,1,6,3);
631 Vector4ui b = new Vector4ui (3,4,6,7);
632 Vector4ui c = Vector4ui.Max (a, b);
645 public static int vector16b_cmpeq () {
646 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
647 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
648 Vector16b c = Vector16b.CompareEqual (a, b);
686 public static int vector16b_sum_abs_diff () {
687 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
688 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
689 Vector8us c = Vector16b.SumOfAbsoluteDifferences (a, b);
711 public static int test_0_vector16b_extract_mask () {
712 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
713 int c = Vector16b.ExtractByteMask (a);
720 public static int test_0_vector16b_min () {
721 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
722 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
723 Vector16b c = Vector16b.Min (a, b);
760 public static int test_0_vector16b_max () {
761 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
762 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
763 Vector16b c = Vector16b.Max (a, b);
799 public static int test_0_vector16b_avg () {
800 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
801 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
802 Vector16b c = Vector16b.Average (a, b);
840 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
841 Vector8us res = new Vector8us ();
842 byte *a = (byte*)&va;
843 byte *b = (byte*)&vb;
846 for (int i = 0; i < 8; ++i)
847 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
848 res.V0 = (ushort)tmp;
851 for (int i = 0; i < 8; ++i)
852 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
853 res.V4 = (ushort)tmp;
857 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
858 public static int test_2_local_simplifier_regression_other_blocks () {
859 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
860 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
861 Vector8us res = bad_method_regression_2 (a,b);
862 return (int)res.V0 + res.V4;
865 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
866 Vector8us res = new Vector8us ();
867 byte *a = (byte*)&va;
868 byte *b = (byte*)&vb;
869 *((ushort*)&res) = 10;
880 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
881 public static int test_10_local_simplifier_regression_first_block () {
882 Vector16b a = new Vector16b ();
883 Vector16b b = new Vector16b ();
884 Vector8us res = bad_method_regression (a,b);
889 public static int test_0_vecto8us_extract_mask () {
890 Vector8us a = new Vector8us (0xF0F0, 0x700F, 0xAABB, 0x0000, 0x00F0, 0xF0F0, 0, 0);
891 int c = Vector8us.ExtractByteMask (a);
898 public static int test_0_vecto8us_shuffle_low () {
899 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
900 Vector8us c = Vector8us.ShuffleLow (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
921 public static int test_0_vecto8us_shuffle_high () {
922 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
923 Vector8us c = Vector8us.ShuffleHigh (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
945 public static int test_0_vecto8us_max () {
946 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
947 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
948 Vector8us c = Vector8us.Max (a, b);
970 public static int test_0_vecto8us_min () {
971 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
972 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
973 Vector8us c = Vector8us.Min (a, b);
994 public static int test_0_vecto8us_avg () {
995 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
996 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
997 Vector8us c = Vector8us.Average (a, b);
1018 static void store_helper (ref Vector4f x) {
1020 k = new Vector4f(9,9,9,9);
1024 public static int test_0_vector4f_byref_store ()
1027 k = new Vector4f(1,2,3,4);
1028 store_helper (ref k);
1034 public static int test_0_vector4f_init_array_element ()
1036 Vector4f[] v = new Vector4f[1];
1037 v[0] = new Vector4f(9,9,9,9);
1043 public static int test_0_vector4f_dup_high () {
1044 Vector4f a = new Vector4f (1, 2, 3, 4);
1045 Vector4f c = Vector4f.DuplicateHigh(a);
1058 public static int test_0_vector4f_dup_low () {
1059 Vector4f a = new Vector4f (1, 2, 3, 4);
1060 Vector4f c = Vector4f.DuplicateLow (a);
1074 public static int test_0_vector4f_interleave_high () {
1075 Vector4f a = new Vector4f (1, 2, 3, 4);
1076 Vector4f b = new Vector4f (5, 6, 7, 8);
1077 Vector4f c = Vector4f.InterleaveHigh (a, b);
1090 public static int test_0_vector4f_interleave_low () {
1091 Vector4f a = new Vector4f (1, 2, 3, 4);
1092 Vector4f b = new Vector4f (5, 6, 7, 8);
1093 Vector4f c = Vector4f.InterleaveLow (a, b);
1106 public static int test_0_vector4f_rcp () {
1107 Vector4f a = new Vector4f (1, 2, 4, 8);
1108 Vector4f c = Vector4f.Reciprocal (a);
1110 //Test with ranges due to the terrible precision.
1111 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
1113 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
1115 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
1117 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
1122 public static int test_0_vector4f_xor () {
1123 Vector4f a = new Vector4f (1, 2, 3, 4);
1124 Vector4f b = new Vector4f (1, 3, 3, 8);
1127 if (((Vector4ui)c).X != 0)
1129 if (((Vector4ui)c).Y != 0x400000)
1131 if (((Vector4ui)c).Z != 0)
1133 if (((Vector4ui)c).W != 0x1800000)
1138 public static int test_0_vector4f_or () {
1139 Vector4f a = new Vector4f (1, 2, 3, 4);
1140 Vector4f b = new Vector4f (1, 3, 3, 8);
1143 if (((Vector4ui)c).X != 0x3F800000)
1145 if (((Vector4ui)c).Y != 0x40400000)
1147 if (((Vector4ui)c).Z != 0x40400000)
1149 if (((Vector4ui)c).W != 0x41800000)
1153 public static int test_0_vector4f_andn () {
1154 Vector4f a = new Vector4f (1, 2, 3, 4);
1155 Vector4f b = new Vector4f (1, 3, 3, 8);
1156 Vector4f c = Vector4f.AndNot (a ,b);
1158 if (((Vector4ui)c).X != 0)
1160 if (((Vector4ui)c).Y != 0x400000)
1162 if (((Vector4ui)c).Z != 0)
1164 if (((Vector4ui)c).W != 0x1000000)
1169 public static int test_0_vector4f_and () {
1170 Vector4f a = new Vector4f (1, 2, 3, 4);
1171 Vector4f b = new Vector4f (1, 3, 3, 8);
1174 if (((Vector4ui)c).X != 0x3F800000)
1176 if (((Vector4ui)c).Y != 0x40000000)
1178 if (((Vector4ui)c).Z != 0x40400000)
1180 if (((Vector4ui)c).W != 0x40000000)
1185 public static int test_0_vector4f_cmpord () {
1186 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1187 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1188 Vector4f c = Vector4f.CompareOrdered (a, b);
1190 if (((Vector4ui)c).X != 0)
1192 if (((Vector4ui)c).Y != 0)
1194 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1196 if (((Vector4ui)c).W != 0xFFFFFFFF)
1201 public static int test_0_vector4f_cmpnle () {
1202 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1203 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1204 Vector4f c = Vector4f.CompareNotLessEqual (a, b);
1206 if (((Vector4ui)c).X != 0xFFFFFFFF)
1208 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1210 if (((Vector4ui)c).Z != 0)
1212 if (((Vector4ui)c).W != 0)
1217 public static int test_0_vector4f_cmpnlt () {
1218 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1219 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1220 Vector4f c = Vector4f.CompareNotLessThan (a, b);
1222 if (((Vector4ui)c).X != 0xFFFFFFFF)
1224 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1226 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1228 if (((Vector4ui)c).W != 0)
1233 public static int test_0_vector4f_cmpneq () {
1234 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1235 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1236 Vector4f c = Vector4f.CompareNotEqual (a, b);
1238 if (((Vector4ui)c).X != 0xFFFFFFFF)
1240 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1242 if (((Vector4ui)c).Z != 0)
1244 if (((Vector4ui)c).W != 0xFFFFFFFF)
1249 public static int test_0_vector4f_cmpunord () {
1250 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1251 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1252 Vector4f c = Vector4f.CompareUnordered (a, b);
1254 if (((Vector4ui)c).X != 0xFFFFFFFF)
1256 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1258 if (((Vector4ui)c).Z != 0)
1260 if (((Vector4ui)c).W != 0)
1265 public static int test_0_vector4f_cmple () {
1266 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1267 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1268 Vector4f c = Vector4f.CompareLessEqual (a, b);
1270 if (((Vector4ui)c).X != 0)
1272 if (((Vector4ui)c).Y != 0)
1274 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1276 if (((Vector4ui)c).W != 0xFFFFFFFF)
1281 public static int test_0_vector4f_cmplt () {
1282 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1283 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1284 Vector4f c = Vector4f.CompareLessThan (a, b);
1286 if (((Vector4ui)c).X != 0)
1288 if (((Vector4ui)c).Y != 0)
1290 if (((Vector4ui)c).Z != 0)
1292 if (((Vector4ui)c).W != 0xFFFFFFFF)
1297 public static int test_0_vector4f_cmpeq () {
1298 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
1299 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
1300 Vector4f c = Vector4f.CompareEqual (a, b);
1302 if (((Vector4ui)c).X != 0)
1304 if (((Vector4ui)c).Y != 0)
1306 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1308 if (((Vector4ui)c).W != 0)
1313 public static int test_0_vector4ui_sar () {
1314 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1316 Vector4ui c = Vector4ui.ShiftRightArithmetic (a, 2);
1318 if (c.X != 0xFC000000)
1329 public static int test_0_vector4ui_unpack_high () {
1330 Vector4ui a = new Vector4ui (1,2,3,4);
1331 Vector4ui b = new Vector4ui (5,6,7,8);
1333 Vector4ui c = Vector4ui.UnpackHigh(a, b);
1346 public static int test_0_vector4ui_unpack_low () {
1347 Vector4ui a = new Vector4ui (1,2,3,4);
1348 Vector4ui b = new Vector4ui (5,6,7,8);
1350 Vector4ui c = Vector4ui.UnpackLow (a, b);
1363 public static int test_0_vector4ui_xor () {
1364 Vector4ui a = new Vector4ui (1,2,3,4);
1365 Vector4ui b = new Vector4ui (7,5,3,1);
1367 Vector4ui c = a ^ b;
1380 public static int test_0_vector4ui_or () {
1381 Vector4ui a = new Vector4ui (1,2,3,4);
1382 Vector4ui b = new Vector4ui (7,5,3,1);
1384 Vector4ui c = a | b;
1396 public static int test_0_vector4ui_and () {
1397 Vector4ui a = new Vector4ui (1,2,3,4);
1398 Vector4ui b = new Vector4ui (7,5,3,1);
1400 Vector4ui c = a & b;
1413 public static int test_0_vector4ui_shr () {
1414 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1416 Vector4ui c = a >> 2;
1418 if (c.X != 0x3C000000)
1429 public static int test_0_vector4ui_shl () {
1430 Vector4ui a = new Vector4ui (10,20,3,40);
1432 Vector4ui c = a << 2;
1445 public static int test_0_vector4ui_mul () {
1446 Vector4ui a = new Vector4ui (0x8888,20,3,40);
1447 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1449 Vector4ui c = a * b;
1451 if (c.X != 0xffff7800)
1461 public static int test_0_vector4ui_sub () {
1462 Vector4ui a = new Vector4ui (1,20,3,40);
1463 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1465 Vector4ui c = a - b;
1467 if (c.X != 0xff0101)
1478 public static int test_0_vector4ui_add () {
1479 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
1480 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1482 Vector4ui c = a + b;
1484 if (c.X != 0xfe01fe00)
1496 static int test_0_vector4ui_accessors () {
1497 Vector4ui a = new Vector4ui (1,2,3,4);
1523 static int test_0_vector8us_sub_sat () {
1524 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
1525 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1526 Vector8us c = Vector8us.SubWithSaturation (a, b);
1547 static int test_0_vector8us_add_sat () {
1548 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1549 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1550 Vector8us c = Vector8us.AddWithSaturation (a, b);
1571 static int test_0_vector8us_unpack_low () {
1572 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1573 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1574 Vector8us c = Vector8us.UnpackLow (a, b);
1596 static int test_0_vector8us_shift_left () {
1597 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1599 Vector8us c = a << amt;
1610 static int test_0_vector8us_shift_right_arithmetic () {
1611 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1613 Vector8us c = Vector8us.ShiftRightArithmetic (a, amt);
1624 static int test_0_vector8us_shift_variable_offset () {
1626 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1628 Vector8us c = b >> off;
1645 static int test_0_vector8us_shift_operand_is_live_after_op () {
1646 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1648 Vector8us c = b >> 2;
1664 static int test_0_vector8us_shr_constant () {
1665 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1666 Vector8us c = a >> 2;
1677 static int test_0_vector8us_mul () {
1678 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
1679 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
1681 Vector8us c = a * b;
1691 static int test_0_vector8us_add () {
1692 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1693 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
1695 Vector8us c = a + b;
1706 static int test_0_vector8us_sub () {
1707 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
1708 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
1710 Vector8us c = a - b;
1722 static int test_0_vector8us_accessors () {
1723 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1771 static int test_0_vector16b_unpack_high () {
1772 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1773 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1774 Vector16b c = Vector16b.UnpackHigh (a, b);
1795 static int test_0_vector16b_unpack_low () {
1796 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1797 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1798 Vector16b c = Vector16b.UnpackLow (a, b);
1819 static int test_0_vector16b_sub_sat () {
1820 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1821 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1822 Vector16b c = Vector16b.SubWithSaturation (a, b);
1833 static int test_0_vector16b_add_sat () {
1834 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1835 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1836 Vector16b c = Vector16b.AddWithSaturation (a, b);
1847 static int test_0_vector16b_add_ovf () {
1848 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1849 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1850 Vector16b c = a + b;
1861 static int test_0_vector16b_accessors () {
1862 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1949 public static int test_0_accessors () {
1950 Vector4f a = new Vector4f (1, 2, 3, 4);
1962 public static int test_0_packed_add_with_stack_tmp () {
1963 Vector4f a = new Vector4f (1, 2, 3, 4);
1964 Vector4f b = new Vector4f (5, 6, 7, 8);
1965 Vector4f c = new Vector4f (-1, -3, -4, -5);
1966 Vector4f d = a + b + c;
1978 public static int test_0_simple_packed_add () {
1979 Vector4f a = new Vector4f (1, 2, 3, 4);
1980 Vector4f b = new Vector4f (5, 6, 7, 8);
1994 public static int test_0_simple_packed_sub () {
1995 Vector4f a = new Vector4f (1, 2, 3, 4);
1996 Vector4f b = new Vector4f (5, 6, 7, 8);
2009 public static int test_0_simple_packed_mul () {
2010 Vector4f a = new Vector4f (1, 2, 3, 4);
2011 Vector4f b = new Vector4f (5, 6, 7, 8);
2024 public static int test_0_simple_packed_div () {
2025 Vector4f a = new Vector4f (2, 2, 3, 4);
2026 Vector4f b = new Vector4f (20, 10, 33, 12);
2039 public static int test_0_simple_packed_sqrt () {
2040 Vector4f a = new Vector4f (16, 4, 9, 25);
2041 a = Vector4f.Sqrt (a);
2053 public static int test_0_simple_packed_invsqrt () {
2054 Vector4f a = new Vector4f (16, 4, 100, 25);
2055 //this function has VERY low precision
2056 a = Vector4f.InvSqrt (a);
2057 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
2059 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
2061 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
2063 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
2068 public static int test_0_simple_packed_min () {
2069 Vector4f a = new Vector4f (16, -4, 9, 25);
2070 Vector4f b = new Vector4f (5, 3, 9, 0);
2071 Vector4f c = Vector4f.Min (a, b);
2083 public static int test_0_simple_packed_max () {
2084 Vector4f a = new Vector4f (16, -4, 9, 25);
2085 Vector4f b = new Vector4f (5, 3, 9, 0);
2086 Vector4f c = Vector4f.Max (a, b);
2098 public static int test_0_simple_packed_hadd () {
2099 Vector4f a = new Vector4f (5, 5, 6, 6);
2100 Vector4f b = new Vector4f (7, 7, 8, 8);
2101 Vector4f c = Vector4f.HorizontalAdd (a, b);
2113 public static int test_0_simple_packed_hsub () {
2114 Vector4f a = new Vector4f (5, 2, 6, 1);
2115 Vector4f b = new Vector4f (7, 0, 8, 3);
2116 Vector4f c = Vector4f.HorizontalSub (a, b);
2128 public static int test_0_simple_packed_addsub () {
2129 Vector4f a = new Vector4f (5, 2, 6, 1);
2130 Vector4f b = new Vector4f (7, 0, 8, 3);
2131 Vector4f c = Vector4f.AddSub (a, b);
2143 public static int test_0_simple_packed_shuffle () {
2144 Vector4f a = new Vector4f (1, 2, 3, 4);
2145 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2157 public static int test_0_packed_shuffle_with_reg_pressure () {
2158 Vector4f v = new Vector4f (1, 2, 3, 4);
2159 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
2160 if (ff) v = v + v -v ;
2162 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2163 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2164 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2165 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2166 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2174 Vector4f result = r0 + r1 + r2 + r3;
2184 if (result.Y != result.Y)
2189 public static int test_24_regs_pressure_a () {
2190 Vector4f a = new Vector4f (1, 2, 3, 4);
2198 public static int test_54_regs_pressure_b () {
2199 Vector4f a = new Vector4f (1, 2, 3, 4);
2203 Vector4f e = a + b + c;
2204 Vector4f f = d - b + a - c;
2205 Vector4f g = a - d * f - c + b;
2206 Vector4f h = a * b - c + e;
2207 Vector4f i = h - g - f - e - d - c - b - a;
2208 Vector4f j = a + b + c + d + e + f + g + h + i;
2213 public static int test_3_single_block_var_is_properly_promoted () {
2214 Vector4f a = new Vector4f (4, 5, 6, 7);
2218 Vector4f b = new Vector4f (1, 2, 3, 4);
2229 static float float_val = 45f;
2231 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
2232 Vector4f v = new Vector4f (1, 2, 3, 4);
2233 float f = float_val;
2242 public static int Main () {
2243 return TestDriver.RunTests (typeof (SimdTests));