Pinvoke symbols according to the new moonlight naming convention.
[mono-project.git] / mono / mini / basic-simd.cs
blobcc8150a0a4766ea006823408244f6df265b5d731
1 using System;
2 using Mono.Simd;
4 public class SimdTests {
5 static int ddd;
6 static void InitByRef (out Vector4i v) {
7 v = new Vector4i (99);
8 if (ddd > 10)
9 throw new Exception ("ddd");
12 static int test_0_vector4i_one_element_ctor_with_byref ()
14 Vector4i a;
15 InitByRef (out a);
16 if (a.X != 99)
17 return 1;
18 if (a.Y != 99)
19 return 2;
20 if (a.Z != 99)
21 return 3;
22 if (a.W != 99)
23 return 4;
24 return 0;
27 static int test_0_vector2d_one_element_ctor () {
28 Vector2d a = new Vector2d (99);
29 if (a.X != 99)
30 return 1;
31 if (a.Y != 99)
32 return 2;
33 return 0;
36 static int test_0_vector2ul_one_element_ctor () {
37 Vector2ul a = new Vector2ul (99);
39 if (a.X != 99)
40 return 1;
41 if (a.Y != 99)
42 return 2;
43 return 0;
46 static int test_0_vector2l_one_element_ctor () {
47 Vector2l a = new Vector2l (99);
49 if (a.X != 99)
50 return 1;
51 if (a.Y != 99)
52 return 2;
53 return 0;
56 static int test_0_vector4f_one_element_ctor () {
57 Vector4f a = new Vector4f (99);
59 if (a.X != 99)
60 return 1;
61 if (a.Y != 99)
62 return 2;
63 if (a.Z != 99)
64 return 3;
65 if (a.W != 99)
66 return 4;
67 return 0;
70 static int test_0_vector4ui_one_element_ctor () {
71 Vector4ui a = new Vector4ui (99);
73 if (a.X != 99)
74 return 1;
75 if (a.Y != 99)
76 return 2;
77 if (a.Z != 99)
78 return 3;
79 if (a.W != 99)
80 return 4;
81 return 0;
84 static int test_0_vector4i_one_element_ctor () {
85 Vector4i a = new Vector4i (99);
87 if (a.X != 99)
88 return 1;
89 if (a.Y != 99)
90 return 2;
91 if (a.Z != 99)
92 return 3;
93 if (a.W != 99)
94 return 4;
95 return 0;
98 static int test_0_vector8us_one_element_ctor () {
99 Vector8us a = new Vector8us (99);
101 if (a.V0 != 99)
102 return 1;
103 if (a.V1 != 99)
104 return 2;
105 if (a.V2 != 99)
106 return 3;
107 if (a.V3 != 99)
108 return 4;
109 if (a.V4 != 99)
110 return 5;
111 if (a.V5 != 99)
112 return 6;
113 if (a.V6 != 99)
114 return 7;
115 if (a.V7 != 99)
116 return 8;
117 return 0;
120 static int test_0_vector8s_one_element_ctor () {
121 Vector8s a = new Vector8s (99);
123 if (a.V0 != 99)
124 return 1;
125 if (a.V1 != 99)
126 return 2;
127 if (a.V2 != 99)
128 return 3;
129 if (a.V3 != 99)
130 return 4;
131 if (a.V4 != 99)
132 return 5;
133 if (a.V5 != 99)
134 return 6;
135 if (a.V6 != 99)
136 return 7;
137 if (a.V7 != 99)
138 return 8;
139 return 0;
142 static int test_0_vector16sb_one_element_ctor () {
143 Vector16sb a = new Vector16sb (99);
145 if (a.V0 != 99)
146 return 1;
147 if (a.V1 != 99)
148 return 2;
149 if (a.V2 != 99)
150 return 3;
151 if (a.V3 != 99)
152 return 4;
153 if (a.V4 != 99)
154 return 5;
155 if (a.V5 != 99)
156 return 6;
157 if (a.V6 != 99)
158 return 7;
159 if (a.V7 != 99)
160 return 8;
161 if (a.V8 != 99)
162 return 9;
163 if (a.V9 != 99)
164 return 10;
165 if (a.V10 != 99)
166 return 11;
167 if (a.V11 != 99)
168 return 12;
169 if (a.V12 != 99)
170 return 13;
171 if (a.V13 != 99)
172 return 14;
173 if (a.V14 != 99)
174 return 15;
175 if (a.V15 != 99)
176 return 16;
177 return 0;
180 static int test_0_vector16b_one_element_ctor () {
181 Vector16b a = new Vector16b (99);
183 if (a.V0 != 99)
184 return 1;
185 if (a.V1 != 99)
186 return 2;
187 if (a.V2 != 99)
188 return 3;
189 if (a.V3 != 99)
190 return 4;
191 if (a.V4 != 99)
192 return 5;
193 if (a.V5 != 99)
194 return 6;
195 if (a.V6 != 99)
196 return 7;
197 if (a.V7 != 99)
198 return 8;
199 if (a.V8 != 99)
200 return 9;
201 if (a.V9 != 99)
202 return 10;
203 if (a.V10 != 99)
204 return 11;
205 if (a.V11 != 99)
206 return 12;
207 if (a.V12 != 99)
208 return 13;
209 if (a.V13 != 99)
210 return 14;
211 if (a.V14 != 99)
212 return 15;
213 if (a.V15 != 99)
214 return 16;
215 return 0;
218 public static unsafe int test_0_sizeof_returns_16_2d ()
220 double[] array = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
221 fixed (double *ptr = &array [0]) {
222 Vector2d *f = (Vector2d*)ptr;
223 Vector2d a = *f++;
224 Vector2d b = *f++;
225 Vector2d c = *f++;
226 Vector2d d = *f++;
228 if (a.X != 1 || a.Y != 2)
229 return 1;
230 if (b.X != 3 || b.Y != 4)
231 return 2;
232 if (c.X != 5 || c.Y != 6)
233 return 3;
234 if (d.X != 7 || d.Y != 8)
235 return 4;
237 return 0;
240 public static unsafe int test_0_sizeof_returns_16_4f ()
242 float[] array = new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
243 fixed (float *ptr = &array [0]) {
244 Vector4f *f = (Vector4f*)ptr;
245 Vector4f a = *f++;
246 Vector4f b = *f++;
247 Vector4f c = *f++;
248 Vector4f d = *f++;
250 if (a.X != 1 || a.W != 4)
251 return 1;
252 if (b.X != 5 || b.W != 8)
253 return 2;
254 if (c.X != 9 || c.W != 12)
255 return 3;
256 if (d.X != 13 || d.W != 16)
257 return 4;
259 return 0;
262 public static unsafe int test_0_sizeof_returns_16_8d ()
264 short[] array = new short[40];
265 for (int i = 0; i < 40; ++i)
266 array [i] = (short) (i + 1);
268 fixed (short *ptr = &array [0]) {
269 Vector8s *f = (Vector8s*)ptr;
270 Vector8s a = *f++;
271 Vector8s b = *f++;
272 Vector8s c = *f++;
273 Vector8s d = *f++;
275 if (a.V0 != 1 || a.V7 != 8)
276 return 1;
277 if (b.V0 != 9 || b.V7 != 16)
278 return 2;
279 if (c.V0 != 17 || c.V7 != 24)
280 return 3;
281 if (d.V0 != 25 || d.V7 != 32)
282 return 4;
284 return 0;
287 public static unsafe int test_0_sizeof_returns_16_16b ()
289 byte[] array = new byte[80];
290 for (int i = 0; i < 80; ++i)
291 array [i] = (byte) (i + 1);
293 fixed (byte *ptr = &array [0]) {
294 Vector16b *f = (Vector16b*)ptr;
295 Vector16b a = *f++;
296 Vector16b b = *f++;
297 Vector16b c = *f++;
298 Vector16b d = *f++;
300 if (a.V0 != 1 || a.V15 != 16)
301 return 1;
302 if (b.V0 != 17 || b.V15 != 32)
303 return 2;
304 if (c.V0 != 33 || c.V15 != 48)
305 return 3;
306 if (d.V0 != 49 || d.V15 != 64)
307 return 4;
309 return 0;
311 public static int test_0_bug_462457 ()
313 Vector4f sum = new Vector4f(0,0,0,0);
314 Vector4f add = new Vector4f(1.0F,1.0F,1.0F,1.0F);
316 for (int i = 0; i < 10; ++i)
317 sum = sum + add;
319 if (sum.X != 10f)
320 return 1;
321 return 0;
324 public static int test_0_vector16b_operator_neq () {
325 Vector16b a = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
326 Vector16b b = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
327 if (a != b)
328 return 1;
329 b.V0 = 99;
330 if (!(a != b))
331 return 2;
332 return 0;
335 public static int test_0_vector16b_operator_eq () {
336 Vector16b a = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
337 Vector16b b = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
338 if (!(a == b))
339 return 1;
340 b.V0 = 99;
341 if (a == b)
342 return 2;
343 return 0;
346 public static int test_0_vector8us_operator_neq () {
347 Vector8us a = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
348 Vector8us b = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
349 if (a != b)
350 return 1;
351 b.V0 = 99;
352 if (!(a != b))
353 return 2;
354 return 0;
357 public static int test_0_vector8us_operator_eq () {
358 Vector8us a = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
359 Vector8us b = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
360 if (!(a == b))
361 return 1;
362 b.V0 = 99;
363 if (a == b)
364 return 2;
365 return 0;
368 public static int test_0_set_vector4f_operator_neq () {
369 Vector4f a = new Vector4f(1, 2, 3, 4);
370 Vector4f b = new Vector4f(1, 2, 3, 4);
371 if (a != b)
372 return 1;
374 a = new Vector4f(1, 2, float.NaN, 4);
375 b = new Vector4f(1, 2, float.NaN, 4);
376 if (!(a != b)) //NaN is always !=
377 return 2;
379 a = new Vector4f(1, 2, float.NaN, 4);
380 b = new Vector4f(1, 2, 10, 4);
381 if (!(a != b))
382 return 3;
384 a = new Vector4f(1, 2, float.PositiveInfinity, 4);
385 b = new Vector4f(1, 2, float.PositiveInfinity, 4);
386 if (a != b)
387 return 4;
389 a = new Vector4f(1, 2, 20, 4);
390 b = new Vector4f(1, 2, 30, 4);
391 if (!(a != b))
392 return 5;
394 return 0;
397 public static int test_0_set_vector4f_operator_eq () {
398 Vector4f a = new Vector4f(1, 2, 3, 4);
399 Vector4f b = new Vector4f(1, 2, 3, 4);
400 if (!(a == b))
401 return 1;
403 a = new Vector4f(1, 2, float.NaN, 4);
404 b = new Vector4f(1, 2, float.NaN, 4);
405 if (a == b)
406 return 2;
408 a = new Vector4f(1, 2, 10, 4);
409 b = new Vector4f(1, 2, float.NaN, 4);
410 if (a == b)
411 return 3;
413 a = new Vector4f(1, 2, float.PositiveInfinity, 4);
414 b = new Vector4f(1, 2, float.PositiveInfinity, 4);
415 if (!(a == b))
416 return 4;
417 return 0;
420 public static int test_1_set_vector4ui_operator_neq () {
421 Vector4ui a = new Vector4ui(1, 2, 3, 4);
422 Vector4ui b = new Vector4ui(1, 2, 3, 4);
423 if (a != b)
424 return 0;
425 return 1;
428 public static int test_0_set_vector4ui_operator_neq () {
429 Vector4ui a = new Vector4ui(1, 2, 3, 4);
430 Vector4ui b = new Vector4ui(111, 2, 3, 4);
431 if (a != b)
432 return 0;
433 return 1;
436 public static int test_0_set_vector4ui_operator_eq () {
437 Vector4ui a = new Vector4ui(1, 2, 3, 4);
438 Vector4ui b = new Vector4ui(1, 2, 3, 4);
439 if (a == b)
440 return 0;
441 return 1;
444 public static int test_1_set_vector4ui_operator_eq () {
445 Vector4ui a = new Vector4ui(1, 2, 3, 4);
446 Vector4ui b = new Vector4ui(111, 2, 3, 4);
447 if (a == b)
448 return 0;
449 return 1;
452 public static int test_0_set_vector_small_array () {
453 uint[] array = new uint[3];
455 try {
456 array.SetVector (new Vector4ui (), 0);
457 return 1;
458 } catch (IndexOutOfRangeException) {
460 return 0;
463 public static int test_0_set_vector_negative_index () {
464 uint[] array = new uint[4];
466 try {
467 array.SetVector (new Vector4ui (), -1);
468 return 1;
469 } catch (IndexOutOfRangeException) {
471 return 0;
474 public static int test_0_set_vector_bounds_error () {
475 uint[] array = new uint[4];
477 try {
478 array.SetVector (new Vector4ui (), 1);
479 return 1;
480 } catch (IndexOutOfRangeException) {
482 return 0;
485 public static int test_0_set_vector () {
486 uint[] array = new uint[10];
487 Vector4ui a = new Vector4ui (11, 22, 33, 44);
489 array.SetVector (a, 1);
491 if (array [1] != 11)
492 return 1;
493 if (array [2] != 22)
494 return 2;
495 if (array [3] != 33)
496 return 3;
497 if (array [4] != 44)
498 return 4;
499 return 0;
502 public static int test_0_get_vector_small_array () {
503 uint[] array = new uint[3];
505 try {
506 Vector4ui res = array.GetVector (0);
507 return 1;
508 } catch (IndexOutOfRangeException) {
510 return 0;
513 public static int test_0_get_vector_negative_index () {
514 uint[] array = new uint[4];
516 try {
517 Vector4ui res = array.GetVector (-1);
518 return 1;
519 } catch (IndexOutOfRangeException) {
521 return 0;
524 public static int test_0_get_vector_bounds_error () {
525 uint[] array = new uint[4];
527 try {
528 Vector4ui res = array.GetVector (1);
529 return 1;
530 } catch (IndexOutOfRangeException) {
532 return 0;
535 public static int test_0_get_vector () {
536 uint[] array = new uint[] { 11, 22, 33, 44, 55, 66, 77, 88, 99, 111 };
538 Vector4ui res = array.GetVector (1);
540 if (res.X != 22)
541 return 1;
542 if (res.Y != 33)
543 return 2;
544 if (res.Z != 44)
545 return 3;
546 if (res.W != 55)
547 return 4;
549 return 0;
552 public static int test_0_accessor_vecto2l () {
553 Vector2l a = new Vector2l (3, 2);
555 if (a.X != 3)
556 return 1;
557 if (a.Y != 2)
558 return 2;
560 a.X = 500000000000055l;
561 a.Y = -12345678900l;
563 if (a.X != 500000000000055l)
564 return 3;
565 if (a.Y != -12345678900l)
566 return 4;
567 return 0;
570 public static int test_0_accessor_vecto2d () {
571 Vector2d a = new Vector2d (3, 2);
573 if (a.X != 3)
574 return 1;
575 if (a.Y != 2)
576 return 2;
578 a.X = 5000000000000;
579 a.Y = -0.5;
581 if (a.X != 5000000000000)
582 return 3;
583 if (a.Y != -0.5)
584 return 4;
585 return 0;
588 public static int test_0_accessor_vecto4f () {
589 Vector4f a = new Vector4f (1,2,3,4);
591 if (a.X != 1)
592 return 1;
593 if (a.Y != 2)
594 return 2;
595 if (a.Z != 3)
596 return 3;
597 if (a.W != 4)
598 return 4;
600 a.X = 128f;
601 a.Y = 256f;
602 a.Z = -0.5f;
603 a.W = 0.125f;
605 if (a.X != 128)
606 return 5;
607 if (a.Y != 256)
608 return 6;
609 if (a.Z != -0.5)
610 return 7;
611 if (a.W != 0.125)
612 return 8;
613 return 0;
616 public static int test_0_accessor_vecto4i () {
617 Vector4i a = new Vector4i (0x70000000, -1, 3, 4);
619 if (a.X != 0x70000000)
620 return 1;
621 if (a.Y != -1)
622 return 2;
623 if (a.Z != 3)
624 return 3;
625 if (a.W != 4)
626 return 4;
628 a.X = 11;
629 a.Y = 22;
630 a.Z = 33333344;
631 a.W = -44444444;
633 if (a.X != 11)
634 return 5;
635 if (a.Y != 22)
636 return 6;
637 if (a.Z != 33333344)
638 return 7;
639 if (a.W != -44444444)
640 return 8;
641 return 0;
644 public static int test_0_accessor_vecto4ui () {
645 Vector4ui a = new Vector4ui (0xF0000000, 0xF0000, 3, 4);
647 if (a.X != 0xF0000000)
648 return 1;
649 if (a.Y != 0xF0000)
650 return 2;
651 if (a.Z != 3)
652 return 3;
653 if (a.W != 4)
654 return 4;
656 a.X = 11;
657 a.Y = 22;
658 a.Z = 33333344;
659 a.W = 44444444;
661 if (a.X != 11)
662 return 5;
663 if (a.Y != 22)
664 return 6;
665 if (a.Z != 33333344)
666 return 7;
667 if (a.W != 44444444)
668 return 8;
669 return 0;
672 static float use_getter_with_byref (ref Vector4f a) {
673 return a.W;
676 public static int test_0_accessor_and_byref_var () {
677 Vector4f a = new Vector4f (1, 2, 3, 4);
678 if (use_getter_with_byref (ref a) != 4)
679 return 1;
680 return 0;
683 public static unsafe int test_0_vector2ul_slr () {
684 Vector2ul a = new Vector2ul (1, 6);
686 Vector2ul c = a >> 1;
687 if (c.X != 0)
688 return 1;
689 if (c.Y != 3)
690 return 2;
691 return 0;
694 public static unsafe int test_0_vector2l_cmp_gt () {
695 Vector2l a = new Vector2l (10, 5);
696 Vector2l b = new Vector2l (-1, 5);
698 Vector2l c = a.CompareGreaterThan (b);
700 if (c.X != -1)
701 return 1;
702 if (c.Y != 0)
703 return 2;
704 return 0;
707 public static unsafe int test_0_vector2l_cmp_eq () {
708 Vector2l a = new Vector2l (0xFF, 5);
709 Vector2l b = new Vector2l (0xFF000000FFL, 5);
711 Vector2l c = a.CompareEqual (b);
713 if (c.X != 0)
714 return 1;
715 if (c.Y != -1)
716 return 2;
717 return 0;
720 public static unsafe int test_0_vector2l_srl () {
721 Vector2l a = new Vector2l (1, 6);
723 Vector2l c = a.LogicalRightShift (1);
725 if (c.X != 0)
726 return 1;
727 if (c.Y != 3)
728 return 2;
729 return 0;
732 public static unsafe int test_0_vector2l_unpack_high () {
733 Vector2l a = new Vector2l (1, 6);
734 Vector2l b = new Vector2l (3, 4);
736 Vector2l c = a.UnpackHigh (b);
738 if (c.X != 6)
739 return 1;
740 if (c.Y != 4)
741 return 2;
742 return 0;
745 public static unsafe int test_0_vector2l_unpack_low () {
746 Vector2l a = new Vector2l (1, 6);
747 Vector2l b = new Vector2l (3, 4);
749 Vector2l c = a.UnpackLow (b);
751 if (c.X != 1)
752 return 1;
753 if (c.Y != 3)
754 return 2;
755 return 0;
758 public static unsafe int test_0_vector2l_xor () {
759 Vector2l a = new Vector2l (1, 6);
760 Vector2l b = new Vector2l (3, 4);
762 Vector2l c = a ^ b;
764 if (c.X != 2)
765 return 1;
766 if (c.Y != 2)
767 return 2;
768 return 0;
771 public static unsafe int test_0_vector2l_or () {
772 Vector2l a = new Vector2l (1, 6);
773 Vector2l b = new Vector2l (3, 4);
775 Vector2l c = a | b;
777 if (c.X != 3)
778 return 1;
779 if (c.Y != 6)
780 return 2;
781 return 0;
784 public static unsafe int test_0_vector2l_and () {
785 Vector2l a = new Vector2l (1, 6);
786 Vector2l b = new Vector2l (3, 4);
788 Vector2l c = a & b;
790 if (c.X != 1)
791 return 1;
792 if (c.Y != 4)
793 return 2;
794 return 0;
797 public static unsafe int test_0_vector2l_shl() {
798 Vector2l a = new Vector2l (1, 6);
800 Vector2l c = a << 3;
802 if (c.X != 8)
803 return 1;
804 if (c.Y != 48)
805 return 2;
806 return 0;
808 public static unsafe int test_0_vector2l_sub() {
809 Vector2l a = new Vector2l (1, 6);
810 Vector2l b = new Vector2l (3, 4);
812 Vector2l c = a - b;
814 if (c.X != -2)
815 return 1;
816 if (c.Y != 2)
817 return 2;
818 return 0;
821 public static unsafe int test_0_vector2l_add () {
822 Vector2l a = new Vector2l (1, 2);
823 Vector2l b = new Vector2l (3, 4);
825 Vector2l c = a + b;
827 if (c.X != 4)
828 return 1;
829 if (c.Y != 6)
830 return 2;
831 return 0;
834 public static unsafe int test_0_vector2d_dup () {
835 Vector2d a = new Vector2d (3, 2);
837 Vector2d c = a.Duplicate ();
839 if (c.X != 3)
840 return 1;
841 if (c.Y != 3)
842 return 2;
843 return 0;
846 public static unsafe int test_0_vector2d_cmp_eq () {
847 Vector2d a = new Vector2d (3, 2);
848 Vector2d b = new Vector2d (3, 4);
850 Vector4ui c = (Vector4ui)a.CompareEqual (b);
852 if (c.X != 0xFFFFFFFF)
853 return 1;
854 if (c.Y != 0xFFFFFFFF)
855 return 2;
856 if (c.Z != 0)
857 return 3;
858 if (c.W != 0)
859 return 4;
860 return 0;
863 public static unsafe int test_0_vector2d_unpack_low () {
864 Vector2d a = new Vector2d (1, 2);
865 Vector2d b = new Vector2d (4, 5);
867 Vector2d c = a.InterleaveLow (b);
869 if (c.X != 1)
870 return 1;
871 if (c.Y != 4)
872 return 2;
873 return 0;
876 public static unsafe int test_0_vector2d_unpack_high () {
877 Vector2d a = new Vector2d (1, 2);
878 Vector2d b = new Vector2d (4, 5);
880 Vector2d c = a.InterleaveHigh (b);
882 if (c.X != 2)
883 return 1;
884 if (c.Y != 5)
885 return 2;
886 return 0;
888 public static unsafe int test_0_vector2d_addsub () {
889 Vector2d a = new Vector2d (1, 2);
890 Vector2d b = new Vector2d (4, 1);
892 Vector2d c = a.AddSub (b);
894 if (c.X != -3)
895 return 1;
896 if (c.Y != 3)
897 return 2;
898 return 0;
900 public static unsafe int test_0_vector2d_hsub () {
901 Vector2d a = new Vector2d (1, 2);
902 Vector2d b = new Vector2d (4, 1);
904 Vector2d c = a.HorizontalSub (b);
906 if (c.X != -1)
907 return 1;
908 if (c.Y != 3)
909 return 2;
910 return 0;
913 public static unsafe int test_0_vector2d_hadd () {
914 Vector2d a = new Vector2d (1, 2);
915 Vector2d b = new Vector2d (4, 0);
917 Vector2d c = a.HorizontalAdd (b);
919 if (c.X != 3)
920 return 1;
921 if (c.Y != 4)
922 return 2;
923 return 0;
926 public static unsafe int test_0_vector2d_min () {
927 Vector2d a = new Vector2d (1, 2);
928 Vector2d b = new Vector2d (4, 0);
930 Vector2d c = a.Min (b);
932 if (c.X != 1)
933 return 1;
934 if (c.Y != 0)
935 return 2;
936 return 0;
939 public static unsafe int test_0_vector2d_max () {
940 Vector2d a = new Vector2d (1, 2);
941 Vector2d b = new Vector2d (4, 0);
943 Vector2d c = a.Max (b);
945 if (c.X != 4)
946 return 1;
947 if (c.Y != 2)
948 return 2;
949 return 0;
953 public static unsafe int test_0_vector2d_andnot () {
954 Vector2d a = new Vector2d (1, 2);
955 Vector2d b = new Vector2d (3, 4);
957 Vector4ui c = (Vector4ui)a.AndNot (b);
958 Vector4ui ta = (Vector4ui)a;
959 Vector4ui tb = (Vector4ui)b;
961 if (c.X != (~ta.X & tb.X))
962 return 1;
963 if (c.Y != (~ta.Y & tb.Y))
964 return 2;
965 if (c.Z != (~ta.Z & tb.Z))
966 return 3;
967 if (c.W != (~ta.W & tb.W))
968 return 4;
969 return 0;
972 public static unsafe int test_0_vector2d_div () {
973 Vector2d a = new Vector2d (1, 2);
974 Vector2d b = new Vector2d (4, 5);
976 Vector2d c = a / b;
978 if (c.X != 0.25)
979 return 1;
980 if (c.Y != 0.4)
981 return 2;
982 return 0;
985 public static unsafe int test_0_vector2d_mul () {
986 Vector2d a = new Vector2d (1, 2);
987 Vector2d b = new Vector2d (3, 5);
989 Vector2d c = a * b;
991 if (c.X != 3)
992 return 1;
993 if (c.Y != 10)
994 return 2;
995 return 0;
997 public static unsafe int test_0_vector2d_sub () {
998 Vector2d a = new Vector2d (1, 2);
999 Vector2d b = new Vector2d (3, 5);
1001 Vector2d c = a - b;
1003 if (c.X != -2)
1004 return 1;
1005 if (c.Y != -3)
1006 return 2;
1007 return 0;
1009 public static unsafe int test_0_vector2d_add () {
1010 Vector2d a = new Vector2d (1, 2);
1011 Vector2d b = new Vector2d (3, 4);
1013 Vector2d c = a + b;
1015 if (c.X != 4)
1016 return 1;
1017 if (c.Y != 6)
1018 return 2;
1019 return 0;
1021 public static unsafe int test_0_vector2d_xor () {
1022 Vector2d a = new Vector2d (1, 2);
1023 Vector2d b = new Vector2d (3, 4);
1025 Vector4ui c = (Vector4ui)(a ^ b);
1026 Vector4ui ta = (Vector4ui)a;
1027 Vector4ui tb = (Vector4ui)b;
1029 if (c.X != (ta.X ^ tb.X))
1030 return 1;
1031 if (c.Y != (ta.Y ^ tb.Y))
1032 return 2;
1033 if (c.Z != (ta.Z ^ tb.Z))
1034 return 3;
1035 if (c.W != (ta.W ^ tb.W))
1036 return 4;
1037 return 0;
1040 public static unsafe int test_0_vector2d_or () {
1041 Vector2d a = new Vector2d (1, 2);
1042 Vector2d b = new Vector2d (3, 4);
1044 Vector4ui c = (Vector4ui)(a | b);
1045 Vector4ui ta = (Vector4ui)a;
1046 Vector4ui tb = (Vector4ui)b;
1048 if (c.X != (ta.X | tb.X))
1049 return 1;
1050 if (c.Y != (ta.Y | tb.Y))
1051 return 2;
1052 if (c.Z != (ta.Z | tb.Z))
1053 return 3;
1054 if (c.W != (ta.W | tb.W))
1055 return 4;
1056 return 0;
1059 public static unsafe int test_0_vector2d_and () {
1060 Vector2d a = new Vector2d (1, 2);
1061 Vector2d b = new Vector2d (3, 4);
1063 Vector4ui c = (Vector4ui)(a & b);
1064 Vector4ui ta = (Vector4ui)a;
1065 Vector4ui tb = (Vector4ui)b;
1067 if (c.X != (ta.X & tb.X))
1068 return 1;
1069 if (c.Y != (ta.Y & tb.Y))
1070 return 2;
1071 if (c.Z != (ta.Z & tb.Z))
1072 return 3;
1073 if (c.W != (ta.W & tb.W))
1074 return 4;
1075 return 0;
1078 public static unsafe int test_0_vector8s_pack_signed_sat () {
1079 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
1080 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
1082 Vector16sb c = a.PackWithSignedSaturation (b);
1084 if (c.V0 != -128)
1085 return 1;
1086 if (c.V1 != 127)
1087 return 2;
1089 return 0;
1092 public static unsafe int test_0_vector16sb_sub_sat () {
1093 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1094 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
1096 Vector16sb c = a.SubtractWithSaturation (b);
1098 if (c.V0 != 127)
1099 return 1;
1100 if (c.V1 != -128)
1101 return 2;
1102 if (c.V2 != 0)
1103 return 3;
1104 if (c.V3 != 0)
1105 return 4;
1106 if (c.V4 != 9)
1107 return 5;
1108 if (c.V5 != 9)
1109 return 6;
1110 if (c.V6 != 9)
1111 return 7;
1112 if (c.V7 != -7)
1113 return 8;
1114 return 0;
1117 public static unsafe int test_0_vector16sb_add_sat () {
1118 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1119 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
1121 Vector16sb c = a.AddWithSaturation (b);
1123 if (c.V0 != 127)
1124 return 1;
1125 if (c.V1 != -128)
1126 return 2;
1127 if (c.V2 != 22)
1128 return 3;
1129 if (c.V3 != 24)
1130 return 4;
1131 if (c.V4 != 17)
1132 return 5;
1133 if (c.V5 != 19)
1134 return 6;
1135 if (c.V6 != 21)
1136 return 7;
1137 if (c.V7 != 7)
1138 return 8;
1139 return 0;
1142 public static unsafe int test_0_vector16sb_cmp_gt () {
1143 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1144 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
1146 Vector16sb c = a.CompareGreaterThan (b);
1148 if (c.V0 != -1)
1149 return 1;
1150 if (c.V1 != 0)
1151 return 2;
1152 if (c.V2 != 0)
1153 return 3;
1154 if (c.V3 != 0)
1155 return 4;
1156 if (c.V4 != -1)
1157 return 5;
1158 if (c.V5 != -1)
1159 return 6;
1160 if (c.V6 != -1)
1161 return 7;
1162 return 0;
1166 public static int test_0_vector4ui_pack_with_sat () {
1167 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
1168 Vector4ui b = new Vector4ui (5,6,7,8);
1170 Vector8us c = a.SignedPackWithUnsignedSaturation (b);
1172 if (c.V0 != 0)
1173 return 1;
1174 if (c.V1 != 0xFFFF)
1175 return 2;
1176 if (c.V2 != 3)
1177 return 3;
1178 if (c.V3 != 4)
1179 return 4;
1180 if (c.V4 != 5)
1181 return 5;
1182 if (c.V5 != 6)
1183 return 6;
1184 if (c.V6 != 7)
1185 return 7;
1186 if (c.V7 != 8)
1187 return 8;
1188 return 0;
1191 public static int test_0_vector8us_pack_with_sat () {
1192 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1193 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1194 Vector16b c = a.SignedPackWithUnsignedSaturation (b);
1196 if (c.V0 != 0)
1197 return 1;
1198 if (c.V1 != 1)
1199 return 2;
1200 if (c.V2 != 2)
1201 return 3;
1202 if (c.V8 != 3)
1203 return 4;
1204 if (c.V15 != 10)
1205 return 5;
1206 return 0;
1209 public static int test_0_vector8us_mul_high () {
1210 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
1211 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
1212 Vector8us c = a.MultiplyStoreHigh (b);
1214 if (c.V0 != 0xFE01)
1215 return 1;
1216 if (c.V1 != 0)
1217 return 2;
1218 if (c.V2 != 0)
1219 return 3;
1220 if (c.V3 != 0)
1221 return 4;
1222 if (c.V4 != 0)
1223 return 5;
1224 if (c.V5 != 0)
1225 return 6;
1226 if (c.V6 != 0)
1227 return 7;
1228 if (c.V7 != 0)
1229 return 8;
1230 return 0;
1233 public static int test_0_vector8us_cmpeq () {
1234 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
1235 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
1236 Vector8us c = a.CompareEqual (b);
1238 if (c.V0 != 0)
1239 return 1;
1240 if (c.V1 != 0xFFFF)
1241 return 2;
1242 if (c.V2 != 0)
1243 return 3;
1244 if (c.V3 != 0)
1245 return 4;
1246 if (c.V4 != 0)
1247 return 5;
1248 if (c.V5 != 0xFFFF)
1249 return 6;
1250 if (c.V6 != 0xFFFF)
1251 return 7;
1252 if (c.V7 != 0)
1253 return 8;
1254 return 0;
1258 public static int test_0_vector4ui_cmpeq () {
1259 Vector4ui a = new Vector4ui (6,1,6,3);
1260 Vector4ui b = new Vector4ui (3,4,6,7);
1261 Vector4ui c = a.CompareEqual (b);
1263 if (c.X != 0)
1264 return 1;
1265 if (c.Y != 0)
1266 return 2;
1267 if (c.Z != 0xFFFFFFFF)
1268 return 3;
1269 if (c.W != 0)
1270 return 4;
1271 return 0;
1274 public static int test_0_vector4ui_shuffle () {
1275 Vector4ui a = new Vector4ui (1,2,3,4);
1276 Vector4ui c = a.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1278 if (c.X != 2)
1279 return 1;
1280 if (c.Y != 4)
1281 return 2;
1282 if (c.Z != 1)
1283 return 3;
1284 if (c.W != 3)
1285 return 4;
1286 return 0;
1289 public static int test_0_vector4ui_min () {
1290 Vector4ui a = new Vector4ui (6,1,6,3);
1291 Vector4ui b = new Vector4ui (3,4,6,7);
1292 Vector4ui c = a.Min (b);
1294 if (c.X != 3)
1295 return 1;
1296 if (c.Y != 1)
1297 return 2;
1298 if (c.Z != 6)
1299 return 3;
1300 if (c.W != 3)
1301 return 4;
1302 return 0;
1305 public static int test_0_vector4ui_max () {
1306 Vector4ui a = new Vector4ui (6,1,6,3);
1307 Vector4ui b = new Vector4ui (3,4,6,7);
1308 Vector4ui c = a.Max (b);
1310 if (c.X != 6)
1311 return 1;
1312 if (c.Y != 4)
1313 return 2;
1314 if (c.Z != 6)
1315 return 3;
1316 if (c.W != 7)
1317 return 4;
1318 return 0;
1321 public static int vector16b_cmpeq () {
1322 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
1323 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
1324 Vector16b c = a.CompareEqual (b);
1326 if (c.V0 != 0)
1327 return 1;
1328 if (c.V1 != 0)
1329 return 2;
1330 if (c.V2 != 0)
1331 return 3;
1332 if (c.V3 != 0xff)
1333 return 4;
1334 if (c.V4 != 0xff)
1335 return 5;
1336 if (c.V5 != 0xff)
1337 return 6;
1338 if (c.V6 != 0xff)
1339 return 7;
1340 if (c.V7 != 0xff)
1341 return 8;
1342 if (c.V8 != 0xff)
1343 return 9;
1344 if (c.V9 != 0xff)
1345 return 10;
1346 if (c.V10 != 0xff)
1347 return 11;
1348 if (c.V11 != 0xff)
1349 return 12;
1350 if (c.V12 != 0xff)
1351 return 13;
1352 if (c.V13 != 0xff)
1353 return 14;
1354 if (c.V14 != 0xff)
1355 return 15;
1356 if (c.V15 != 0)
1357 return 16;
1358 return 0;
1362 public static int vector16b_sum_abs_diff () {
1363 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
1364 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
1365 Vector8us c = a.SumOfAbsoluteDifferences (b);
1367 if (c.V0 != 130)
1368 return 1;
1369 if (c.V1 != 0)
1370 return 2;
1371 if (c.V2 != 0)
1372 return 3;
1373 if (c.V3 != 0)
1374 return 4;
1375 if (c.V4 != 20)
1376 return 5;
1377 if (c.V5 != 0)
1378 return 6;
1379 if (c.V6 != 0)
1380 return 7;
1381 if (c.V7 != 0)
1382 return 8;
1383 return 0;
1387 public static int test_0_vector16b_extract_mask () {
1388 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
1389 int c = a.ExtractByteMask ();
1391 if (c != 0x4C5)
1392 return 1;
1393 return 0;
1396 public static int test_0_vector16b_min () {
1397 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
1398 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1399 Vector16b c = a.Min (b);
1401 if (c.V0 != 0)
1402 return 1;
1403 if (c.V1 != 10)
1404 return 2;
1405 if (c.V2 != 11)
1406 return 3;
1407 if (c.V3 != 12)
1408 return 4;
1409 if (c.V4 != 4)
1410 return 5;
1411 if (c.V5 != 5)
1412 return 6;
1413 if (c.V6 != 6)
1414 return 7;
1415 if (c.V7 != 0)
1416 return 8;
1417 if (c.V8 != 1)
1418 return 9;
1419 if (c.V9 != 2)
1420 return 10;
1421 if (c.V10 != 3)
1422 return 11;
1423 if (c.V11 != 4)
1424 return 12;
1425 if (c.V12 != 5)
1426 return 13;
1427 if (c.V13 != 6)
1428 return 14;
1429 if (c.V14 != 7)
1430 return 15;
1431 if (c.V15 != 8)
1432 return 16;
1433 return 0;
1436 public static int test_0_vector16b_max () {
1437 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
1438 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1439 Vector16b c = a.Max (b);
1441 if (c.V0 != 9)
1442 return 1;
1443 if (c.V1 != 12)
1444 return 2;
1445 if (c.V2 != 20)
1446 return 3;
1447 if (c.V3 != 12)
1448 return 4;
1449 if (c.V4 != 13)
1450 return 5;
1451 if (c.V5 != 14)
1452 return 6;
1453 if (c.V6 != 15)
1454 return 7;
1455 if (c.V7 != 7)
1456 return 8;
1457 if (c.V8 != 8)
1458 return 9;
1459 if (c.V9 != 9)
1460 return 10;
1461 if (c.V10 != 10)
1462 return 11;
1463 if (c.V11 != 11)
1464 return 12;
1465 if (c.V12 != 12)
1466 return 13;
1467 if (c.V13 != 13)
1468 return 14;
1469 if (c.V14 != 14)
1470 return 15;
1471 if (c.V15 != 15)
1472 return 16;
1473 return 0;
1475 public static int test_0_vector16b_avg () {
1476 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1477 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1478 Vector16b c = a.Average (b);
1480 if (c.V0 != 5)
1481 return 1;
1482 if (c.V1 != 6)
1483 return 2;
1484 if (c.V2 != 7)
1485 return 3;
1486 if (c.V3 != 8)
1487 return 4;
1488 if (c.V4 != 9)
1489 return 5;
1490 if (c.V5 != 10)
1491 return 6;
1492 if (c.V6 != 11)
1493 return 7;
1494 if (c.V7 != 4)
1495 return 8;
1496 if (c.V8 != 5)
1497 return 9;
1498 if (c.V9 != 6)
1499 return 10;
1500 if (c.V10 != 7)
1501 return 11;
1502 if (c.V11 != 8)
1503 return 12;
1504 if (c.V12 != 9)
1505 return 13;
1506 if (c.V13 != 10)
1507 return 14;
1508 if (c.V14 != 11)
1509 return 15;
1510 if (c.V15 != 12)
1511 return 16;
1512 return 0;
1516 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
1517 Vector8us res = new Vector8us ();
1518 byte *a = (byte*)&va;
1519 byte *b = (byte*)&vb;
1521 int tmp = 0;
1522 for (int i = 0; i < 8; ++i)
1523 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1524 res.V0 = (ushort)tmp;
1526 tmp = 0;
1527 for (int i = 0; i < 8; ++i)
1528 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1529 res.V4 = (ushort)tmp;
1530 return res;
1533 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
1534 public static int test_2_local_simplifier_regression_other_blocks () {
1535 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
1536 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
1537 Vector8us res = bad_method_regression_2 (a,b);
1538 return (int)res.V0 + res.V4;
1541 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
1542 Vector8us res = new Vector8us ();
1543 byte *a = (byte*)&va;
1544 byte *b = (byte*)&vb;
1545 *((ushort*)&res) = 10;
1547 int tmp = 0;
1548 if (*b != 0)
1549 tmp++;
1551 Vector8us dd = res;
1552 dd = dd + dd - dd;
1553 return dd;
1556 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
1557 public static int test_10_local_simplifier_regression_first_block () {
1558 Vector16b a = new Vector16b ();
1559 Vector16b b = new Vector16b ();
1560 Vector8us res = bad_method_regression (a,b);
1561 return (int)res.V0;
1564 public static int test_0_vecto8us_shuffle_low () {
1565 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1566 Vector8us c = a.ShuffleLow (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1568 if (c.V0 != 2)
1569 return 1;
1570 if (c.V1 != 4)
1571 return 2;
1572 if (c.V2 != 1)
1573 return 3;
1574 if (c.V3 != 3)
1575 return 4;
1576 if (c.V4 != 5)
1577 return 5;
1578 if (c.V5 != 6)
1579 return 6;
1580 if (c.V6 != 7)
1581 return 7;
1582 if (c.V7 != 8)
1583 return 8;
1584 return 0;
1587 public static int test_0_vecto8us_shuffle_high () {
1588 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1589 Vector8us c = a.ShuffleHigh (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1591 if (c.V0 != 1)
1592 return 1;
1593 if (c.V1 != 2)
1594 return 2;
1595 if (c.V2 != 3)
1596 return 3;
1597 if (c.V3 != 4)
1598 return 4;
1599 if (c.V4 != 6)
1600 return 5;
1601 if (c.V5 != 8)
1602 return 6;
1603 if (c.V6 != 5)
1604 return 7;
1605 if (c.V7 != 7)
1606 return 8;
1608 return 0;
1611 public static int test_0_vecto8us_max () {
1612 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1613 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
1614 Vector8us c = a.Max (b);
1616 if (c.V0 != 9)
1617 return 1;
1618 if (c.V1 != 2)
1619 return 2;
1620 if (c.V2 != 3)
1621 return 3;
1622 if (c.V3 != 4)
1623 return 4;
1624 if (c.V4 != 9)
1625 return 5;
1626 if (c.V5 != 6)
1627 return 6;
1628 if (c.V6 != 7)
1629 return 7;
1630 if (c.V7 != 1000)
1631 return 0;
1633 return 0;
1636 public static int test_0_vecto8us_min () {
1637 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
1638 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1639 Vector8us c = a.Min (b);
1641 if (c.V0 != 1)
1642 return 1;
1643 if (c.V1 != 1)
1644 return 2;
1645 if (c.V2 != 1)
1646 return 3;
1647 if (c.V3 != 0)
1648 return 4;
1649 if (c.V4 != 3)
1650 return 5;
1651 if (c.V5 != 4)
1652 return 6;
1653 if (c.V6 != 5)
1654 return 7;
1655 if (c.V7 != 4)
1656 return 8;
1657 return 0;
1660 public static int test_0_vecto8us_avg () {
1661 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1662 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1663 Vector8us c = a.Average (b);
1665 if (c.V0 != 5)
1666 return 1;
1667 if (c.V1 != 2)
1668 return 2;
1669 if (c.V2 != 2)
1670 return 3;
1671 if (c.V3 != 3)
1672 return 4;
1673 if (c.V4 != 4)
1674 return 5;
1675 if (c.V5 != 5)
1676 return 6;
1677 if (c.V6 != 6)
1678 return 7;
1679 if (c.V7 != 7)
1680 return 8;
1681 return 0;
1684 static void store_helper (ref Vector4f x) {
1685 Vector4f k;
1686 k = new Vector4f(9,9,9,9);
1687 x = k;
1690 public static int test_0_vector4f_byref_store ()
1692 Vector4f k;
1693 k = new Vector4f(1,2,3,4);
1694 store_helper (ref k);
1695 if (k.X != 9)
1696 return 1;
1697 return 0;
1700 public static int test_0_vector4f_init_array_element ()
1702 Vector4f[] v = new Vector4f[1];
1703 v[0] = new Vector4f(9,9,9,9);
1704 if (v [0].X != 9)
1705 return 1;
1706 return 0;
1709 public static int test_0_vector4f_dup_high () {
1710 Vector4f a = new Vector4f (1, 2, 3, 4);
1711 Vector4f c = a.DuplicateHigh();
1713 if (c.X != 2)
1714 return 1;
1715 if (c.Y != 2)
1716 return 2;
1717 if (c.Z != 4)
1718 return 3;
1719 if (c.W != 4)
1720 return 4;
1721 return 0;
1724 public static int test_0_vector4f_dup_low () {
1725 Vector4f a = new Vector4f (1, 2, 3, 4);
1726 Vector4f c = a.DuplicateLow ();
1728 if (c.X != 1)
1729 return 1;
1730 if (c.Y != 1)
1731 return 2;
1732 if (c.Z != 3)
1733 return 3;
1734 if (c.W != 3)
1735 return 4;
1736 return 0;
1740 public static int test_0_vector4f_interleave_high () {
1741 Vector4f a = new Vector4f (1, 2, 3, 4);
1742 Vector4f b = new Vector4f (5, 6, 7, 8);
1743 Vector4f c = a.InterleaveHigh (b);
1745 if (c.X != 3)
1746 return 1;
1747 if (c.Y != 7)
1748 return 2;
1749 if (c.Z != 4)
1750 return 3;
1751 if (c.W != 8)
1752 return 4;
1753 return 0;
1756 public static int test_0_vector4f_interleave_low () {
1757 Vector4f a = new Vector4f (1, 2, 3, 4);
1758 Vector4f b = new Vector4f (5, 6, 7, 8);
1759 Vector4f c = a.InterleaveLow (b);
1761 if (c.X != 1)
1762 return 1;
1763 if (c.Y != 5)
1764 return 2;
1765 if (c.Z != 2)
1766 return 3;
1767 if (c.W != 6)
1768 return 4;
1769 return 0;
1772 public static int test_0_vector4f_rcp () {
1773 Vector4f a = new Vector4f (1, 2, 4, 8);
1774 Vector4f c = a.Reciprocal ();
1776 //Test with ranges due to the terrible precision.
1777 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
1778 return 1;
1779 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
1780 return 2;
1781 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
1782 return 3;
1783 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
1784 return 4;
1785 return 0;
1788 public static int test_0_vector4f_xor () {
1789 Vector4f a = new Vector4f (1, 2, 3, 4);
1790 Vector4f b = new Vector4f (1, 3, 3, 8);
1791 Vector4f c = a ^ b;
1793 if (((Vector4ui)c).X != 0)
1794 return 1;
1795 if (((Vector4ui)c).Y != 0x400000)
1796 return 2;
1797 if (((Vector4ui)c).Z != 0)
1798 return 3;
1799 if (((Vector4ui)c).W != 0x1800000)
1800 return 4;
1801 return 0;
1804 public static int test_0_vector4f_or () {
1805 Vector4f a = new Vector4f (1, 2, 3, 4);
1806 Vector4f b = new Vector4f (1, 3, 3, 8);
1807 Vector4f c = a | b;
1809 if (((Vector4ui)c).X != 0x3F800000)
1810 return 1;
1811 if (((Vector4ui)c).Y != 0x40400000)
1812 return 2;
1813 if (((Vector4ui)c).Z != 0x40400000)
1814 return 3;
1815 if (((Vector4ui)c).W != 0x41800000)
1816 return 4;
1817 return 0;
1819 public static int test_0_vector4f_andn () {
1820 Vector4f a = new Vector4f (1, 2, 3, 4);
1821 Vector4f b = new Vector4f (1, 3, 3, 8);
1822 Vector4f c = a.AndNot (b);
1824 if (((Vector4ui)c).X != 0)
1825 return 1;
1826 if (((Vector4ui)c).Y != 0x400000)
1827 return 2;
1828 if (((Vector4ui)c).Z != 0)
1829 return 3;
1830 if (((Vector4ui)c).W != 0x1000000)
1831 return 4;
1832 return 0;
1835 public static int test_0_vector4f_and () {
1836 Vector4f a = new Vector4f (1, 2, 3, 4);
1837 Vector4f b = new Vector4f (1, 3, 3, 8);
1838 Vector4f c = a & b;
1840 if (((Vector4ui)c).X != 0x3F800000)
1841 return 1;
1842 if (((Vector4ui)c).Y != 0x40000000)
1843 return 2;
1844 if (((Vector4ui)c).Z != 0x40400000)
1845 return 3;
1846 if (((Vector4ui)c).W != 0x40000000)
1847 return 4;
1848 return 0;
1851 public static int test_0_vector4f_cmpord () {
1852 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1853 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1854 Vector4f c = a.CompareOrdered (b);
1856 if (((Vector4ui)c).X != 0)
1857 return 1;
1858 if (((Vector4ui)c).Y != 0)
1859 return 2;
1860 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1861 return 3;
1862 if (((Vector4ui)c).W != 0xFFFFFFFF)
1863 return 4;
1864 return 0;
1867 public static int test_0_vector4f_cmpnle () {
1868 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1869 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1870 Vector4f c = a.CompareNotLessEqual (b);
1872 if (((Vector4ui)c).X != 0xFFFFFFFF)
1873 return 1;
1874 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1875 return 2;
1876 if (((Vector4ui)c).Z != 0)
1877 return 3;
1878 if (((Vector4ui)c).W != 0)
1879 return 4;
1880 return 0;
1883 public static int test_0_vector4f_cmpnlt () {
1884 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1885 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1886 Vector4f c = a.CompareNotLessThan (b);
1888 if (((Vector4ui)c).X != 0xFFFFFFFF)
1889 return 1;
1890 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1891 return 2;
1892 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1893 return 3;
1894 if (((Vector4ui)c).W != 0)
1895 return 4;
1896 return 0;
1899 public static int test_0_vector4f_cmpneq () {
1900 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1901 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1902 Vector4f c = a.CompareNotEqual (b);
1904 if (((Vector4ui)c).X != 0xFFFFFFFF)
1905 return 1;
1906 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1907 return 2;
1908 if (((Vector4ui)c).Z != 0)
1909 return 3;
1910 if (((Vector4ui)c).W != 0xFFFFFFFF)
1911 return 4;
1912 return 0;
1915 public static int test_0_vector4f_cmpunord () {
1916 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1917 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1918 Vector4f c = a.CompareUnordered (b);
1920 if (((Vector4ui)c).X != 0xFFFFFFFF)
1921 return 1;
1922 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1923 return 2;
1924 if (((Vector4ui)c).Z != 0)
1925 return 3;
1926 if (((Vector4ui)c).W != 0)
1927 return 4;
1928 return 0;
1931 public static int test_0_vector4f_cmple () {
1932 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1933 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1934 Vector4f c = a.CompareLessEqual (b);
1936 if (((Vector4ui)c).X != 0)
1937 return 1;
1938 if (((Vector4ui)c).Y != 0)
1939 return 2;
1940 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1941 return 3;
1942 if (((Vector4ui)c).W != 0xFFFFFFFF)
1943 return 4;
1944 return 0;
1947 public static int test_0_vector4f_cmplt () {
1948 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1949 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1950 Vector4f c = a.CompareLessThan (b);
1952 if (((Vector4ui)c).X != 0)
1953 return 1;
1954 if (((Vector4ui)c).Y != 0)
1955 return 2;
1956 if (((Vector4ui)c).Z != 0)
1957 return 3;
1958 if (((Vector4ui)c).W != 0xFFFFFFFF)
1959 return 4;
1960 return 0;
1963 public static int test_0_vector4f_cmpeq () {
1964 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
1965 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
1966 Vector4f c = a.CompareEqual (b);
1968 if (((Vector4ui)c).X != 0)
1969 return 1;
1970 if (((Vector4ui)c).Y != 0)
1971 return 2;
1972 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1973 return 3;
1974 if (((Vector4ui)c).W != 0)
1975 return 4;
1976 return 0;
1979 public static int test_0_vector4ui_sar () {
1980 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1982 Vector4ui c = a.ArithmeticRightShift (2);
1984 if (c.X != 0xFC000000)
1985 return 1;
1986 if (c.Y != 5)
1987 return 2;
1988 if (c.Z != 0)
1989 return 3;
1990 if (c.W != 10)
1991 return 4;
1992 return 0;
1995 public static int test_0_vector4ui_unpack_high () {
1996 Vector4ui a = new Vector4ui (1,2,3,4);
1997 Vector4ui b = new Vector4ui (5,6,7,8);
1999 Vector4ui c = a.UnpackHigh(b);
2001 if (c.X != 3)
2002 return 1;
2003 if (c.Y != 7)
2004 return 2;
2005 if (c.Z != 4)
2006 return 3;
2007 if (c.W != 8)
2008 return 4;
2009 return 0;
2012 public static int test_0_vector4ui_unpack_low () {
2013 Vector4ui a = new Vector4ui (1,2,3,4);
2014 Vector4ui b = new Vector4ui (5,6,7,8);
2016 Vector4ui c = a.UnpackLow (b);
2018 if (c.X != 1)
2019 return 1;
2020 if (c.Y != 5)
2021 return 2;
2022 if (c.Z != 2)
2023 return 3;
2024 if (c.W != 6)
2025 return 4;
2026 return 0;
2029 public static int test_0_vector4ui_xor () {
2030 Vector4ui a = new Vector4ui (1,2,3,4);
2031 Vector4ui b = new Vector4ui (7,5,3,1);
2033 Vector4ui c = a ^ b;
2035 if (c.X != 6)
2036 return 1;
2037 if (c.Y != 7)
2038 return 2;
2039 if (c.Z != 0)
2040 return 3;
2041 if (c.W != 5)
2042 return 4;
2043 return 0;
2046 public static int test_0_vector4ui_or () {
2047 Vector4ui a = new Vector4ui (1,2,3,4);
2048 Vector4ui b = new Vector4ui (7,5,3,1);
2050 Vector4ui c = a | b;
2052 if (c.X != 7)
2053 return 1;
2054 if (c.Y != 7)
2055 return 2;
2056 if (c.Z != 3)
2057 return 3;
2058 if (c.W != 5)
2059 return 4;
2060 return 0;
2062 public static int test_0_vector4ui_and () {
2063 Vector4ui a = new Vector4ui (1,2,3,4);
2064 Vector4ui b = new Vector4ui (7,5,3,1);
2066 Vector4ui c = a & b;
2068 if (c.X != 1)
2069 return 1;
2070 if (c.Y != 0)
2071 return 2;
2072 if (c.Z != 3)
2073 return 3;
2074 if (c.W != 0)
2075 return 4;
2076 return 0;
2079 public static int test_0_vector4ui_shr () {
2080 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
2082 Vector4ui c = a >> 2;
2084 if (c.X != 0x3C000000)
2085 return 1;
2086 if (c.Y != 5)
2087 return 2;
2088 if (c.Z != 0)
2089 return 3;
2090 if (c.W != 10)
2091 return 4;
2092 return 0;
2095 public static int test_0_vector4ui_shl () {
2096 Vector4ui a = new Vector4ui (10,20,3,40);
2098 Vector4ui c = a << 2;
2100 if (c.X != 40)
2101 return 1;
2102 if (c.Y != 80)
2103 return 2;
2104 if (c.Z != 12)
2105 return 3;
2106 if (c.W != 160)
2107 return 4;
2108 return 0;
2111 public static int test_0_vector4ui_mul () {
2112 Vector4ui a = new Vector4ui (0x8888,20,3,40);
2113 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
2115 Vector4ui c = a * b;
2117 if (c.X != 0xffff7800)
2118 return 1;
2119 if (c.Y != 40)
2120 return 2;
2121 if (c.Z != 9)
2122 return 3;
2123 if (c.W != 160)
2124 return 4;
2125 return 0;
2127 public static int test_0_vector4ui_sub () {
2128 Vector4ui a = new Vector4ui (1,20,3,40);
2129 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
2131 Vector4ui c = a - b;
2133 if (c.X != 0xff0101)
2134 return 1;
2135 if (c.Y != 18)
2136 return 2;
2137 if (c.Z != 0)
2138 return 3;
2139 if (c.W != 36)
2140 return 4;
2141 return 0;
2144 public static int test_0_vector4ui_add () {
2145 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
2146 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
2148 Vector4ui c = a + b;
2150 if (c.X != 0xfe01fe00)
2151 return 1;
2152 if (c.Y != 4)
2153 return 2;
2154 if (c.Z != 6)
2155 return 3;
2156 if (c.W != 8)
2157 return 4;
2158 return 0;
2162 static int test_0_vector4ui_accessors () {
2163 Vector4ui a = new Vector4ui (1,2,3,4);
2165 if (a.X != 1)
2166 return 1;
2167 if (a.Y != 2)
2168 return 2;
2169 if (a.Z != 3)
2170 return 3;
2171 if (a.W != 4)
2172 return 4;
2173 a.X = 10;
2174 a.Y = 20;
2175 a.Z = 30;
2176 a.W = 40;
2178 if (a.X != 10)
2179 return 5;
2180 if (a.Y != 20)
2181 return 6;
2182 if (a.Z != 30)
2183 return 7;
2184 if (a.W != 40)
2185 return 8;
2186 return 0;
2189 static int test_0_vector8us_sub_sat () {
2190 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
2191 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
2192 Vector8us c = a.SubtractWithSaturation (b);
2194 if (c.V0 != 0)
2195 return 1;
2196 if (c.V1 != 0)
2197 return 2;
2198 if (c.V2 != 15)
2199 return 3;
2200 if (c.V3 != 0)
2201 return 4;
2202 if (c.V4 != 0)
2203 return 5;
2204 if (c.V5 != 0)
2205 return 6;
2206 if (c.V6 != 0)
2207 return 7;
2208 if (c.V7 != 0)
2209 return 8;
2210 return 0;
2213 static int test_0_vector8us_add_sat () {
2214 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
2215 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
2216 Vector8us c = a.AddWithSaturation (b);
2218 if (c.V0 != 0xFFFF)
2219 return 1;
2220 if (c.V1 != 5)
2221 return 2;
2222 if (c.V2 != 7)
2223 return 3;
2224 if (c.V3 != 9)
2225 return 4;
2226 if (c.V4 != 11)
2227 return 5;
2228 if (c.V5 != 13)
2229 return 6;
2230 if (c.V6 != 15)
2231 return 7;
2232 if (c.V7 != 17)
2233 return 8;
2234 return 0;
2237 static int test_0_vector8us_unpack_low () {
2238 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
2239 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
2240 Vector8us c = a.UnpackLow (b);
2242 if (c.V0 != 0)
2243 return 1;
2244 if (c.V1 != 3)
2245 return 2;
2246 if (c.V2 != 1)
2247 return 3;
2248 if (c.V3 != 4)
2249 return 4;
2250 if (c.V4 != 2)
2251 return 5;
2252 if (c.V5 != 5)
2253 return 6;
2254 if (c.V6 != 3)
2255 return 7;
2256 if (c.V7 != 6)
2257 return 8;
2258 return 0;
2262 static int test_0_vector8us_shift_left () {
2263 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
2264 int amt = 2;
2265 Vector8us c = a << amt;
2267 if (c.V0 != 0xFC00)
2268 return 1;
2269 if (c.V1 != 4)
2270 return 2;
2271 if (c.V7 != 28)
2272 return 3;
2273 return 0;
2276 static int test_0_vector8us_shift_right_arithmetic () {
2277 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
2278 int amt = 2;
2279 Vector8us c = a.ArithmeticRightShift (amt);
2281 if (c.V0 != 0xFFC0)
2282 return 1;
2283 if (c.V1 != 0)
2284 return 2;
2285 if (c.V7 != 1)
2286 return 3;
2287 return 0;
2290 static int test_0_vector8us_shift_variable_offset () {
2291 int off = 2;
2292 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
2293 Vector8us b = a;
2294 Vector8us c = b >> off;
2295 a = b + b;
2297 if (c.V0 != 0x3C00)
2298 return 1;
2299 if (c.V1 != 0)
2300 return 2;
2301 if (c.V7 != 1)
2302 return 3;
2303 if (a.V1 != 2)
2304 return 4;
2305 if (a.V7 != 14)
2306 return 5;
2307 return 0;
2311 static int test_0_vector8us_shift_operand_is_live_after_op () {
2312 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
2313 Vector8us b = a;
2314 Vector8us c = b >> 2;
2315 a = b + b;
2317 if (c.V0 != 0x3C00)
2318 return 1;
2319 if (c.V1 != 0)
2320 return 2;
2321 if (c.V7 != 1)
2322 return 3;
2323 if (a.V1 != 2)
2324 return 4;
2325 if (a.V7 != 14)
2326 return 5;
2327 return 0;
2330 static int test_0_vector8us_shr_constant () {
2331 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
2332 Vector8us c = a >> 2;
2334 if (c.V0 != 0x3C00)
2335 return 1;
2336 if (c.V1 != 0)
2337 return 2;
2338 if (c.V7 != 1)
2339 return 3;
2340 return 0;
2343 static int test_0_vector8us_mul () {
2344 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
2345 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
2347 Vector8us c = a * b;
2348 if (c.V0 != 63488)
2349 return 1;
2350 if (c.V1 != 4)
2351 return 2;
2352 if (c.V7 != 80)
2353 return 3;
2354 return 0;
2357 static int test_0_vector8us_add () {
2358 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
2359 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
2361 Vector8us c = a + b;
2362 if (c.V0 != 34696)
2363 return 1;
2364 if (c.V1 != 5)
2365 return 2;
2366 if (c.V7 != 18)
2367 return 3;
2368 return 0;
2372 static int test_0_vector8us_sub () {
2373 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
2374 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
2376 Vector8us c = a - b;
2378 if (c.V0 != 65529)
2379 return 1;
2380 if (c.V1 != 3)
2381 return 2;
2382 if (c.V7 != 2)
2383 return 3;
2384 return 0;
2388 static int test_0_vector8us_accessors () {
2389 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
2391 if (a.V0 != 0)
2392 return 1;
2393 if (a.V1 != 1)
2394 return 2;
2395 if (a.V2 != 2)
2396 return 3;
2397 if (a.V3 != 3)
2398 return 4;
2399 if (a.V4 != 4)
2400 return 5;
2401 if (a.V5 != 5)
2402 return 6;
2403 if (a.V6 != 6)
2404 return 7;
2405 if (a.V7 != 7)
2406 return 8;
2407 a.V0 = 10;
2408 a.V1 = 20;
2409 a.V2 = 30;
2410 a.V3 = 40;
2411 a.V4 = 50;
2412 a.V5 = 60;
2413 a.V6 = 70;
2414 a.V7 = 80;
2416 if (a.V0 != 10)
2417 return 17;
2418 if (a.V1 != 20)
2419 return 18;
2420 if (a.V2 != 30)
2421 return 19;
2422 if (a.V3 != 40)
2423 return 20;
2424 if (a.V4 != 50)
2425 return 21;
2426 if (a.V5 != 60)
2427 return 22;
2428 if (a.V6 != 70)
2429 return 23;
2430 if (a.V7 != 80)
2431 return 24;
2433 return 0;
2437 static int test_0_vector16b_unpack_high () {
2438 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2439 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2440 Vector16b c = a.UnpackHigh (b);
2442 if (c.V0 != 8)
2443 return 1;
2444 if (c.V1 != 1)
2445 return 2;
2446 if (c.V2 != 9)
2447 return 3;
2448 if (c.V3 != 2)
2449 return 4;
2450 if (c.V4 != 10)
2451 return 5;
2452 if (c.V5 != 3)
2453 return 6;
2454 if (c.V14 != 15)
2455 return 7;
2456 if (c.V15 != 8)
2457 return 8;
2458 return 0;
2461 static int test_0_vector16b_unpack_low () {
2462 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2463 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2464 Vector16b c = a.UnpackLow (b);
2466 if (c.V0 != 0)
2467 return 1;
2468 if (c.V1 != 9)
2469 return 2;
2470 if (c.V2 != 1)
2471 return 3;
2472 if (c.V3 != 10)
2473 return 4;
2474 if (c.V4 != 2)
2475 return 5;
2476 if (c.V5 != 11)
2477 return 6;
2478 if (c.V14 != 7)
2479 return 7;
2480 if (c.V15 != 0)
2481 return 8;
2482 return 0;
2485 static int test_0_vector16b_sub_sat () {
2486 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2487 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2488 Vector16b c = a.SubtractWithSaturation (b);
2490 if (c.V0 != 0)
2491 return 1;
2492 if (c.V1 != 9)
2493 return 2;
2494 if (c.V15 != 0)
2495 return 3;
2496 return 0;
2499 static int test_0_vector16b_add_sat () {
2500 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2501 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2502 Vector16b c = a.AddWithSaturation (b);
2504 if (c.V0 != 255)
2505 return 1;
2506 if (c.V1 != 11)
2507 return 2;
2508 if (c.V15 != 23)
2509 return 3;
2510 return 0;
2513 static int test_0_vector16b_add_ovf () {
2514 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2515 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2516 Vector16b c = a + b;
2518 if (c.V0 != 144)
2519 return 1;
2520 if (c.V1 != 11)
2521 return 2;
2522 if (c.V15 != 23)
2523 return 3;
2524 return 0;
2527 static int test_0_vector16b_accessors () {
2528 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2530 if (a.V0 != 0)
2531 return 1;
2532 if (a.V1 != 1)
2533 return 2;
2534 if (a.V2 != 2)
2535 return 3;
2536 if (a.V3 != 3)
2537 return 4;
2538 if (a.V4 != 4)
2539 return 5;
2540 if (a.V5 != 5)
2541 return 6;
2542 if (a.V6 != 6)
2543 return 7;
2544 if (a.V7 != 7)
2545 return 8;
2546 if (a.V8 != 8)
2547 return 9;
2548 if (a.V9 != 9)
2549 return 10;
2550 if (a.V10 != 10)
2551 return 11;
2552 if (a.V11 != 11)
2553 return 12;
2554 if (a.V12 != 12)
2555 return 13;
2556 if (a.V13 != 13)
2557 return 14;
2558 if (a.V14 != 14)
2559 return 15;
2560 if (a.V15 != 15)
2561 return 16;
2563 a.V0 = 10;
2564 a.V1 = 20;
2565 a.V2 = 30;
2566 a.V3 = 40;
2567 a.V4 = 50;
2568 a.V5 = 60;
2569 a.V6 = 70;
2570 a.V7 = 80;
2571 a.V8 = 90;
2572 a.V9 = 100;
2573 a.V10 = 110;
2574 a.V11 = 120;
2575 a.V12 = 130;
2576 a.V13 = 140;
2577 a.V14 = 150;
2578 a.V15 = 160;
2580 if (a.V0 != 10)
2581 return 17;
2582 if (a.V1 != 20)
2583 return 18;
2584 if (a.V2 != 30)
2585 return 19;
2586 if (a.V3 != 40)
2587 return 20;
2588 if (a.V4 != 50)
2589 return 21;
2590 if (a.V5 != 60)
2591 return 22;
2592 if (a.V6 != 70)
2593 return 23;
2594 if (a.V7 != 80)
2595 return 24;
2596 if (a.V8 != 90)
2597 return 25;
2598 if (a.V9 != 100)
2599 return 26;
2600 if (a.V10 != 110)
2601 return 27;
2602 if (a.V11 != 120)
2603 return 28;
2604 if (a.V12 != 130)
2605 return 29;
2606 if (a.V13 != 140)
2607 return 30;
2608 if (a.V14 != 150)
2609 return 31;
2610 if (a.V15 != 160)
2611 return 32;
2612 return 0;
2615 public static int test_0_accessors () {
2616 Vector4f a = new Vector4f (1, 2, 3, 4);
2617 if (a.X != 1f)
2618 return 1;
2619 if (a.Y != 2f)
2620 return 2;
2621 if (a.Z != 3f)
2622 return 3;
2623 if (a.W != 4f)
2624 return 4;
2625 return 0;
2628 public static int test_0_packed_add_with_stack_tmp () {
2629 Vector4f a = new Vector4f (1, 2, 3, 4);
2630 Vector4f b = new Vector4f (5, 6, 7, 8);
2631 Vector4f c = new Vector4f (-1, -3, -4, -5);
2632 Vector4f d = a + b + c;
2633 if (d.X != 5f)
2634 return 1;
2635 if (d.Y != 5f)
2636 return 2;
2637 if (d.Z != 6f)
2638 return 3;
2639 if (d.W != 7f)
2640 return 4;
2641 return 0;
2644 public static int test_0_simple_packed_add () {
2645 Vector4f a = new Vector4f (1, 2, 3, 4);
2646 Vector4f b = new Vector4f (5, 6, 7, 8);
2647 Vector4f c;
2648 c = a + b;
2649 if (c.X != 6f)
2650 return 1;
2651 if (c.Y != 8f)
2652 return 2;
2653 if (c.Z != 10f)
2654 return 3;
2655 if (c.W != 12f)
2656 return 4;
2657 return 0;
2660 public static int test_0_simple_packed_sub () {
2661 Vector4f a = new Vector4f (1, 2, 3, 4);
2662 Vector4f b = new Vector4f (5, 6, 7, 8);
2663 Vector4f c = b - a;
2664 if (c.X != 4f)
2665 return 1;
2666 if (c.Y != 4f)
2667 return 2;
2668 if (c.Z != 4f)
2669 return 3;
2670 if (c.W != 4f)
2671 return 4;
2672 return 0;
2675 public static int test_0_simple_packed_mul () {
2676 Vector4f a = new Vector4f (1, 2, 3, 4);
2677 Vector4f b = new Vector4f (5, 6, 7, 8);
2678 Vector4f c = b * a;
2679 if (c.X != 5f)
2680 return 1;
2681 if (c.Y != 12f)
2682 return 2;
2683 if (c.Z != 21f)
2684 return 3;
2685 if (c.W != 32f)
2686 return 4;
2687 return 0;
2690 public static int test_0_simple_packed_div () {
2691 Vector4f a = new Vector4f (2, 2, 3, 4);
2692 Vector4f b = new Vector4f (20, 10, 33, 12);
2693 Vector4f c = b / a;
2694 if (c.X != 10f)
2695 return 1;
2696 if (c.Y != 5f)
2697 return 2;
2698 if (c.Z != 11f)
2699 return 3;
2700 if (c.W != 3f)
2701 return 4;
2702 return 0;
2705 public static int test_0_simple_packed_sqrt () {
2706 Vector4f a = new Vector4f (16, 4, 9, 25);
2707 a = a.Sqrt ();
2708 if (a.X != 4f)
2709 return 1;
2710 if (a.Y != 2f)
2711 return 2;
2712 if (a.Z != 3f)
2713 return 3;
2714 if (a.W != 5f)
2715 return 4;
2716 return 0;
2719 public static int test_0_simple_packed_invsqrt () {
2720 Vector4f a = new Vector4f (16, 4, 100, 25);
2721 //this function has VERY low precision
2722 a = a.InvSqrt ();
2723 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
2724 return 1;
2725 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
2726 return 2;
2727 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
2728 return 3;
2729 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
2730 return 4;
2731 return 0;
2734 public static int test_0_simple_packed_min () {
2735 Vector4f a = new Vector4f (16, -4, 9, 25);
2736 Vector4f b = new Vector4f (5, 3, 9, 0);
2737 Vector4f c = a.Min (b);
2738 if (c.X != 5f)
2739 return 1;
2740 if (c.Y != -4f)
2741 return 2;
2742 if (c.Z != 9f)
2743 return 3;
2744 if (c.W != 0f)
2745 return 4;
2746 return 0;
2749 public static int test_0_simple_packed_max () {
2750 Vector4f a = new Vector4f (16, -4, 9, 25);
2751 Vector4f b = new Vector4f (5, 3, 9, 0);
2752 Vector4f c = a.Max (b);
2753 if (c.X != 16f)
2754 return 1;
2755 if (c.Y != 3f)
2756 return 2;
2757 if (c.Z != 9f)
2758 return 3;
2759 if (c.W != 25f)
2760 return 4;
2761 return 0;
2764 public static int test_0_simple_packed_hadd () {
2765 Vector4f a = new Vector4f (5, 5, 6, 6);
2766 Vector4f b = new Vector4f (7, 7, 8, 8);
2767 Vector4f c = a.HorizontalAdd (b);
2768 if (c.X != 10f)
2769 return 1;
2770 if (c.Y != 12f)
2771 return 2;
2772 if (c.Z != 14f)
2773 return 3;
2774 if (c.W != 16f)
2775 return 4;
2776 return 0;
2779 public static int test_0_simple_packed_hsub () {
2780 Vector4f a = new Vector4f (5, 2, 6, 1);
2781 Vector4f b = new Vector4f (7, 0, 8, 3);
2782 Vector4f c = a.HorizontalSub (b);
2783 if (c.X != 3f)
2784 return 1;
2785 if (c.Y != 5f)
2786 return 2;
2787 if (c.Z != 7f)
2788 return 3;
2789 if (c.W != 5f)
2790 return 4;
2791 return 0;
2794 public static int test_0_simple_packed_addsub () {
2795 Vector4f a = new Vector4f (5, 2, 6, 1);
2796 Vector4f b = new Vector4f (7, 0, 8, 3);
2797 Vector4f c = a.AddSub (b);
2798 if (c.X != -2f)
2799 return 1;
2800 if (c.Y != 2f)
2801 return 2;
2802 if (c.Z != -2f)
2803 return 3;
2804 if (c.W != 4f)
2805 return 4;
2806 return 0;
2809 public static int test_0_simple_packed_shuffle () {
2810 Vector4f a = new Vector4f (1, 2, 3, 4);
2811 a = a.Shuffle(ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2812 if (a.X != 2f)
2813 return 1;
2814 if (a.Y != 4f)
2815 return 2;
2816 if (a.Z != 1f)
2817 return 3;
2818 if (a.W != 3f)
2819 return 4;
2820 return 0;
2823 public static int test_0_packed_shuffle_with_reg_pressure () {
2824 Vector4f v = new Vector4f (1, 2, 3, 4);
2825 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
2826 if (ff) v = v + v -v ;
2828 Vector4f r0 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2829 Vector4f r1 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2830 Vector4f x = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2831 Vector4f r2 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2832 Vector4f r3 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2833 Vector4f a = x;
2835 r0 = r0 * m0 + x;
2836 r1 = r1 * m1 + x;
2837 x = x - v + v;
2838 r2 = r2 * m2 + x;
2839 r3 = r3 * m3 + x;
2840 Vector4f result = r0 + r1 + r2 + r3;
2842 if (a.X != 2f)
2843 return 1;
2844 if (a.Y != 4f)
2845 return 2;
2846 if (a.Z != 1f)
2847 return 3;
2848 if (a.W != 3f)
2849 return 4;
2850 if (result.Y != result.Y)
2851 return 0;
2852 return 0;
2855 public static int test_0_double_packed_sqrt () {
2856 Vector2d a = new Vector2d (16, 4);
2857 a = a.Sqrt ();
2858 if (a.X != 4f)
2859 return 1;
2860 if (a.Y != 2f)
2861 return 2;
2862 return 0;
2865 public static int test_24_regs_pressure_a () {
2866 Vector4f a = new Vector4f (1, 2, 3, 4);
2867 Vector4f b = a + a;
2868 Vector4f c = b * a;
2869 Vector4f d = a - b;
2870 c = a + b + c + d;
2871 return (int)c.Z;
2874 public static int test_54_regs_pressure_b () {
2875 Vector4f a = new Vector4f (1, 2, 3, 4);
2876 Vector4f b = a + a;
2877 Vector4f c = b - a;
2878 Vector4f d = c - a;
2879 Vector4f e = a + b + c;
2880 Vector4f f = d - b + a - c;
2881 Vector4f g = a - d * f - c + b;
2882 Vector4f h = a * b - c + e;
2883 Vector4f i = h - g - f - e - d - c - b - a;
2884 Vector4f j = a + b + c + d + e + f + g + h + i;
2885 return (int)j.Z;
2888 public static int test_8_regs_pressure_c () {
2889 Vector4f a = new Vector4f (1, 2, 3, 4);
2890 Vector4f b = a + a;
2891 Vector4f c = b - a;
2892 Vector4f d = c - a;
2893 Vector4f e = a + b + c;
2894 Vector4f f = d - b + a - c;
2895 Vector4f g = a - d * f - c + b;
2896 Vector4f h = a * b - c + e;
2897 Vector4f i = h - g - f - e - d - c - b - a;
2898 Vector4f j = a + b + c + d + e + f + g + h + i;
2899 Vector4f k = j - i - h + e + d - a + b - f + g;
2900 Vector4f l = k * c - j * b - i * e + f - g;
2901 Vector4f m = l - k + j - i + e + f;
2902 Vector4f n = m - j + g - i + e * b + a * d;
2903 Vector4f o = k + j + i * b;
2904 Vector4f p = m + j + i + e + l;
2905 Vector4f q = l * m + j + k;
2906 Vector4f r = p * a + o * b + j * c + m * d + l * e;
2907 Vector4f s = a - b - c - d - e - f - g - h - i - j - k - l - m - p - o - q - r;
2908 Vector4f t = a + b + c + d + e + f + g + h + i + j + k + l + m + p + o + q + r + s;
2909 return (int)t.W;
2912 public static int test_0_regs_pressure_fp_and_simd_share_bank_1 () {
2913 Vector4f a = new Vector4f (4, 3, 2, 1);
2914 float aF = 10f;
2915 Vector4f b = a + a;
2916 float bF = aF + aF;
2917 Vector4f c = b - a;
2918 float cF = bF - aF;
2919 Vector4f d = c - a;
2920 float dF = cF - aF;
2921 Vector4f e = a + b + c;
2922 float eF = aF + bF + cF;
2923 Vector4f f = d - b + a - c;
2924 float fF = dF - bF + aF - cF;
2925 Vector4f g = a - d * f - c + b;
2926 float gF = aF - dF * fF - cF + bF;
2927 Vector4f h = a * b - c + e;
2928 float hF = aF * bF - cF + eF;
2929 Vector4f i = h - g - f - e - d - c - b - a;
2930 float iF = hF - gF - fF - eF - dF - cF - bF - aF;
2931 Vector4f j = a + b + c + d + e + f + g + h + i;
2932 float jF = aF + bF + cF + dF + eF + fF + gF + hF + iF;
2934 if (j.X != 88f)
2935 return 1;
2937 if(jF != 460f)
2938 return 2;
2940 return 0;
2943 public static int test_0_regs_pressure_fp_and_simd_share_bank_2 () {
2944 Vector4f a = new Vector4f (4, 3, 2, 1);
2945 float aF = 10f;
2946 Vector4f b = a + a;
2947 float bF = aF + aF;
2948 Vector4f c = b - a;
2949 float cF = bF - aF;
2950 Vector4f d = c - a;
2951 float dF = cF - aF;
2952 Vector4f e = a + b + c;
2953 float eF = aF + bF + cF;
2954 Vector4f f = d - b + a - c;
2955 float fF = dF - bF + aF - cF;
2956 Vector4f g = a - d * f - c + b;
2957 float gF = aF - dF * fF - cF + bF;
2958 Vector4f h = a * b - c + e;
2959 float hF = aF * bF - cF + eF;
2960 Vector4f i = h - g - f - e - d - c - b - a;
2961 float iF = hF - gF - fF - eF - dF - cF - bF - aF;
2962 Vector4f j = a + b + c + d + e + f + g + h + i;
2963 float jF = aF + bF + cF + dF + eF + fF + gF + hF + iF;
2964 Vector4f k = j - i - h + e + d - a + b - f + g;
2965 float kF = jF - iF - hF + eF + dF - aF + bF - fF + gF;
2966 Vector4f l = k * c - j * b - i * e + f - g;
2967 float lF = kF * cF - jF * bF - iF * eF + fF - gF;
2968 Vector4f m = l - k + j - i + e + f;
2969 float mF = lF - kF + jF - iF + eF + fF;
2970 Vector4f n = m - j + g - i + e * b + a * d;
2971 float nF = mF - jF + gF - iF + eF * bF + aF * dF;
2972 Vector4f o = k + j + i * b;
2973 float oF = kF + jF + iF * bF;
2974 Vector4f p = m + j + i + e + l;
2975 float pF = mF + jF + iF + eF + lF;
2976 Vector4f q = l * m + j + k;
2977 float qF = lF * mF + jF + kF;
2978 Vector4f r = p * a + o * b + j * c + m * d + l * e;
2979 float rF = pF * aF + oF * bF + jF * cF + mF * dF + lF * eF;
2980 Vector4f s = a - b - c - d - e - f - g - h - i - j - k - l - m - p - o - q - r;
2981 float sF = aF - bF - cF - dF - eF - fF - gF - hF - iF - jF - kF - lF - mF - pF - oF - qF - rF;
2982 Vector4f t = a + b + c + d + e + f + g + h + i + j + k + l + m + p + o + q + r + s;
2983 float tF = aF + bF + cF + dF + eF + fF + gF + hF + iF + jF + kF + lF + mF + pF + oF + qF + rF + sF;
2985 if (t.X != 8f)
2986 return 1;
2988 if(tF != 14f)
2989 return 2;
2991 return 0;
2995 public static void call_simd_fp () {
2996 Vector4f a = new Vector4f (20f, 22f, 23f, 24f);
2997 float b = 25f;
2998 Vector4f c = new Vector4f (26f, 27f, 28f, 29f);
2999 float d = 30f;
3001 b += d;
3002 a += c;
3004 public static int test_0_call_fp_and_simd_share_bank () {
3006 float a = 1f;
3007 Vector4f b = new Vector4f (2f, 3f, 4f, 5f);
3008 float c = 6f;
3009 Vector4f d = new Vector4f (7f, 8f, 9f, 10f);
3011 a += c;
3013 b += d;
3015 call_simd_fp ();
3016 if (a != 7f)
3017 return 1;
3018 if (b.X != 9f)
3019 return 2;
3020 if (c != 6f)
3021 return 3;
3022 if (d.X != 7f)
3023 return 4;
3024 if (b.W != 15f)
3025 return 5;
3026 if (d.W != 10f)
3027 return 6;
3030 return 0;
3034 static bool ff;
3035 public static int test_3_single_block_var_is_properly_promoted () {
3036 Vector4f a = new Vector4f (4, 5, 6, 7);
3037 if (ff)
3038 a = a - a;
3039 else {
3040 Vector4f b = new Vector4f (1, 2, 3, 4);
3041 Vector4f c = b;
3042 a = a - b;
3043 if (ff) {
3044 c = a;
3045 a = c;
3048 return (int)a.X;
3051 static float float_val = 45f;
3053 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
3054 Vector4f v = new Vector4f (1, 2, 3, 4);
3055 float f = float_val;
3056 int x = (int)f;
3057 if (v.X != 1f)
3058 return 1;
3059 if (x != 45f)
3060 return 2;
3061 return 0;
3064 public static int test_0_sse41_vector8s_min () {
3065 Vector8s v = new Vector8s(2);
3066 Vector8s v2 = new Vector8s(1);
3067 v = v.Min(v2);
3068 if (v.V0 != 1 || v.V1 != 1 || v.V2 != 1 || v.V3 != 1 || v.V4 != 1 || v.V5 != 1 || v.V6 != 1 || v.V7 != 1)
3069 return 1;
3070 return 0;
3073 public static int test_0_simd_const_indexer_simple () {
3074 Vector4f v = new Vector4f (1, 2, 3, 4);
3076 if (v[0] != 1)
3077 return 1;
3078 if (v[1] != 2)
3079 return 2;
3080 if (v[2] != 3)
3081 return 3;
3082 if (v[3] != 4)
3083 return 4;
3084 return 0;
3087 public static int test_0_simd_var_indexer_simple () {
3088 Vector4f v = new Vector4f (1, 2, 3, 4);
3090 int index = 0;
3092 if (v[index++] != 1)
3093 return 1;
3094 if (v[index++] != 2)
3095 return 2;
3096 if (v[index++] != 3)
3097 return 3;
3098 if (v[index] != 4)
3099 return 4;
3100 return 0;
3103 public static int test_0_simd_const_indexer_double () {
3104 Vector2d v = new Vector2d (1, 2);
3106 if (v[0] != 1)
3107 return 1;
3108 if (v[1] != 2)
3109 return 2;
3110 return 0;
3113 public static int test_0_simd_var_indexer_double () {
3114 Vector2d v = new Vector2d (1, 2);
3116 int index = 0;
3118 if (v[index++] != 1)
3119 return 1;
3120 if (v[index] != 2)
3121 return 2;
3122 return 0;
3126 public static int test_0_scala_vector4f_mul () {
3127 Vector4f a = new Vector4f (1, 2, 3, 4);
3128 Vector4f b = 2 * a;
3129 Vector4f c = a * 3;
3131 if (b.X != 2f || b.Y != 4f || b.Z != 6f || b.W != 8f )
3132 return 1;
3133 if (c.X != 3f || c.Y != 6f || c.Z != 9f || c.W != 12f )
3134 return 1;
3136 return 0;
3139 static void CallMethodThatClobbersRegs () {
3140 Vector4f a = new Vector4f (9,9,9,9);
3141 Vector4f b = new Vector4f (9,9,9,9);
3142 a = a + b;
3145 public static int test_0_call_spills_regs_correctly () {
3146 Vector4f a = new Vector4f (1,2,3,4);
3147 Vector4f b = new Vector4f (5,6,7,8);
3149 CallMethodThatClobbersRegs ();
3151 bool b0 = a.X == 1f;
3152 bool b1 = b.X == 5f;
3153 if (!b0 || !b1)
3154 return 1;
3155 return 0;
3158 public static int test_0_shuffle_with_two_args_pd () {
3159 Vector2d a = new Vector2d (1,2);
3160 Vector2d b = new Vector2d (5,6);
3162 Vector2d c = a.Shuffle (b, 0x2);
3163 if (c.X != 1)
3164 return 1;
3165 if (c.Y != 6)
3166 return 2;
3167 return 0;
3170 public static int test_0_shuffle_with_two_args_ps () {
3171 Vector4f a = new Vector4f (1, 2, 3, 4);
3172 Vector4f b = new Vector4f (5, 6, 7, 8);
3174 Vector4f c = a.Shuffle (b, ShuffleSel.ExpandY);
3175 if (c.X != 2)
3176 return 1;
3177 if (c.Y != 2)
3178 return 2;
3179 if (c.Z != 6)
3180 return 3;
3181 if (c.W != 6)
3182 return 4;
3183 return 0;
3186 public static int test_0_i_to_d () {
3187 var a = new Vector4i (1, 2, 3, 4);
3188 var b = a.ConvertToDouble ();
3189 if (b.X != 1)
3190 return 1;
3191 if (b.Y != 2)
3192 return 2;
3193 return 0;
3196 public static int test_0_i_to_f () {
3197 var a = new Vector4i (1, 2, 3, 4);
3198 var b = a.ConvertToFloat ();
3199 if (b.X != 1)
3200 return 1;
3201 if (b.Y != 2)
3202 return 2;
3203 if (b.Z != 3)
3204 return 3;
3205 if (b.W != 4)
3206 return 4;
3207 return 0;
3210 public static int test_0_d_to_i () {
3211 var a = new Vector2d (1.4, 2.6);
3212 var b = a.ConvertToInt ();
3213 if (b.X != 1)
3214 return 1;
3215 if (b.Y != 3)
3216 return 2;
3217 if (b.Z != 0)
3218 return 3;
3219 if (b.W != 0)
3220 return 4;
3221 return 0;
3224 public static int test_0_d_to_f () {
3225 var a = new Vector2d (1, 2);
3226 var b = a.ConvertToFloat ();
3227 if (b.X != 1)
3228 return 1;
3229 if (b.Y != 2)
3230 return 2;
3231 if (b.Z != 0)
3232 return 3;
3233 if (b.W != 0)
3234 return 4;
3235 return 0;
3238 public static int test_0_f_to_i () {
3239 var a = new Vector4f (1.1f, 2.2f, 3.5f, 4.6f);
3240 var b = a.ConvertToInt ();
3241 if (b.X != 1)
3242 return 1;
3243 if (b.Y != 2)
3244 return 2;
3245 if (b.Z != 4)
3246 return 3;
3247 if (b.W != 5)
3248 return 4;
3249 return 0;
3252 public static int test_0_f_to_d () {
3253 var a = new Vector4f (1,2,3,4);
3254 var b = a.ConvertToDouble ();
3255 if (b.X != 1)
3256 return 1;
3257 if (b.Y != 2)
3258 return 2;
3259 return 0;
3262 public static int test_0_d_to_i_trunc () {
3263 var a = new Vector2d (1.4, 2.6);
3264 var b = a.ConvertToIntTruncated ();
3265 if (b.X != 1)
3266 return 1;
3267 if (b.Y != 2)
3268 return 2;
3269 if (b.Z != 0)
3270 return 3;
3271 if (b.W != 0)
3272 return 4;
3273 return 0;
3276 public static int test_0_f_to_i_trunc () {
3277 var a = new Vector4f (1.1f, 2.2f, 3.5f, 4.6f);
3278 var b = a.ConvertToIntTruncated ();
3279 if (b.X != 1)
3280 return 1;
3281 if (b.Y != 2)
3282 return 2;
3283 if (b.Z != 3)
3284 return 3;
3285 if (b.W != 4)
3286 return 4;
3287 return 0;
3289 public static int Main (String[] args) {
3290 return TestDriver.RunTests (typeof (SimdTests), args);