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