using Mono.Simd;
public class SimdTests {
+ public static int test_0_accessor_vecto4i () {
+ Vector4i a = new Vector4i (0x70000000, -1, 3, 4);
+
+ if (a.X != 0x70000000)
+ return 1;
+ if (a.Y != -1)
+ return 2;
+ if (a.Z != 3)
+ return 3;
+ if (a.W != 4)
+ return 4;
+
+ a.X = 11;
+ a.Y = 22;
+ a.Z = 33333344;
+ a.W = -44444444;
+
+ if (a.X != 11)
+ return 5;
+ if (a.Y != 22)
+ return 6;
+ if (a.Z != 33333344)
+ return 7;
+ if (a.W != -44444444)
+ return 8;
+ return 0;
+ }
+
+ public static int test_0_accessor_vecto4ui () {
+ Vector4ui a = new Vector4ui (0xF0000000, 0xF0000, 3, 4);
+
+ if (a.X != 0xF0000000)
+ return 1;
+ if (a.Y != 0xF0000)
+ return 2;
+ if (a.Z != 3)
+ return 3;
+ if (a.W != 4)
+ return 4;
+
+ a.X = 11;
+ a.Y = 22;
+ a.Z = 33333344;
+ a.W = 44444444;
+
+ if (a.X != 11)
+ return 5;
+ if (a.Y != 22)
+ return 6;
+ if (a.Z != 33333344)
+ return 7;
+ if (a.W != 44444444)
+ return 8;
+ return 0;
+ }
+
+ static float use_getter_with_byref (ref Vector4f a) {
+ return a.W;
+ }
+
+ public static int test_0_accessor_and_byref_var () {
+ Vector4f a = new Vector4f (1, 2, 3, 4);
+ if (use_getter_with_byref (ref a) != 4)
+ return 1;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2ul_slr () {
+ Vector2ul a = new Vector2ul (1, 6);
+
+ Vector2ul c = a >> 1;
+ if (c.X != 0)
+ return 1;
+ if (c.Y != 3)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2l_cmp_gt () {
+ Vector2l a = new Vector2l (10, 5);
+ Vector2l b = new Vector2l (-1, 5);
+
+ Vector2l c = Vector2l.CompareGreaterThan (a, b);
+
+ if (c.X != -1)
+ return 1;
+ if (c.Y != 0)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2l_cmp_eq () {
+ Vector2l a = new Vector2l (0xFF, 5);
+ Vector2l b = new Vector2l (0xFF000000FFL, 5);
+
+ Vector2l c = Vector2l.CompareEqual (a, b);
+
+ if (c.X != 0)
+ return 1;
+ if (c.Y != -1)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2l_srl () {
+ Vector2l a = new Vector2l (1, 6);
+
+ Vector2l c = Vector2l.LogicalRightShift (a, 1);
+
+ if (c.X != 0)
+ return 1;
+ if (c.Y != 3)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2l_unpack_high () {
+ Vector2l a = new Vector2l (1, 6);
+ Vector2l b = new Vector2l (3, 4);
+
+ Vector2l c = Vector2l.UnpackHigh (a, b);
+
+ if (c.X != 6)
+ return 1;
+ if (c.Y != 4)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2l_unpack_low () {
+ Vector2l a = new Vector2l (1, 6);
+ Vector2l b = new Vector2l (3, 4);
+
+ Vector2l c = Vector2l.UnpackLow (a, b);
+
+ if (c.X != 1)
+ return 1;
+ if (c.Y != 3)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2l_xor () {
+ Vector2l a = new Vector2l (1, 6);
+ Vector2l b = new Vector2l (3, 4);
+
+ Vector2l c = a ^ b;
+
+ if (c.X != 2)
+ return 1;
+ if (c.Y != 2)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2l_or () {
+ Vector2l a = new Vector2l (1, 6);
+ Vector2l b = new Vector2l (3, 4);
+
+ Vector2l c = a | b;
+
+ if (c.X != 3)
+ return 1;
+ if (c.Y != 6)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2l_and () {
+ Vector2l a = new Vector2l (1, 6);
+ Vector2l b = new Vector2l (3, 4);
+
+ Vector2l c = a & b;
+
+ if (c.X != 1)
+ return 1;
+ if (c.Y != 4)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2l_shl() {
+ Vector2l a = new Vector2l (1, 6);
+
+ Vector2l c = a << 3;
+
+ if (c.X != 8)
+ return 1;
+ if (c.Y != 48)
+ return 2;
+ return 0;
+ }
+ public static unsafe int test_0_vector2l_sub() {
+ Vector2l a = new Vector2l (1, 6);
+ Vector2l b = new Vector2l (3, 4);
+
+ Vector2l c = a - b;
+
+ if (c.X != -2)
+ return 1;
+ if (c.Y != 2)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2l_add () {
+ Vector2l a = new Vector2l (1, 2);
+ Vector2l b = new Vector2l (3, 4);
+
+ Vector2l c = a + b;
+
+ if (c.X != 4)
+ return 1;
+ if (c.Y != 6)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2d_dup () {
+ Vector2d a = new Vector2d (3, 2);
+
+ Vector2d c = Vector2d.Duplicate (a);
+
+ if (c.X != 3)
+ return 1;
+ if (c.Y != 3)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2d_cmp_eq () {
+ Vector2d a = new Vector2d (3, 2);
+ Vector2d b = new Vector2d (3, 4);
+
+ Vector4ui c = (Vector4ui)Vector2d.CompareEqual (a, b);
+
+ if (c.X != 0xFFFFFFFF)
+ return 1;
+ if (c.Y != 0xFFFFFFFF)
+ return 2;
+ if (c.Z != 0)
+ return 3;
+ if (c.W != 0)
+ return 4;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2d_unpack_low () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (4, 5);
+
+ Vector2d c = Vector2d.InterleaveLow (a, b);
+
+ if (c.X != 1)
+ return 1;
+ if (c.Y != 4)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2d_unpack_high () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (4, 5);
+
+ Vector2d c = Vector2d.InterleaveHigh (a, b);
+
+ if (c.X != 2)
+ return 1;
+ if (c.Y != 5)
+ return 2;
+ return 0;
+ }
+ public static unsafe int test_0_vector2d_addsub () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (4, 1);
+
+ Vector2d c = Vector2d.AddSub (a, b);
+
+ if (c.X != -3)
+ return 1;
+ if (c.Y != 3)
+ return 2;
+ return 0;
+ }
+ public static unsafe int test_0_vector2d_hsub () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (4, 1);
+
+ Vector2d c = Vector2d.HorizontalSub (a, b);
+
+ if (c.X != -1)
+ return 1;
+ if (c.Y != 3)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2d_hadd () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (4, 0);
+
+ Vector2d c = Vector2d.HorizontalAdd (a, b);
+
+ if (c.X != 3)
+ return 1;
+ if (c.Y != 4)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2d_min () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (4, 0);
+
+ Vector2d c = Vector2d.Min (a, b);
+
+ if (c.X != 1)
+ return 1;
+ if (c.Y != 0)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2d_max () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (4, 0);
+
+ Vector2d c = Vector2d.Max (a, b);
+
+ if (c.X != 4)
+ return 1;
+ if (c.Y != 2)
+ return 2;
+ return 0;
+ }
+
+
+ public static unsafe int test_0_vector2d_andnot () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (3, 4);
+
+ Vector4ui c = (Vector4ui)Vector2d.AndNot (a, b);
+
+ if (c.X != 0)
+ return 1;
+ if (c.Y != 1074266112)
+ return 2;
+ if (c.Z != 0)
+ return 3;
+ if (c.W != 1048576)
+ return 4;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2d_div () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (4, 5);
+
+ Vector2d c = a / b;
+
+ if (c.X != 0.25)
+ return 1;
+ if (c.Y != 0.4)
+ return 2;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2d_mul () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (3, 5);
+
+ Vector2d c = a * b;
+
+ if (c.X != 3)
+ return 1;
+ if (c.Y != 10)
+ return 2;
+ return 0;
+ }
+ public static unsafe int test_0_vector2d_sub () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (3, 5);
+
+ Vector2d c = a - b;
+
+ if (c.X != -2)
+ return 1;
+ if (c.Y != -3)
+ return 2;
+ return 0;
+ }
+ public static unsafe int test_0_vector2d_add () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (3, 4);
+
+ Vector2d c = a + b;
+
+ if (c.X != 4)
+ return 1;
+ if (c.Y != 6)
+ return 2;
+ return 0;
+ }
+ public static unsafe int test_0_vector2d_xor () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (3, 4);
+
+ Vector4ui c = (Vector4ui)(a ^ b);
+
+ if (c.X != 0)
+ return 1;
+ if (c.Y != 2146959360)
+ return 2;
+ if (c.Z != 0)
+ return 3;
+ if (c.W != 1048576)
+ return 4;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2d_or () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (3, 4);
+
+ Vector4ui c = (Vector4ui)(a | b);
+
+ if (c.X != 0)
+ return 1;
+ if (c.Y != 2146959360)
+ return 2;
+ if (c.Z != 0)
+ return 3;
+ if (c.W != 1074790400)
+ return 4;
+ return 0;
+ }
+
+ public static unsafe int test_0_vector2d_and () {
+ Vector2d a = new Vector2d (1, 2);
+ Vector2d b = new Vector2d (3, 4);
+
+ Vector4ui c = (Vector4ui)(a & b);
+
+ if (c.X != 0)
+ return 1;
+ if (c.Y != 0)
+ return 2;
+ if (c.Z != 0)
+ return 3;
+ if (c.W != 1073741824)
+ return 3;
+ return 0;
+ }
+
+ public static unsafe int test_vector8s_pack_signed_sat () {
+ Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
+ Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
+
+ Vector16sb c = Vector8s.PackWithSignedSaturation (a, b);
+
+ if (c.V0 != -128)
+ return 1;
+ if (c.V1 != 127)
+ return 2;
+
+ return 0;
+ }
+
+ public static unsafe int test_vector16sb_sub_sat () {
+ Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
+ Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
+
+ Vector16sb c = Vector16sb.SubtractWithSaturation (a, b);
+
+ if (c.V0 != 127)
+ return 1;
+ if (c.V1 != -128)
+ return 2;
+ if (c.V2 != 0)
+ return 3;
+ if (c.V3 != 0)
+ return 4;
+ if (c.V4 != 9)
+ return 5;
+ if (c.V5 != 9)
+ return 6;
+ if (c.V6 != 9)
+ return 7;
+ if (c.V7 != -7)
+ return 8;
+ return 0;
+ }
+
+ public static unsafe int test_vector16sb_add_sat () {
+ Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
+ Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
+
+ Vector16sb c = Vector16sb.AddWithSaturation (a, b);
+
+ if (c.V0 != 127)
+ return 1;
+ if (c.V1 != -128)
+ return 2;
+ if (c.V2 != 22)
+ return 3;
+ if (c.V3 != 24)
+ return 4;
+ if (c.V4 != 17)
+ return 5;
+ if (c.V5 != 19)
+ return 6;
+ if (c.V6 != 21)
+ return 7;
+ if (c.V7 != 7)
+ return 8;
+ return 0;
+ }
+
+ public static unsafe int test_vector16sb_cmp_gt () {
+ Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
+ Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
+
+ Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
+
+ if (c.V0 != -1)
+ return 1;
+ if (c.V1 != 0)
+ return 2;
+ if (c.V2 != 0)
+ return 3;
+ if (c.V3 != 0)
+ return 4;
+ if (c.V4 != -1)
+ return 5;
+ if (c.V5 != -1)
+ return 6;
+ if (c.V6 != -1)
+ return 7;
+ return 0;
+ }
+
+
+ public static int test_0_vector4ui_pack_with_sat () {
+ Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
+ Vector4ui b = new Vector4ui (5,6,7,8);
+
+ Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
+
+ if (c.V0 != 0)
+ return 1;
+ if (c.V1 != 0xFFFF)
+ return 2;
+ if (c.V2 != 3)
+ return 3;
+ if (c.V3 != 4)
+ return 4;
+ if (c.V4 != 5)
+ return 5;
+ if (c.V5 != 6)
+ return 6;
+ if (c.V6 != 7)
+ return 7;
+ if (c.V7 != 8)
+ return 8;
+ return 0;
+ }
+
+ public static int test_0_vector8us_pack_with_sat () {
+ Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
+ Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
+ Vector16b c = Vector8us.SignedPackWithUnsignedSaturation (a, b);
+
+ if (c.V0 != 0)
+ return 1;
+ if (c.V1 != 1)
+ return 2;
+ if (c.V2 != 2)
+ return 3;
+ if (c.V8 != 3)
+ return 4;
+ if (c.V15 != 10)
+ return 5;
+ return 0;
+ }
+
+ public static int test_0_vector8us_mul_high () {
+ Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
+ Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
+ Vector8us c = Vector8us.MultiplyStoreHigh (a, b);
+
+ if (c.V0 != 0xFE01)
+ return 1;
+ if (c.V1 != 0)
+ return 2;
+ if (c.V2 != 0)
+ return 3;
+ if (c.V3 != 0)
+ return 4;
+ if (c.V4 != 0)
+ return 5;
+ if (c.V5 != 0)
+ return 6;
+ if (c.V6 != 0)
+ return 7;
+ if (c.V7 != 0)
+ return 8;
+ return 0;
+ }
+
+ public static int test_0_vector8us_cmpeq () {
+ Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
+ Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
+ Vector8us c = Vector8us.CompareEqual (a, b);
+
+ if (c.V0 != 0)
+ return 1;
+ if (c.V1 != 0xFFFF)
+ return 2;
+ if (c.V2 != 0)
+ return 3;
+ if (c.V3 != 0)
+ return 4;
+ if (c.V4 != 0)
+ return 5;
+ if (c.V5 != 0xFFFF)
+ return 6;
+ if (c.V6 != 0xFFFF)
+ return 7;
+ if (c.V7 != 0)
+ return 8;
+ return 0;
+ }
+
+
+ public static int test_0_vector4ui_cmpeq () {
+ Vector4ui a = new Vector4ui (6,1,6,3);
+ Vector4ui b = new Vector4ui (3,4,6,7);
+ Vector4ui c = Vector4ui.CompareEqual (a, b);
+
+ if (c.X != 0)
+ return 1;
+ if (c.Y != 0)
+ return 2;
+ if (c.Z != 0xFFFFFFFF)
+ return 3;
+ if (c.W != 0)
+ return 4;
+ return 0;
+ }
+
+ public static int test_0_vector4ui_shuffle () {
+ Vector4ui a = new Vector4ui (1,2,3,4);
+ Vector4ui c = Vector4ui.Shuffle (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
+
+ if (c.X != 2)
+ return 1;
+ if (c.Y != 4)
+ return 2;
+ if (c.Z != 1)
+ return 3;
+ if (c.W != 3)
+ return 4;
+ return 0;
+ }
+
+ public static int test_0_vector4ui_extract_mask () {
+ Vector4ui a = new Vector4ui (0xFF00FF00,0x0F0FAA99,0,0);
+ int c = Vector4ui.ExtractByteMask (a);
+
+ if (c != 0x3A)
+ return 1;
+ return 0;
+ }
+
+ public static int test_0_vector4ui_min () {
+ Vector4ui a = new Vector4ui (6,1,6,3);
+ Vector4ui b = new Vector4ui (3,4,6,7);
+ Vector4ui c = Vector4ui.Min (a, b);
+
+ if (c.X != 3)
+ return 1;
+ if (c.Y != 1)
+ return 2;
+ if (c.Z != 6)
+ return 3;
+ if (c.W != 3)
+ return 4;
+ return 0;
+ }
+
+ public static int test_0_vector4ui_max () {
+ Vector4ui a = new Vector4ui (6,1,6,3);
+ Vector4ui b = new Vector4ui (3,4,6,7);
+ Vector4ui c = Vector4ui.Max (a, b);
+
+ if (c.X != 6)
+ return 1;
+ if (c.Y != 4)
+ return 2;
+ if (c.Z != 6)
+ return 3;
+ if (c.W != 7)
+ return 4;
+ return 0;
+ }
+
+ public static int vector16b_cmpeq () {
+ Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
+ Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+ Vector16b c = Vector16b.CompareEqual (a, b);
+
+ if (c.V0 != 0)
+ return 1;
+ if (c.V1 != 0)
+ return 2;
+ if (c.V2 != 0)
+ return 3;
+ if (c.V3 != 0xff)
+ return 4;
+ if (c.V4 != 0xff)
+ return 5;
+ if (c.V5 != 0xff)
+ return 6;
+ if (c.V6 != 0xff)
+ return 7;
+ if (c.V7 != 0xff)
+ return 8;
+ if (c.V8 != 0xff)
+ return 9;
+ if (c.V9 != 0xff)
+ return 10;
+ if (c.V10 != 0xff)
+ return 11;
+ if (c.V11 != 0xff)
+ return 12;
+ if (c.V12 != 0xff)
+ return 13;
+ if (c.V13 != 0xff)
+ return 14;
+ if (c.V14 != 0xff)
+ return 15;
+ if (c.V15 != 0)
+ return 16;
+ return 0;
+ }
+
+
+ public static int vector16b_sum_abs_diff () {
+ Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
+ Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
+ Vector8us c = Vector16b.SumOfAbsoluteDifferences (a, b);
+
+ if (c.V0 != 130)
+ return 1;
+ if (c.V1 != 0)
+ return 2;
+ if (c.V2 != 0)
+ return 3;
+ if (c.V3 != 0)
+ return 4;
+ if (c.V4 != 20)
+ return 5;
+ if (c.V5 != 0)
+ return 6;
+ if (c.V6 != 0)
+ return 7;
+ if (c.V7 != 0)
+ return 8;
+ return 0;
+ }
+
+
+ public static int test_0_vector16b_extract_mask () {
+ Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
+ int c = Vector16b.ExtractByteMask (a);
+
+ if (c != 0x4C5)
+ return 1;
+ return 0;
+ }
+
+ public static int test_0_vector16b_min () {
+ Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
+ Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
+ Vector16b c = Vector16b.Min (a, b);
+
+ if (c.V0 != 0)
+ return 1;
+ if (c.V1 != 10)
+ return 2;
+ if (c.V2 != 11)
+ return 3;
+ if (c.V3 != 12)
+ return 4;
+ if (c.V4 != 4)
+ return 5;
+ if (c.V5 != 5)
+ return 6;
+ if (c.V6 != 6)
+ return 7;
+ if (c.V7 != 0)
+ return 8;
+ if (c.V8 != 1)
+ return 9;
+ if (c.V9 != 2)
+ return 10;
+ if (c.V10 != 3)
+ return 11;
+ if (c.V11 != 4)
+ return 12;
+ if (c.V12 != 5)
+ return 13;
+ if (c.V13 != 6)
+ return 14;
+ if (c.V14 != 7)
+ return 15;
+ if (c.V15 != 8)
+ return 16;
+ return 0;
+ }
+
+ public static int test_0_vector16b_max () {
+ Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
+ Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
+ Vector16b c = Vector16b.Max (a, b);
+
+ if (c.V0 != 9)
+ return 1;
+ if (c.V1 != 12)
+ return 2;
+ if (c.V2 != 20)
+ return 3;
+ if (c.V3 != 12)
+ return 4;
+ if (c.V4 != 13)
+ return 5;
+ if (c.V5 != 14)
+ return 6;
+ if (c.V6 != 15)
+ return 7;
+ if (c.V7 != 7)
+ return 8;
+ if (c.V8 != 8)
+ return 9;
+ if (c.V9 != 9)
+ return 10;
+ if (c.V10 != 10)
+ return 11;
+ if (c.V11 != 11)
+ return 12;
+ if (c.V12 != 12)
+ return 13;
+ if (c.V13 != 13)
+ return 14;
+ if (c.V14 != 14)
+ return 15;
+ if (c.V15 != 15)
+ return 16;
+ return 0;
+ }
+ public static int test_0_vector16b_avg () {
+ Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
+ Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
+ Vector16b c = Vector16b.Average (a, b);
+
+ if (c.V0 != 5)
+ return 1;
+ if (c.V1 != 6)
+ return 2;
+ if (c.V2 != 7)
+ return 3;
+ if (c.V3 != 8)
+ return 4;
+ if (c.V4 != 9)
+ return 5;
+ if (c.V5 != 10)
+ return 6;
+ if (c.V6 != 11)
+ return 7;
+ if (c.V7 != 4)
+ return 8;
+ if (c.V8 != 5)
+ return 9;
+ if (c.V9 != 6)
+ return 10;
+ if (c.V10 != 7)
+ return 11;
+ if (c.V11 != 8)
+ return 12;
+ if (c.V12 != 9)
+ return 13;
+ if (c.V13 != 10)
+ return 14;
+ if (c.V14 != 11)
+ return 15;
+ if (c.V15 != 12)
+ return 16;
+ return 0;
+ }
+
+
+ static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
+ Vector8us res = new Vector8us ();
+ byte *a = (byte*)&va;
+ byte *b = (byte*)&vb;
+
+ int tmp = 0;
+ for (int i = 0; i < 8; ++i)
+ tmp += System.Math.Abs ((int)*a++ - (int)*b++);
+ res.V0 = (ushort)tmp;
+
+ tmp = 0;
+ for (int i = 0; i < 8; ++i)
+ tmp += System.Math.Abs ((int)*a++ - (int)*b++);
+ res.V4 = (ushort)tmp;
+ return res;
+ }
+
+ /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
+ public static int test_2_local_simplifier_regression_other_blocks () {
+ Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
+ Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+ Vector8us res = bad_method_regression_2 (a,b);
+ return (int)res.V0 + res.V4;
+ }
+
static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
Vector8us res = new Vector8us ();
byte *a = (byte*)&va;
return dd;
}
- /*This bug was caused the simplifier not taking notice of LDADDR.*/
- public static int test_10_local_simplier_regression () {
+ /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
+ public static int test_10_local_simplifier_regression_first_block () {
Vector16b a = new Vector16b ();
Vector16b b = new Vector16b ();
Vector8us res = bad_method_regression (a,b);
public static int test_0_vector4f_cmpeq () {
Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
Vector4f b = new Vector4f (1, float.NaN, 3, 4);
- Vector4f c = Vector4f.CompareEquals (a, b);
+ Vector4f c = Vector4f.CompareEqual (a, b);
if (((Vector4ui)c).X != 0)
return 1;
public static int test_0_vector4ui_sar () {
Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
- Vector4ui c = Vector4ui.ShiftRightArithmetic (a, 2);
+ Vector4ui c = Vector4ui.ArithmeticRightShift (a, 2);
if (c.X != 0xFC000000)
return 1;
static int test_0_vector8us_sub_sat () {
Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
- Vector8us c = Vector8us.SubWithSaturation (a, b);
+ Vector8us c = Vector8us.SubtractWithSaturation (a, b);
if (c.V0 != 0)
return 1;
static int test_0_vector8us_shift_right_arithmetic () {
Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
int amt = 2;
- Vector8us c = Vector8us.ShiftRightArithmetic (a, amt);
+ Vector8us c = Vector8us.ArithmeticRightShift (a, amt);
if (c.V0 != 0xFFC0)
return 1;
return 0;
}
- static int test_0_vector16b_sar () {
- Vector16b a = new Vector16b (0xF0,20,3,40,0,0,0,0,0,0,0,0,0,0,0,0);
-
- Vector16b c = Vector16b.ShiftRightArithmetic (a, 2);
- if (c.V0 != 0xFC)
- return 1;
- if (c.V1 != 5)
- return 1;
- if (c.V2 != 0)
- return 2;
- if (c.V3 != 10)
- return 3;
- return 0;
- }
-
static int test_0_vector16b_sub_sat () {
Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
- Vector16b c = Vector16b.SubWithSaturation (a, b);
+ Vector16b c = Vector16b.SubtractWithSaturation (a, b);
if (c.V0 != 0)
return 1;