2008-10-28 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / mini / basic-simd.cs
1 using System;
2 using Mono.Simd;
3
4 public class SimdTests {
5         public static unsafe int test_vector2ul_slr () {
6                 Vector2ul a = new Vector2ul (1, 6);
7
8                 Vector2ul c = a >> 1;
9         
10                 Console.WriteLine (c.X);//0
11                 Console.WriteLine (c.Y);//3
12
13                 return 0;
14                 return 0;
15         }
16
17         public static unsafe int test_vector2l_cmp_gt () {
18                 Vector2l a = new Vector2l (10, 5);
19                 Vector2l b = new Vector2l (-1, 5);
20
21                 Vector2l c = Vector2l.CompareGreaterThan (a, b);
22         
23                 if (c.X != -1)
24                         return 1;
25                 if (c.Y != 0)
26                         return 2;
27                 return 0;
28         }
29
30         public static unsafe int test_vector2l_cmp_eq () {
31                 Vector2l a = new Vector2l (0xFF,          5);
32                 Vector2l b = new Vector2l (0xFF000000FFL, 5);
33
34                 Vector2l c = Vector2l.CompareEqual (a, b);
35         
36                 if (c.X != 0)
37                         return 1;
38                 if (c.Y != -1)
39                         return 2;
40                 return 0;
41         }
42
43         public static unsafe int test_vector2l_srl () {
44                 Vector2l a = new Vector2l (1, 6);
45
46                 Vector2l c = Vector2l.ShiftRightLogic (a, 1);
47         
48                 if (c.X != 0)
49                         return 1;
50                 if (c.Y != 3)
51                         return 2;
52                 return 0;
53         }
54
55         public static unsafe int test_vector2l_unpack_high () {
56                 Vector2l a = new Vector2l (1, 6);
57                 Vector2l b = new Vector2l (3, 4);
58
59                 Vector2l c = Vector2l.UnpackHigh (a, b);
60         
61                 if (c.X != 6)
62                         return 1;
63                 if (c.Y != 4)
64                         return 2;
65                 return 0;
66         }
67
68         public static unsafe int test_vector2l_unpack_low () {
69                 Vector2l a = new Vector2l (1, 6);
70                 Vector2l b = new Vector2l (3, 4);
71
72                 Vector2l c = Vector2l.UnpackLow (a, b);
73         
74                 if (c.X != 1)
75                         return 1;
76                 if (c.Y != 3)
77                         return 2;
78                 return 0;
79         }
80
81         public static unsafe int test_vector2l_xor () {
82                 Vector2l a = new Vector2l (1, 6);
83                 Vector2l b = new Vector2l (3, 4);
84
85                 Vector2l c = a ^ b;
86         
87                 if (c.X != 2)
88                         return 1;
89                 if (c.Y != 2)
90                         return 2;
91                 return 0;
92         }
93
94         public static unsafe int test_vector2l_or () {
95                 Vector2l a = new Vector2l (1, 6);
96                 Vector2l b = new Vector2l (3, 4);
97
98                 Vector2l c = a | b;
99         
100                 if (c.X != 3)
101                         return 1;
102                 if (c.Y != 6)
103                         return 2;
104                 return 0;
105         }
106
107         public static unsafe int test_vector2l_and () {
108                 Vector2l a = new Vector2l (1, 6);
109                 Vector2l b = new Vector2l (3, 4);
110
111                 Vector2l c = a & b;
112         
113                 if (c.X != 1)
114                         return 1;
115                 if (c.Y != 4)
116                         return 2;
117                 return 0;
118         }
119
120         public static unsafe int test_vector2l_shl() {
121                 Vector2l a = new Vector2l (1, 6);
122
123                 Vector2l c = a << 3;
124         
125                 if (c.X != 8)
126                         return 1;
127                 if (c.Y != 48)
128                         return 2;
129                 return 0;
130         }
131         public static unsafe int test_vector2l_sub() {
132                 Vector2l a = new Vector2l (1, 6);
133                 Vector2l b = new Vector2l (3, 4);
134
135                 Vector2l c = a - b;
136         
137                 if (c.X != -2)
138                         return 1;
139                 if (c.Y != 2)
140                         return 2;
141                 return 0;
142         }
143
144         public static unsafe int test_vector2l_add () {
145                 Vector2l a = new Vector2l (1, 2);
146                 Vector2l b = new Vector2l (3, 4);
147
148                 Vector2l c = a + b;
149         
150                 if (c.X != 4)
151                         return 1;
152                 if (c.Y != 6)
153                         return 2;
154                 return 0;
155         }
156
157         public static unsafe int test_0_vector2d_dup () {
158                 Vector2d a = new Vector2d (3, 2);
159
160                 Vector2d c = Vector2d.Duplicate (a);
161         
162                 if (c.X != 3)
163                         return 1;
164                 if (c.Y != 3)
165                         return 2;
166                 return 0;
167         }
168
169         public static unsafe int test_0_vector2d_cmp_eq () {
170                 Vector2d a = new Vector2d (3, 2);
171                 Vector2d b = new Vector2d (3, 4);
172
173                 Vector4ui c = (Vector4ui)Vector2d.CompareEqual (a, b);
174         
175                 if (c.X != 0xFFFFFFFF)
176                         return 1;
177                 if (c.Y != 0xFFFFFFFF)
178                         return 2;
179                 if (c.Z != 0)
180                         return 3;
181                 if (c.W != 0)
182                         return 4;
183                 return 0;
184         }
185
186         public static unsafe int test_0_vector2d_unpack_low () {
187                 Vector2d a = new Vector2d (1, 2);
188                 Vector2d b = new Vector2d (4, 5);
189
190                 Vector2d c = Vector2d.InterleaveLow (a, b);
191         
192                 if (c.X != 1)
193                         return 1;
194                 if (c.Y != 4)
195                         return 2;
196                 return 0;
197         }
198
199         public static unsafe int test_0_vector2d_unpack_high () {
200                 Vector2d a = new Vector2d (1, 2);
201                 Vector2d b = new Vector2d (4, 5);
202
203                 Vector2d c = Vector2d.InterleaveHigh (a, b);
204         
205                 if (c.X != 2)
206                         return 1;
207                 if (c.Y != 5)
208                         return 2;
209                 return 0;
210         }
211         public static unsafe int test_0_vector2d_addsub () {
212                 Vector2d a = new Vector2d (1, 2);
213                 Vector2d b = new Vector2d (4, 1);
214
215                 Vector2d c = Vector2d.AddSub (a, b);
216         
217                 if (c.X != -3)
218                         return 1;
219                 if (c.Y != 3)
220                         return 2;
221                 return 0;
222         }
223         public static unsafe int test_0_vector2d_hsub () {
224                 Vector2d a = new Vector2d (1, 2);
225                 Vector2d b = new Vector2d (4, 1);
226
227                 Vector2d c = Vector2d.HorizontalSub (a, b);
228         
229                 if (c.X != -1)
230                         return 1;
231                 if (c.Y != 3)
232                         return 2;
233                 return 0;
234         }
235
236         public static unsafe int test_0_vector2d_hadd () {
237                 Vector2d a = new Vector2d (1, 2);
238                 Vector2d b = new Vector2d (4, 0);
239
240                 Vector2d c = Vector2d.HorizontalAdd (a, b);
241         
242                 if (c.X != 3)
243                         return 1;
244                 if (c.Y != 4)
245                         return 2;
246                 return 0;
247         }
248
249         public static unsafe int test_0_vector2d_min () {
250                 Vector2d a = new Vector2d (1, 2);
251                 Vector2d b = new Vector2d (4, 0);
252
253                 Vector2d c = Vector2d.Min (a, b);
254         
255                 if (c.X != 1)
256                         return 1;
257                 if (c.Y != 0)
258                         return 2;
259                 return 0;
260         }
261
262         public static unsafe int test_0_vector2d_max () {
263                 Vector2d a = new Vector2d (1, 2);
264                 Vector2d b = new Vector2d (4, 0);
265
266                 Vector2d c = Vector2d.Max (a, b);
267         
268                 if (c.X != 4)
269                         return 1;
270                 if (c.Y != 2)
271                         return 2;
272                 return 0;
273         }
274
275
276         public static unsafe int test_0_vector2d_andnot () {
277                 Vector2d a = new Vector2d (1, 2);
278                 Vector2d b = new Vector2d (3, 4);
279
280                 Vector4ui c = (Vector4ui)Vector2d.AndNot (a, b);
281         
282                 if (c.X != 0)
283                         return 1;
284                 if (c.Y != 1074266112)
285                         return 2;
286                 if (c.Z != 0)
287                         return 3;
288                 if (c.W != 1048576)
289                         return 4;
290                 return 0;
291         }
292
293         public static unsafe int test_0_vector2d_div () {
294                 Vector2d a = new Vector2d (1, 2);
295                 Vector2d b = new Vector2d (4, 5);
296
297                 Vector2d c = a / b;
298         
299                 if (c.X != 0.25)
300                         return 1;
301                 if (c.Y != 0.4)
302                         return 2;
303                 return 0;
304         }
305
306         public static unsafe int test_0_vector2d_mul () {
307                 Vector2d a = new Vector2d (1, 2);
308                 Vector2d b = new Vector2d (3, 5);
309
310                 Vector2d c = a * b;
311         
312                 if (c.X != 3)
313                         return 1;
314                 if (c.Y != 10)
315                         return 2;
316                 return 0;
317         }
318         public static unsafe int test_0_vector2d_sub () {
319                 Vector2d a = new Vector2d (1, 2);
320                 Vector2d b = new Vector2d (3, 5);
321
322                 Vector2d c = a - b;
323         
324                 if (c.X != -2)
325                         return 1;
326                 if (c.Y != -3)
327                         return 2;
328                 return 0;
329         }
330         public static unsafe int test_0_vector2d_add () {
331                 Vector2d a = new Vector2d (1, 2);
332                 Vector2d b = new Vector2d (3, 4);
333
334                 Vector2d c = a + b;
335         
336                 if (c.X != 4)
337                         return 1;
338                 if (c.Y != 6)
339                         return 2;
340                 return 0;
341         }
342         public static unsafe int test_0_vector2d_xor () {
343                 Vector2d a = new Vector2d (1, 2);
344                 Vector2d b = new Vector2d (3, 4);
345
346                 Vector4ui c = (Vector4ui)(a ^ b);
347         
348                 if (c.X != 0)
349                         return 1;
350                 if (c.Y != 2146959360)
351                         return 2;
352                 if (c.Z != 0)
353                         return 3;
354                 if (c.W != 1048576)
355                         return 4;
356                 return 0;
357         }
358
359         public static unsafe int test_0_vector2d_or () {
360                 Vector2d a = new Vector2d (1, 2);
361                 Vector2d b = new Vector2d (3, 4);
362
363                 Vector4ui c = (Vector4ui)(a | b);
364         
365                 if (c.X != 0)
366                         return 1;
367                 if (c.Y != 2146959360)
368                         return 2;
369                 if (c.Z != 0)
370                         return 3;
371                 if (c.W != 1074790400)
372                         return 4;
373                 return 0;
374         }
375
376         public static unsafe int test_0_vector2d_and () {
377                 Vector2d a = new Vector2d (1, 2);
378                 Vector2d b = new Vector2d (3, 4);
379
380                 Vector4ui c = (Vector4ui)(a & b);
381         
382                 if (c.X != 0)
383                         return 1;
384                 if (c.Y != 0)
385                         return 2;
386                 if (c.Z != 0)
387                         return 3;
388                 if (c.W != 1073741824)
389                         return 3;
390                 return 0;
391         }
392
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);
396
397                 Vector16sb c = Vector8s.PackWithSignedSaturation (a, b);
398
399                 if (c.V0 != -128)
400                         return 1;
401                 if (c.V1 != 127)
402                         return 2;
403
404                 return 0;
405         }
406
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);
410
411                 Vector16sb c = Vector16sb.SubWithSaturation (a, b);
412
413                 if (c.V0 != 127)
414                         return 1;
415                 if (c.V1 != -128)
416                         return 2;
417                 if (c.V2 != 0)
418                         return 3;
419                 if (c.V3 != 0)
420                         return 4;
421                 if (c.V4 != 9)
422                         return 5;
423                 if (c.V5 != 9)
424                         return 6;
425                 if (c.V6 != 9)
426                         return 7;
427                 if (c.V7 != -7)
428                         return 8;
429                 return 0;
430         }
431
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);
435
436                 Vector16sb c = Vector16sb.AddWithSaturation (a, b);
437
438                 if (c.V0 != 127)
439                         return 1;
440                 if (c.V1 != -128)
441                         return 2;
442                 if (c.V2 != 22)
443                         return 3;
444                 if (c.V3 != 24)
445                         return 4;
446                 if (c.V4 != 17)
447                         return 5;
448                 if (c.V5 != 19)
449                         return 6;
450                 if (c.V6 != 21)
451                         return 7;
452                 if (c.V7 != 7)
453                         return 8;
454                 return 0;
455         }
456
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);
460
461                 Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
462
463                 if (c.V0 != -1)
464                         return 1;
465                 if (c.V1 != 0)
466                         return 2;
467                 if (c.V2 != 0)
468                         return 3;
469                 if (c.V3 != 0)
470                         return 4;
471                 if (c.V4 != -1)
472                         return 5;
473                 if (c.V5 != -1)
474                         return 6;
475                 if (c.V6 != -1)
476                         return 7;
477                 return 0;
478         }
479
480
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);
484
485                 Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
486
487                 if (c.V0 != 0)
488                         return 1;
489                 if (c.V1 != 0xFFFF)
490                         return 2;
491                 if (c.V2 != 3)
492                         return 3;
493                 if (c.V3 != 4)
494                         return 4;
495                 if (c.V4 != 5)
496                         return 5;
497                 if (c.V5 != 6)
498                         return 6;
499                 if (c.V6 != 7)
500                         return 7;
501                 if (c.V7 != 8)
502                         return 8;
503                 return 0;
504         }
505
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);
510
511                 if (c.V0 != 0)
512                         return 1;
513                 if (c.V1 != 1)
514                         return 2;
515                 if (c.V2 != 2)
516                         return 3;
517                 if (c.V8 != 3)
518                         return 4;
519                 if (c.V15 != 10)
520                         return 5;
521                 return 0;
522         }
523
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);
528
529                 if (c.V0 != 0xFE01)
530                         return 1;
531                 if (c.V1 != 0)
532                         return 2;
533                 if (c.V2 != 0)
534                         return 3;
535                 if (c.V3 != 0)
536                         return 4;
537                 if (c.V4 != 0)
538                         return 5;
539                 if (c.V5 != 0)
540                         return 6;
541                 if (c.V6 != 0)
542                         return 7;
543                 if (c.V7 != 0)
544                         return 8;
545                 return 0;
546         }
547
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);
552
553                 if (c.V0 != 0)
554                         return 1;
555                 if (c.V1 != 0xFFFF)
556                         return 2;
557                 if (c.V2 != 0)
558                         return 3;
559                 if (c.V3 != 0)
560                         return 4;
561                 if (c.V4 != 0)
562                         return 5;
563                 if (c.V5 != 0xFFFF)
564                         return 6;
565                 if (c.V6 != 0xFFFF)
566                         return 7;
567                 if (c.V7 != 0)
568                         return 8;
569                 return 0;
570         }
571
572
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);
577
578                 if (c.X != 0)
579                         return 1;
580                 if (c.Y != 0)
581                         return 2;
582                 if (c.Z != 0xFFFFFFFF)
583                         return 3;
584                 if (c.W != 0)
585                         return 4;
586                 return 0;
587         }
588
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);
592
593                 if (c.X != 2)
594                         return 1;
595                 if (c.Y != 4)
596                         return 2;
597                 if (c.Z != 1)
598                         return 3;
599                 if (c.W != 3)
600                         return 4;
601                 return 0;
602         }
603
604         public static int test_0_vector4ui_extract_mask () {
605                 Vector4ui a = new Vector4ui (0xFF00FF00,0x0F0FAA99,0,0);
606                 int c = Vector4ui.ExtractByteMask (a);
607
608                 if (c != 0x3A)
609                         return 1;
610                 return 0;
611         }
612
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);
617
618                 if (c.X != 3)
619                         return 1;
620                 if (c.Y != 1)
621                         return 2;
622                 if (c.Z != 6)
623                         return 3;
624                 if (c.W != 3)
625                         return 4;
626                 return 0;
627         }
628
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);
633
634                 if (c.X != 6)
635                         return 1;
636                 if (c.Y != 4)
637                         return 2;
638                 if (c.Z != 6)
639                         return 3;
640                 if (c.W != 7)
641                         return 4;
642                 return 0;
643         }
644
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);
649
650                 if (c.V0 != 0)
651                         return 1;
652                 if (c.V1 != 0)
653                         return 2;
654                 if (c.V2 != 0)
655                         return 3;
656                 if (c.V3 != 0xff)
657                         return 4;
658                 if (c.V4 != 0xff)
659                         return 5;
660                 if (c.V5 != 0xff)
661                         return 6;
662                 if (c.V6 != 0xff)
663                         return 7;
664                 if (c.V7 != 0xff)
665                         return 8;
666                 if (c.V8 != 0xff)
667                         return 9;
668                 if (c.V9 != 0xff)
669                         return 10;
670                 if (c.V10 != 0xff)
671                         return 11;
672                 if (c.V11 != 0xff)
673                         return 12;
674                 if (c.V12 != 0xff)
675                         return 13;
676                 if (c.V13 != 0xff)
677                         return 14;
678                 if (c.V14 != 0xff)
679                         return 15;
680                 if (c.V15 != 0)
681                         return 16;
682                 return 0;
683         }
684
685
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);
690
691                 if (c.V0 != 130)
692                         return 1;
693                 if (c.V1 != 0)
694                         return 2;
695                 if (c.V2 != 0)
696                         return 3;
697                 if (c.V3 != 0)
698                         return 4;
699                 if (c.V4 != 20)
700                         return 5;
701                 if (c.V5 != 0)
702                         return 6;
703                 if (c.V6 != 0)
704                         return 7;
705                 if (c.V7 != 0)
706                         return 8;
707                 return 0;
708         }
709
710
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);
714
715                 if (c != 0x4C5)
716                         return 1;
717                 return 0;
718         }
719
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);
724
725                 if (c.V0 != 0)
726                         return 1;
727                 if (c.V1 != 10)
728                         return 2;
729                 if (c.V2 != 11)
730                         return 3;
731                 if (c.V3 != 12)
732                         return 4;
733                 if (c.V4 != 4)
734                         return 5;
735                 if (c.V5 != 5)
736                         return 6;
737                 if (c.V6 != 6)
738                         return 7;
739                 if (c.V7 != 0)
740                         return 8;
741                 if (c.V8 != 1)
742                         return 9;
743                 if (c.V9 != 2)
744                         return 10;
745                 if (c.V10 != 3)
746                         return 11;
747                 if (c.V11 != 4)
748                         return 12;
749                 if (c.V12 != 5)
750                         return 13;
751                 if (c.V13 != 6)
752                         return 14;
753                 if (c.V14 != 7)
754                         return 15;
755                 if (c.V15 != 8)
756                         return 16;
757                 return 0;
758         }
759
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);
764
765                 if (c.V0 != 9)
766                         return 1;
767                 if (c.V1 != 12)
768                         return 2;
769                 if (c.V2 != 20)
770                         return 3;
771                 if (c.V3 != 12)
772                         return 4;
773                 if (c.V4 != 13)
774                         return 5;
775                 if (c.V5 != 14)
776                         return 6;
777                 if (c.V6 != 15)
778                         return 7;
779                 if (c.V7 != 7)
780                         return 8;
781                 if (c.V8 != 8)
782                         return 9;
783                 if (c.V9 != 9)
784                         return 10;
785                 if (c.V10 != 10)
786                         return 11;
787                 if (c.V11 != 11)
788                         return 12;
789                 if (c.V12 != 12)
790                         return 13;
791                 if (c.V13 != 13)
792                         return 14;
793                 if (c.V14 != 14)
794                         return 15;
795                 if (c.V15 != 15)
796                         return 16;
797                 return 0;
798         }
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);
803
804                 if (c.V0 != 5)
805                         return 1;
806                 if (c.V1 != 6)
807                         return 2;
808                 if (c.V2 != 7)
809                         return 3;
810                 if (c.V3 != 8)
811                         return 4;
812                 if (c.V4 != 9)
813                         return 5;
814                 if (c.V5 != 10)
815                         return 6;
816                 if (c.V6 != 11)
817                         return 7;
818                 if (c.V7 != 4)
819                         return 8;
820                 if (c.V8 != 5)
821                         return 9;
822                 if (c.V9 != 6)
823                         return 10;
824                 if (c.V10 != 7)
825                         return 11;
826                 if (c.V11 != 8)
827                         return 12;
828                 if (c.V12 != 9)
829                         return 13;
830                 if (c.V13 != 10)
831                         return 14;
832                 if (c.V14 != 11)
833                         return 15;
834                 if (c.V15 != 12)
835                         return 16;
836                 return 0;
837         }
838
839
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;
844
845                 int tmp = 0;
846                 for (int i = 0; i < 8; ++i)
847                         tmp += System.Math.Abs ((int)*a++ - (int)*b++);
848                 res.V0 = (ushort)tmp;
849
850                 tmp = 0;
851                 for (int i = 0; i < 8; ++i)
852                         tmp += System.Math.Abs ((int)*a++ - (int)*b++);
853                 res.V4 = (ushort)tmp;
854                 return res;
855         }
856
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;
863         }
864
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;
870
871                 int tmp = 0;
872                 if (*b != 0)
873                         tmp++;
874
875                 Vector8us dd = res;
876                 dd = dd + dd - dd;
877                 return dd;
878         }
879
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);
885                 return (int)res.V0;
886         }
887         
888
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);
892
893                 if (c != 0xD33)
894                         return 1;
895                 return 0;
896         }
897
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);
901
902                 if (c.V0 != 2)
903                         return 1;
904                 if (c.V1 != 4)
905                         return 2;
906                 if (c.V2 != 1)
907                         return 3;
908                 if (c.V3 != 3)
909                         return 4;
910                 if (c.V4 != 5)
911                         return 5;
912                 if (c.V5 != 6)
913                         return 6;
914                 if (c.V6 != 7)
915                         return 7;
916                 if (c.V7 != 8)
917                         return 8;
918                 return 0;
919         }
920
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);
924
925                 if (c.V0 != 1)
926                         return 1;
927                 if (c.V1 != 2)
928                         return 2;
929                 if (c.V2 != 3)
930                         return 3;
931                 if (c.V3 != 4)
932                         return 4;
933                 if (c.V4 != 6)
934                         return 5;
935                 if (c.V5 != 8)
936                         return 6;
937                 if (c.V6 != 5)
938                         return 7;
939                 if (c.V7 != 7)
940                         return 8;
941
942                 return 0;
943         }
944
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);
949
950                 if (c.V0 != 9)
951                         return 1;
952                 if (c.V1 != 2)
953                         return 2;
954                 if (c.V2 != 3)
955                         return 3;
956                 if (c.V3 != 4)
957                         return 4;
958                 if (c.V4 != 9)
959                         return 5;
960                 if (c.V5 != 6)
961                         return 6;
962                 if (c.V6 != 7)
963                         return 7;
964                 if (c.V7 != 1000)
965                         return 0;
966
967                 return 0;
968         }
969
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);
974
975                 if (c.V0 != 1)
976                         return 1;
977                 if (c.V1 != 1)
978                         return 2;
979                 if (c.V2 != 1)
980                         return 3;
981                 if (c.V3 != 0)
982                         return 4;
983                 if (c.V4 != 3)
984                         return 5;
985                 if (c.V5 != 4)
986                         return 6;
987                 if (c.V6 != 5)
988                         return 7;
989                 if (c.V7 != 4)
990                         return 8;
991                 return 0;
992         }
993
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);
998
999                 if (c.V0 != 5)
1000                         return 1;
1001                 if (c.V1 != 2)
1002                         return 2;
1003                 if (c.V2 != 2)
1004                         return 3;
1005                 if (c.V3 != 3)
1006                         return 4;
1007                 if (c.V4 != 4)
1008                         return 5;
1009                 if (c.V5 != 5)
1010                         return 6;
1011                 if (c.V6 != 6)
1012                         return 7;
1013                 if (c.V7 != 7)
1014                         return 8;
1015                 return 0;
1016         }
1017
1018         static void store_helper (ref Vector4f x) {
1019                 Vector4f k;
1020                 k = new Vector4f(9,9,9,9);
1021                 x = k;
1022         }
1023
1024         public static int test_0_vector4f_byref_store ()
1025         {
1026                 Vector4f k;
1027                 k = new Vector4f(1,2,3,4);
1028                 store_helper (ref k);
1029                 if (k.X != 9)
1030                         return 1;
1031                 return 0;
1032         }
1033
1034         public static int test_0_vector4f_init_array_element ()
1035         {
1036                 Vector4f[] v = new Vector4f[1];
1037                 v[0] = new Vector4f(9,9,9,9);
1038                 if (v [0].X != 9)
1039                         return 1;
1040                 return 0;
1041         }
1042
1043         public static int test_0_vector4f_dup_high () {
1044                 Vector4f a = new Vector4f (1, 2, 3, 4);
1045                 Vector4f c = Vector4f.DuplicateHigh(a);
1046
1047                 if (c.X != 2)
1048                         return 1;
1049                 if (c.Y != 2)
1050                         return 2;
1051                 if (c.Z != 4)
1052                         return 3;
1053                 if (c.W != 4)
1054                         return 4;
1055                 return 0;
1056         }
1057
1058         public static int test_0_vector4f_dup_low () {
1059                 Vector4f a = new Vector4f (1, 2, 3, 4);
1060                 Vector4f c = Vector4f.DuplicateLow (a);
1061
1062                 if (c.X != 1)
1063                         return 1;
1064                 if (c.Y != 1)
1065                         return 2;
1066                 if (c.Z != 3)
1067                         return 3;
1068                 if (c.W != 3)
1069                         return 4;
1070                 return 0;
1071         }
1072
1073
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);
1078
1079                 if (c.X != 3)
1080                         return 1;
1081                 if (c.Y != 7)
1082                         return 2;
1083                 if (c.Z != 4)
1084                         return 3;
1085                 if (c.W != 8)
1086                         return 4;
1087                 return 0;
1088         }
1089
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);
1094
1095                 if (c.X != 1)
1096                         return 1;
1097                 if (c.Y != 5)
1098                         return 2;
1099                 if (c.Z != 2)
1100                         return 3;
1101                 if (c.W != 6)
1102                         return 4;
1103                 return 0;
1104         }
1105
1106         public static int test_0_vector4f_rcp () {
1107                 Vector4f a = new Vector4f (1, 2, 4, 8);
1108                 Vector4f c = Vector4f.Reciprocal (a);
1109
1110                 //Test with ranges due to the terrible precision.
1111                 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
1112                         return 1;
1113                 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
1114                         return 2;
1115                 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
1116                         return 3;
1117                 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
1118                         return 4;
1119                 return 0;
1120         }
1121
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);
1125                 Vector4f c = a ^ b;
1126
1127                 if (((Vector4ui)c).X != 0)
1128                         return 1;
1129                 if (((Vector4ui)c).Y != 0x400000)
1130                         return 2;
1131                 if (((Vector4ui)c).Z != 0)
1132                         return 3;
1133                 if (((Vector4ui)c).W != 0x1800000)
1134                         return 4;
1135                 return 0;
1136         }
1137
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);
1141                 Vector4f c = a | b;
1142
1143                 if (((Vector4ui)c).X != 0x3F800000)
1144                         return 1;
1145                 if (((Vector4ui)c).Y != 0x40400000)
1146                         return 2;
1147                 if (((Vector4ui)c).Z != 0x40400000)
1148                         return 3;
1149                 if (((Vector4ui)c).W != 0x41800000)
1150                         return 4;
1151                 return 0;
1152         }
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);
1157
1158                 if (((Vector4ui)c).X != 0)
1159                         return 1;
1160                 if (((Vector4ui)c).Y != 0x400000)
1161                         return 2;
1162                 if (((Vector4ui)c).Z != 0)
1163                         return 3;
1164                 if (((Vector4ui)c).W != 0x1000000)
1165                         return 4;
1166                 return 0;
1167         }
1168
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);
1172                 Vector4f c = a & b;
1173
1174                 if (((Vector4ui)c).X != 0x3F800000)
1175                         return 1;
1176                 if (((Vector4ui)c).Y != 0x40000000)
1177                         return 2;
1178                 if (((Vector4ui)c).Z != 0x40400000)
1179                         return 3;
1180                 if (((Vector4ui)c).W != 0x40000000)
1181                         return 4;
1182                 return 0;
1183         }
1184
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);
1189
1190                 if (((Vector4ui)c).X != 0)
1191                         return 1;
1192                 if (((Vector4ui)c).Y != 0)
1193                         return 2;
1194                 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1195                         return 3;
1196                 if (((Vector4ui)c).W != 0xFFFFFFFF)
1197                         return 4;
1198                 return 0;
1199         }
1200
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);
1205
1206                 if (((Vector4ui)c).X != 0xFFFFFFFF)
1207                         return 1;
1208                 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1209                         return 2;
1210                 if (((Vector4ui)c).Z != 0)
1211                         return 3;
1212                 if (((Vector4ui)c).W != 0)
1213                         return 4;
1214                 return 0;
1215         }
1216
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);
1221
1222                 if (((Vector4ui)c).X != 0xFFFFFFFF)
1223                         return 1;
1224                 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1225                         return 2;
1226                 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1227                         return 3;
1228                 if (((Vector4ui)c).W != 0)
1229                         return 4;
1230                 return 0;
1231         }
1232
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);
1237
1238                 if (((Vector4ui)c).X != 0xFFFFFFFF)
1239                         return 1;
1240                 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1241                         return 2;
1242                 if (((Vector4ui)c).Z != 0)
1243                         return 3;
1244                 if (((Vector4ui)c).W != 0xFFFFFFFF)
1245                         return 4;
1246                 return 0;
1247         }
1248
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);
1253
1254                 if (((Vector4ui)c).X != 0xFFFFFFFF)
1255                         return 1;
1256                 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1257                         return 2;
1258                 if (((Vector4ui)c).Z != 0)
1259                         return 3;
1260                 if (((Vector4ui)c).W != 0)
1261                         return 4;
1262                 return 0;
1263         }
1264
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);
1269
1270                 if (((Vector4ui)c).X != 0)
1271                         return 1;
1272                 if (((Vector4ui)c).Y != 0)
1273                         return 2;
1274                 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1275                         return 3;
1276                 if (((Vector4ui)c).W != 0xFFFFFFFF)
1277                         return 4;
1278                 return 0;
1279         }
1280
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);
1285
1286                 if (((Vector4ui)c).X != 0)
1287                         return 1;
1288                 if (((Vector4ui)c).Y != 0)
1289                         return 2;
1290                 if (((Vector4ui)c).Z != 0)
1291                         return 3;
1292                 if (((Vector4ui)c).W != 0xFFFFFFFF)
1293                         return 4;
1294                 return 0;
1295         }
1296
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);
1301
1302                 if (((Vector4ui)c).X != 0)
1303                         return 1;
1304                 if (((Vector4ui)c).Y != 0)
1305                         return 2;
1306                 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1307                         return 3;
1308                 if (((Vector4ui)c).W != 0)
1309                         return 4;
1310                 return 0;
1311         }
1312
1313         public static int test_0_vector4ui_sar () {
1314                 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1315                 
1316                 Vector4ui c = Vector4ui.ShiftRightArithmetic (a, 2);
1317         
1318                 if (c.X != 0xFC000000)
1319                         return 1;
1320                 if (c.Y != 5)
1321                         return 2;
1322                 if (c.Z != 0)
1323                         return 3;
1324                 if (c.W != 10)
1325                         return 4;
1326                 return 0;
1327         }
1328
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);
1332                 
1333                 Vector4ui c = Vector4ui.UnpackHigh(a, b);
1334         
1335                 if (c.X != 3)
1336                         return 1;
1337                 if (c.Y != 7)
1338                         return 2;
1339                 if (c.Z != 4)
1340                         return 3;
1341                 if (c.W != 8)
1342                         return 4;
1343                 return 0;
1344         }
1345
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);
1349                 
1350                 Vector4ui c = Vector4ui.UnpackLow (a, b);
1351         
1352                 if (c.X != 1)
1353                         return 1;
1354                 if (c.Y != 5)
1355                         return 2;
1356                 if (c.Z != 2)
1357                         return 3;
1358                 if (c.W != 6)
1359                         return 4;
1360                 return 0;
1361         }
1362
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);
1366                 
1367                 Vector4ui c = a ^ b;
1368         
1369                 if (c.X != 6)
1370                         return 1;
1371                 if (c.Y != 7)
1372                         return 2;
1373                 if (c.Z != 0)
1374                         return 3;
1375                 if (c.W != 5)
1376                         return 4;
1377                 return 0;
1378         }
1379
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);
1383                 
1384                 Vector4ui c = a | b;
1385         
1386                 if (c.X != 7)
1387                         return 1;
1388                 if (c.Y != 7)
1389                         return 2;
1390                 if (c.Z != 3)
1391                         return 3;
1392                 if (c.W != 5)
1393                         return 4;
1394                 return 0;
1395         }
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);
1399                 
1400                 Vector4ui c = a & b;
1401         
1402                 if (c.X != 1)
1403                         return 1;
1404                 if (c.Y != 0)
1405                         return 2;
1406                 if (c.Z != 3)
1407                         return 3;
1408                 if (c.W != 0)
1409                         return 4;
1410                 return 0;
1411         }
1412
1413         public  static int test_0_vector4ui_shr () {
1414                 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1415                 
1416                 Vector4ui c = a >> 2;
1417         
1418                 if (c.X != 0x3C000000)
1419                         return 1;
1420                 if (c.Y != 5)
1421                         return 2;
1422                 if (c.Z != 0)
1423                         return 3;
1424                 if (c.W != 10)
1425                         return 4;
1426                 return 0;
1427         }
1428
1429         public  static int test_0_vector4ui_shl () {
1430                 Vector4ui a = new Vector4ui (10,20,3,40);
1431                 
1432                 Vector4ui c = a << 2;
1433         
1434                 if (c.X != 40)
1435                         return 1;
1436                 if (c.Y != 80)
1437                         return 2;
1438                 if (c.Z != 12)
1439                         return 3;
1440                 if (c.W != 160)
1441                         return 4;
1442                 return 0;
1443         }
1444
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);
1448                 
1449                 Vector4ui c = a * b;
1450         
1451                 if (c.X != 0xffff7800)
1452                         return 1;
1453                 if (c.Y != 40)
1454                         return 2;
1455                 if (c.Z != 9)
1456                         return 3;
1457                 if (c.W != 160)
1458                         return 4;
1459                 return 0;
1460         }
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);
1464                 
1465                 Vector4ui c = a - b;
1466         
1467                 if (c.X != 0xff0101)
1468                         return 1;
1469                 if (c.Y != 18)
1470                         return 2;
1471                 if (c.Z != 0)
1472                         return 3;
1473                 if (c.W != 36)
1474                         return 4;
1475                 return 0;
1476         }
1477
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);
1481                 
1482                 Vector4ui c = a + b;
1483         
1484                 if (c.X != 0xfe01fe00)
1485                         return 1;
1486                 if (c.Y != 4)
1487                         return 2;
1488                 if (c.Z != 6)
1489                         return 3;
1490                 if (c.W != 8)
1491                         return 4;
1492                 return 0;
1493         }
1494
1495
1496         static int test_0_vector4ui_accessors () {
1497                 Vector4ui a = new Vector4ui (1,2,3,4);
1498
1499                 if (a.X != 1)
1500                         return 1;
1501                 if (a.Y != 2)
1502                         return 2;
1503                 if (a.Z != 3)
1504                         return 3;
1505                 if (a.W != 4)
1506                         return 4;
1507                 a.X = 10;
1508                 a.Y = 20;
1509                 a.Z = 30;
1510                 a.W = 40;
1511
1512                 if (a.X != 10)
1513                         return 5;
1514                 if (a.Y != 20)
1515                         return 6;
1516                 if (a.Z != 30)
1517                         return 7;
1518                 if (a.W != 40)
1519                         return 8;
1520                 return 0;
1521         }
1522
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);
1527
1528                 if (c.V0 != 0)
1529                         return 1;
1530                 if (c.V1 != 0)
1531                         return 2;
1532                 if (c.V2 != 15)
1533                         return 3;
1534                 if (c.V3 != 0)
1535                         return 4;
1536                 if (c.V4 != 0)
1537                         return 5;
1538                 if (c.V5 != 0)
1539                         return 6;
1540                 if (c.V6 != 0)
1541                         return 7;
1542                 if (c.V7 != 0)
1543                         return 8;
1544                 return 0;
1545         }
1546
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);
1551
1552                 if (c.V0 != 0xFFFF)
1553                         return 1;
1554                 if (c.V1 != 5)
1555                         return 2;
1556                 if (c.V2 != 7)
1557                         return 3;
1558                 if (c.V3 != 9)
1559                         return 4;
1560                 if (c.V4 != 11)
1561                         return 5;
1562                 if (c.V5 != 13)
1563                         return 6;
1564                 if (c.V6 != 15)
1565                         return 7;
1566                 if (c.V7 != 17)
1567                         return 8;
1568                 return 0;
1569         }
1570
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);
1575
1576                 if (c.V0 != 0)
1577                         return 1;
1578                 if (c.V1 != 3)
1579                         return 2;
1580                 if (c.V2 != 1)
1581                         return 3;
1582                 if (c.V3 != 4)
1583                         return 4;
1584                 if (c.V4 != 2)
1585                         return 5;
1586                 if (c.V5 != 5)
1587                         return 6;
1588                 if (c.V6 != 3)
1589                         return 7;
1590                 if (c.V7 != 6)
1591                         return 8;
1592                 return 0;
1593         }
1594
1595
1596         static int test_0_vector8us_shift_left () {
1597                 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1598                 int amt = 2;
1599                 Vector8us c = a << amt;
1600         
1601                 if (c.V0 != 0xFC00)
1602                         return 1;
1603                 if (c.V1 != 4)
1604                         return 2;
1605                 if (c.V7 != 28)
1606                         return 3;
1607                 return 0;
1608         }
1609         
1610         static int test_0_vector8us_shift_right_arithmetic () {
1611                 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1612                 int amt = 2;
1613                 Vector8us c = Vector8us.ShiftRightArithmetic (a, amt);
1614         
1615                 if (c.V0 != 0xFFC0)
1616                         return 1;
1617                 if (c.V1 != 0)
1618                         return 2;
1619                 if (c.V7 != 1)
1620                         return 3;
1621                 return 0;
1622         }
1623
1624         static int test_0_vector8us_shift_variable_offset () {
1625                 int off = 2;
1626                 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1627                 Vector8us b = a;
1628                 Vector8us c = b >> off;
1629                 a = b + b;
1630
1631                 if (c.V0 != 0x3C00)
1632                         return 1;
1633                 if (c.V1 != 0)
1634                         return 2;
1635                 if (c.V7 != 1)
1636                         return 3;
1637                 if (a.V1 != 2)
1638                         return 4;
1639                 if (a.V7 != 14)
1640                         return 5;
1641                 return 0;
1642         }
1643         
1644         
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);
1647                 Vector8us b = a;
1648                 Vector8us c = b >> 2;
1649                 a = b + b;
1650
1651                 if (c.V0 != 0x3C00)
1652                         return 1;
1653                 if (c.V1 != 0)
1654                         return 2;
1655                 if (c.V7 != 1)
1656                         return 3;
1657                 if (a.V1 != 2)
1658                         return 4;
1659                 if (a.V7 != 14)
1660                         return 5;
1661                 return 0;
1662         }
1663
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;
1667
1668                 if (c.V0 != 0x3C00)
1669                         return 1;
1670                 if (c.V1 != 0)
1671                         return 2;
1672                 if (c.V7 != 1)
1673                         return 3;
1674                 return 0;
1675         }
1676
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);
1680
1681                 Vector8us c = a * b;
1682                 if (c.V0 != 63488)
1683                         return 1;
1684                 if (c.V1 != 4)
1685                         return 2;
1686                 if (c.V7 != 80)
1687                         return 3;
1688                 return 0;
1689         }
1690
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);
1694
1695                 Vector8us c = a + b;
1696                 if (c.V0 != 34696)
1697                         return 1;
1698                 if (c.V1 != 5)
1699                         return 2;
1700                 if (c.V7 != 18)
1701                         return 3;
1702                 return 0;
1703         }
1704
1705
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);
1709
1710                 Vector8us c = a - b;
1711
1712                 if (c.V0 != 65529)
1713                         return 1;
1714                 if (c.V1 != 3)
1715                         return 2;
1716                 if (c.V7 != 2)
1717                         return 3;
1718                 return 0;
1719         }
1720
1721
1722         static int test_0_vector8us_accessors () {
1723                 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1724
1725                 if (a.V0 != 0)
1726                         return 1;
1727                 if (a.V1 != 1)
1728                         return 2;
1729                 if (a.V2 != 2)
1730                         return 3;
1731                 if (a.V3 != 3)
1732                         return 4;
1733                 if (a.V4 != 4)
1734                         return 5;
1735                 if (a.V5 != 5)
1736                         return 6;
1737                 if (a.V6 != 6)
1738                         return 7;
1739                 if (a.V7 != 7)
1740                         return 8;
1741                 a.V0 = 10;
1742                 a.V1 = 20;
1743                 a.V2 = 30;
1744                 a.V3 = 40;
1745                 a.V4 = 50;
1746                 a.V5 = 60;
1747                 a.V6 = 70;
1748                 a.V7 = 80;
1749
1750                 if (a.V0 != 10)
1751                         return 17;
1752                 if (a.V1 != 20)
1753                         return 18;
1754                 if (a.V2 != 30)
1755                         return 19;
1756                 if (a.V3 != 40)
1757                         return 20;
1758                 if (a.V4 != 50)
1759                         return 21;
1760                 if (a.V5 != 60)
1761                         return 22;
1762                 if (a.V6 != 70)
1763                         return 23;
1764                 if (a.V7 != 80)
1765                         return 24;
1766
1767                 return 0;
1768         }
1769
1770
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);
1775
1776                 if (c.V0 != 8)
1777                         return 1;
1778                 if (c.V1 != 1)
1779                         return 2;
1780                 if (c.V2 != 9)
1781                         return 3;
1782                 if (c.V3 != 2)
1783                         return 4;
1784                 if (c.V4 != 10)
1785                         return 5;
1786                 if (c.V5 != 3)
1787                         return 6;
1788                 if (c.V14 != 15)
1789                         return 7;
1790                 if (c.V15 != 8)
1791                         return 8;
1792                 return 0;
1793         }
1794
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);
1799
1800                 if (c.V0 != 0)
1801                         return 1;
1802                 if (c.V1 != 9)
1803                         return 2;
1804                 if (c.V2 != 1)
1805                         return 3;
1806                 if (c.V3 != 10)
1807                         return 4;
1808                 if (c.V4 != 2)
1809                         return 5;
1810                 if (c.V5 != 11)
1811                         return 6;
1812                 if (c.V14 != 7)
1813                         return 7;
1814                 if (c.V15 != 0)
1815                         return 8;
1816                 return 0;
1817         }
1818
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);
1823
1824                 if (c.V0 != 0)
1825                         return 1;
1826                 if (c.V1 != 9)
1827                         return 2;
1828                 if (c.V15 != 0)
1829                         return 3;
1830                 return 0;
1831         }
1832         
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);
1837
1838                 if (c.V0 != 255)
1839                         return 1;
1840                 if (c.V1 != 11)
1841                         return 2;
1842                 if (c.V15 != 23)
1843                         return 3;
1844                 return 0;
1845         }
1846
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;
1851
1852                 if (c.V0 != 144)
1853                         return 1;
1854                 if (c.V1 != 11)
1855                         return 2;
1856                 if (c.V15 != 23)
1857                         return 3;
1858                 return 0;
1859         }
1860
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);
1863
1864                 if (a.V0 != 0)
1865                         return 1;
1866                 if (a.V1 != 1)
1867                         return 2;
1868                 if (a.V2 != 2)
1869                         return 3;
1870                 if (a.V3 != 3)
1871                         return 4;
1872                 if (a.V4 != 4)
1873                         return 5;
1874                 if (a.V5 != 5)
1875                         return 6;
1876                 if (a.V6 != 6)
1877                         return 7;
1878                 if (a.V7 != 7)
1879                         return 8;
1880                 if (a.V8 != 8)
1881                         return 9;
1882                 if (a.V9 != 9)
1883                         return 10;
1884                 if (a.V10 != 10)
1885                         return 11;
1886                 if (a.V11 != 11)
1887                         return 12;
1888                 if (a.V12 != 12)
1889                         return 13;
1890                 if (a.V13 != 13)
1891                         return 14;
1892                 if (a.V14 != 14)
1893                         return 15;
1894                 if (a.V15 != 15)
1895                         return 16;
1896
1897                 a.V0 = 10;
1898                 a.V1 = 20;
1899                 a.V2 = 30;
1900                 a.V3 = 40;
1901                 a.V4 = 50;
1902                 a.V5 = 60;
1903                 a.V6 = 70;
1904                 a.V7 = 80;
1905                 a.V8 = 90;
1906                 a.V9 = 100;
1907                 a.V10 = 110;
1908                 a.V11 = 120;
1909                 a.V12 = 130;
1910                 a.V13 = 140;
1911                 a.V14 = 150;
1912                 a.V15 = 160;
1913
1914                 if (a.V0 != 10)
1915                         return 17;
1916                 if (a.V1 != 20)
1917                         return 18;
1918                 if (a.V2 != 30)
1919                         return 19;
1920                 if (a.V3 != 40)
1921                         return 20;
1922                 if (a.V4 != 50)
1923                         return 21;
1924                 if (a.V5 != 60)
1925                         return 22;
1926                 if (a.V6 != 70)
1927                         return 23;
1928                 if (a.V7 != 80)
1929                         return 24;
1930                 if (a.V8 != 90)
1931                         return 25;
1932                 if (a.V9 != 100)
1933                         return 26;
1934                 if (a.V10 != 110)
1935                         return 27;
1936                 if (a.V11 != 120)
1937                         return 28;
1938                 if (a.V12 != 130)
1939                         return 29;
1940                 if (a.V13 != 140)
1941                         return 30;
1942                 if (a.V14 != 150)
1943                         return 31;
1944                 if (a.V15 != 160)
1945                         return 32;
1946                 return 0;
1947         }
1948
1949         public static int test_0_accessors () {
1950                 Vector4f a = new Vector4f (1, 2, 3, 4);
1951                 if (a.X != 1f)
1952                         return 1;
1953                 if (a.Y != 2f)
1954                         return 2;
1955                 if (a.Z != 3f)
1956                         return 3;
1957                 if (a.W != 4f)
1958                         return 4;
1959                 return 0;
1960         }
1961
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;
1967                 if (d.X != 5f)
1968                         return 1;
1969                 if (d.Y != 5f)
1970                         return 2;
1971                 if (d.Z != 6f)
1972                         return 3;
1973                 if (d.W != 7f)
1974                         return 4;
1975                 return 0;
1976         }
1977
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);
1981                 Vector4f c;
1982                 c = a + b;
1983                 if (c.X != 6f)
1984                         return 1;
1985                 if (c.Y != 8f)
1986                         return 2;
1987                 if (c.Z != 10f)
1988                         return 3;
1989                 if (c.W != 12f)
1990                         return 4;
1991                 return 0;
1992         }
1993
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);
1997                 Vector4f c = b - a;
1998                 if (c.X != 4f)
1999                         return 1;
2000                 if (c.Y != 4f)
2001                         return 2;
2002                 if (c.Z != 4f)
2003                         return 3;
2004                 if (c.W != 4f)
2005                         return 4;
2006                 return 0;
2007         }
2008
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);
2012                 Vector4f c = b * a;
2013                 if (c.X != 5f)
2014                         return 1;
2015                 if (c.Y != 12f)
2016                         return 2;
2017                 if (c.Z != 21f)
2018                         return 3;
2019                 if (c.W != 32f)
2020                         return 4;
2021                 return 0;
2022         }
2023
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);
2027                 Vector4f c = b / a;
2028                 if (c.X != 10f)
2029                         return 1;
2030                 if (c.Y != 5f)
2031                         return 2;
2032                 if (c.Z != 11f)
2033                         return 3;
2034                 if (c.W != 3f)
2035                         return 4;
2036                 return 0;
2037         }
2038
2039         public static int test_0_simple_packed_sqrt () {
2040                 Vector4f a = new Vector4f (16, 4, 9, 25);
2041                 a = Vector4f.Sqrt (a);
2042                 if (a.X != 4f)
2043                         return 1;
2044                 if (a.Y != 2f)
2045                         return 2;
2046                 if (a.Z != 3f)
2047                         return 3;
2048                 if (a.W != 5f)
2049                         return 4;
2050                 return 0;
2051         }
2052
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))
2058                         return 1;
2059                 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
2060                         return 2;
2061                 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
2062                         return 3;
2063                 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
2064                         return 4;
2065                 return 0;
2066         }
2067
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);
2072                 if (c.X != 5f)
2073                         return 1;
2074                 if (c.Y != -4f)
2075                         return 2;
2076                 if (c.Z != 9f)
2077                         return 3;
2078                 if (c.W != 0f)
2079                         return 4;
2080                 return 0;
2081         }
2082
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);
2087                 if (c.X != 16f)
2088                         return 1;
2089                 if (c.Y != 3f)
2090                         return 2;
2091                 if (c.Z != 9f)
2092                         return 3;
2093                 if (c.W != 25f)
2094                         return 4;
2095                 return 0;
2096         }
2097
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);
2102                 if (c.X != 10f)
2103                         return 1;
2104                 if (c.Y != 12f)
2105                         return 2;
2106                 if (c.Z != 14f)
2107                         return 3;
2108                 if (c.W != 16f)
2109                         return 4;
2110                 return 0;
2111         }
2112
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);
2117                 if (c.X != 3f)
2118                         return 1;
2119                 if (c.Y != 5f)
2120                         return 2;
2121                 if (c.Z != 7f)
2122                         return 3;
2123                 if (c.W != 5f)
2124                         return 4;
2125                 return 0;
2126         }
2127
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);
2132                 if (c.X != -2f)
2133                         return 1;
2134                 if (c.Y != 2f)
2135                         return 2;
2136                 if (c.Z != -2f)
2137                         return 3;
2138                 if (c.W != 4f)
2139                         return 4;
2140                 return 0;
2141         }
2142
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);
2146                 if (a.X != 2f)
2147                         return 1;
2148                 if (a.Y != 4f)
2149                         return 2;
2150                 if (a.Z != 1f)
2151                         return 3;
2152                 if (a.W != 3f)
2153                         return 4;
2154                 return 0;
2155         }
2156
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    ;
2161
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);
2167                 Vector4f a = x;
2168
2169                 r0 = r0 * m0 + x;
2170                 r1 = r1 * m1 + x;
2171                 x = x - v + v;
2172                 r2 = r2 * m2 + x;
2173                 r3 = r3 * m3 + x;
2174                 Vector4f result = r0 + r1 + r2 + r3;
2175
2176                 if (a.X != 2f)
2177                         return 1;
2178                 if (a.Y != 4f)
2179                         return 2;
2180                 if (a.Z != 1f)
2181                         return 3;
2182                 if (a.W != 3f)
2183                         return 4;
2184                 if (result.Y != result.Y)
2185                         return 0;
2186                 return 0;
2187         }
2188         
2189         public static int test_24_regs_pressure_a () {
2190                 Vector4f a = new Vector4f (1, 2, 3, 4);
2191                 Vector4f b = a + a;
2192                 Vector4f c = b * a;
2193                 Vector4f d = a - b;
2194                 c = a + b + c + d;
2195                 return (int)c.Z;
2196         }
2197
2198         public static int test_54_regs_pressure_b () {
2199                 Vector4f a = new Vector4f (1, 2, 3, 4);
2200                 Vector4f b = a + a;
2201                 Vector4f c = b - a;
2202                 Vector4f d = c - a;
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;
2209                 return (int)j.Z;
2210         }
2211
2212         static bool ff;
2213         public static int test_3_single_block_var_is_properly_promoted () {
2214                 Vector4f a = new Vector4f (4, 5, 6, 7);
2215                 if (ff)
2216                         a = a - a;
2217                 else {
2218                         Vector4f b = new Vector4f (1, 2, 3, 4);
2219                         Vector4f c = b;
2220                         a = a - b;
2221                         if (ff) {
2222                                 c = a;
2223                                 a = c;
2224                         }
2225                 }
2226                 return (int)a.X;
2227         }
2228
2229         static float float_val = 45f;
2230
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;
2234                 int x = (int)f;
2235                 if (v.X != 1f)
2236                         return 1;
2237                 if (x != 45f)
2238                         return 2;
2239                 return 0;
2240         }
2241
2242         public static int Main () {
2243                 return TestDriver.RunTests (typeof (SimdTests));
2244         }
2245 }
2246