+
+ static long position = 0;
+
+ public static int test_4_static_inc_long () {
+
+ int count = 4;
+
+ position = 0;
+
+ position += count;
+
+ return (int)position;
+ }
+
+ struct FooStruct {
+
+ public FooStruct (long l) {
+ }
+ }
+
+ public static int test_0_calls_opcode_emulation () {
+ // Test that emulated opcodes do not clobber arguments already in
+ // out registers
+ checked {
+ long val = 10000;
+ new FooStruct (val * 10000);
+ }
+ return 0;
+ }
+
+ public static int test_0_intrins_string_length () {
+ string s = "ABC";
+
+ return (s.Length == 3) ? 0 : 1;
+ }
+
+ public static int test_0_intrins_string_chars () {
+ string s = "ABC";
+
+ return (s [0] == 'A' && s [1] == 'B' && s [2] == 'C') ? 0 : 1;
+ }
+
+ public static int test_0_intrins_object_gettype () {
+ object o = 1;
+
+ return (o.GetType () == typeof (int)) ? 0 : 1;
+ }
+
+ public static int test_0_intrins_object_gethashcode () {
+ object o = new Object ();
+
+ return (o.GetHashCode () == o.GetHashCode ()) ? 0 : 1;
+ }
+
+ class FooClass {
+ }
+
+ public static int test_0_intrins_object_ctor () {
+ object o = new FooClass ();
+
+ return (o != null) ? 0 : 1;
+ }
+
+ public static int test_0_intrins_array_rank () {
+ int[,] a = new int [10, 10];
+
+ return (a.Rank == 2) ? 0 : 1;
+ }
+
+ public static int test_0_intrins_array_length () {
+ int[,] a = new int [10, 10];
+ Array a2 = a;
+
+ return (a2.Length == 100) ? 0 : 1;
+ }
+
+ public static int test_0_intrins_runtimehelpers_offset_to_string_data () {
+ int i = RuntimeHelpers.OffsetToStringData;
+
+ return i - i;
+ }
+
+ public static int test_0_intrins_string_setchar () {
+ StringBuilder sb = new StringBuilder ("ABC");
+
+ sb [1] = 'D';
+
+ return sb.ToString () == "ADC" ? 0 : 1;
+ }
+
+ public class Bar {
+ bool allowLocation = true;
+ Foo f = new Foo ();
+ }
+
+ public static int test_0_regress_78990_unaligned_structs () {
+ new Bar ();
+
+ return 0;
+ }
+
+ public static unsafe int test_97_negative_index () {
+ char[] arr = new char[] {'a', 'b'};
+ fixed (char *p = arr) {
+ char *i = p + 2;
+ char a = i[-2];
+ return a;
+ }
+ }
+
+ /* bug #82281 */
+ public static int test_0_unsigned_right_shift_imm0 () {
+ uint temp = 0;
+ byte[] data = new byte[256];
+ for (int i = 0; i < 1; i ++)
+ temp = (uint)(data[temp >> 24] | data[temp >> 0]);
+ return 0;
+ }
+
+ class Foo2 {
+ public virtual int foo () {
+ return 0;
+ }
+ }
+
+ sealed class Bar2 : Foo2 {
+ public override int foo () {
+ return 0;
+ }
+ }
+
+ public static int test_0_abcrem_check_this_removal () {
+ Bar2 b = new Bar2 ();
+
+ // The check_this generated here by the JIT should be removed
+ b.foo ();
+
+ return 0;
+ }
+
+ static int invoke_twice (Bar2 b) {
+ b.foo ();
+ // The check_this generated here by the JIT should be removed
+ b.foo ();
+
+ return 0;
+ }
+
+ public static int test_0_abcrem_check_this_removal2 () {
+ Bar2 b = new Bar2 ();
+
+ invoke_twice (b);
+
+ return 0;
+ }
+
+ /* #346563 */
+ public static int test_0_array_access_64_bit () {
+ int[] arr2 = new int [10];
+ for (int i = 0; i < 10; ++i)
+ arr2 [i] = i;
+ string s = "ABCDEFGH";
+
+ byte[] arr = new byte [4];
+ arr [0] = 252;
+ arr [1] = 255;
+ arr [2] = 255;
+ arr [3] = 255;
+
+ int len = arr [0] | (arr [1] << 8) | (arr [2] << 16) | (arr [3] << 24);
+ int len2 = - (len + 2);
+
+ // Test array and string access with a 32 bit value whose upper 32 bits are
+ // undefined
+ // len2 = 3
+ if (arr2 [len2] != 2)
+ return 1;
+ if (s [len2] != 'C')
+ return 2;
+ return 0;
+ }
+
+ public static float return_float () {
+ return 1.4e-45f;
+ }
+
+ public static int test_0_float_return_spill () {
+ // The return value of return_float () is spilled because of the
+ // boxing call
+ object o = return_float ();
+ float f = return_float ();
+ return (float)o == f ? 0 : 1;
+ }
+
+ class R4Holder {
+ public static float pi = 3.14f;
+
+ public float float_field;
+ }
+
+ public static int test_0_ldsfld_soft_float () {
+ if (R4Holder.pi == 3.14f)
+ return 0;
+ else
+ return 1;
+ }
+
+ public static int test_0_ldfld_stfld_soft_float () {
+ R4Holder h = new R4Holder ();
+ h.float_field = 3.14f;
+
+ if (h.float_field == 3.14f)
+ return 0;
+ else
+ return 1;
+ }
+
+ class R4HolderRemote : MarshalByRefObject {
+ public static float pi = 3.14f;
+
+ public float float_field;
+ }
+
+ public static int test_0_ldfld_stfld_soft_float_remote () {
+ R4HolderRemote h = new R4HolderRemote ();
+ h.float_field = 3.14f;
+
+ if (h.float_field == 3.14f)
+ return 0;
+ else
+ return 1;
+ }
+
+ public static int test_0_locals_soft_float () {
+ float f = 0.0f;
+
+ f = 3.14f;
+
+ if (f == 3.14f)
+ return 0;
+ else
+ return 1;
+ }
+
+ static int range_check_strlen (int i, string s) {
+ if (i < 0 || i > s.Length)
+ return 1;
+ else
+ return 0;
+ }
+
+ public static int test_0_range_check_opt () {
+ if (range_check_strlen (0, "A") != 0)
+ return 1;
+ if (range_check_strlen (1, "A") != 0)
+ return 2;
+ if (range_check_strlen (2, "A") != 1)
+ return 3;
+ if (range_check_strlen (-100, "A") != 1)
+ return 4;
+ return 0;
+ }
+
+ static int test_0_array_get_set_soft_float () {
+ float[,] arr = new float [2, 2];
+ arr [0, 0] = 256f;
+ return arr [0, 0] == 256f ? 0 : 1;
+ }
+
+ //repro for #506915
+ struct Bug506915 { public int val; }
+ static int test_2_ldobj_stobj_optization ()
+ {
+ int i = 99;
+ var a = new Bug506915 ();
+ var b = new Bug506915 ();
+ if (i.GetHashCode () == 99)
+ i = 44;
+ var array = new Bug506915 [2];
+ array [0].val = 2;
+ array [1] = (i == 0) ? a : array [0];
+
+ return array [1].val;
+ }
+
+ /* mcs can't compile this (#646744) */
+#if FALSE
+ static void InitMe (out Gamma noMercyWithTheStack) {
+ noMercyWithTheStack = new Gamma ();
+ }
+
+ static int FunNoInline () {
+ int x = 99;
+ if (x > 344 && x < 22)
+ return 333;
+ return x;
+ }
+
+ static float DoNothingButDontInline (float a, int b) {
+ if (b > 0)
+ return a;
+ else if (b < 0 && b > 10)
+ return 444.0f;
+ return a;
+ }
+
+ /*
+ * The local register allocator emits loadr8_membase and storer8_membase
+ * to do spilling. This code is generated after mono_arch_lowering_pass so
+ * mono_arch_output_basic_block must know how to deal with big offsets.
+ * This only happens because the call in middle forces the temp for "(float)obj"
+ * to be spilled.
+ */
+ public static int test_0_float_load_and_store_with_big_offset ()
+ {
+ object obj = 1.0f;
+ Gamma noMercyWithTheStack;
+ float res;
+
+ InitMe (out noMercyWithTheStack);
+
+ res = DoNothingButDontInline ((float)obj, FunNoInline ());
+
+ if (!(res == 1.0f))
+ return 1;
+ return 0;
+ }
+#endif
+
+ struct VTypePhi {
+ public int i;
+ }
+
+ static int vtype_phi (VTypePhi v1, VTypePhi v2, bool first) {
+ VTypePhi v = first ? v1 : v2;
+
+ return v.i;
+ }
+
+ static int test_0_vtype_phi ()
+ {
+ VTypePhi v1 = new VTypePhi () { i = 1 };
+ VTypePhi v2 = new VTypePhi () { i = 2 };
+
+ if (vtype_phi (v1, v2, true) != 1)
+ return 1;
+ if (vtype_phi (v1, v2, false) != 2)
+ return 2;
+
+ return 0;
+ }
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ static void UseValue (int index)
+ {
+ }
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ static bool IsFalse ()
+ {
+ return false;
+ }
+
+ static int test_0_llvm_moving_faulting_loads ()
+ {
+ int[] indexes = null;
+
+ if (IsFalse ()) {
+ indexes = new int[0];
+ }
+
+ while (IsFalse ()) {
+ UseValue (indexes[0]);
+ UseValue (indexes[0]);
+ }
+
+ return 0;
+ }
+