return 0;
}
+ public static int test_0_min_un () {
+ uint a = (uint)int.MaxValue + 10;
+
+ for (uint b = 7; b <= 10; ++b) {
+ if (Math.Min (a, b) != b)
+ return (int)b;
+ if (Math.Min (b, a) != b)
+ return (int)b;
+ return 0;
+ }
+
+ public static int test_0_max_un () {
+ uint a = (uint)int.MaxValue + 10;
+
+ for (uint b = 7; b <= 10; ++b) {
+ if (Math.Max (a, b) != a)
+ return (int)b;
+ if (Math.Max (b, a) != a)
+ return (int)b;
+ }
+ return 0;
+ }
+
public static int test_0_abs () {
double d = -5.0;
}
stmt: OP_MKREFANY_REGS (OP_GROUP (reg, reg), OP_GROUP (reg, reg)) {
- int class_reg = state->left->right->reg1;
g_assert (!s->compile_aot);
MONO_EMIT_NEW_STORE_MEMBASE (s, OP_STOREP_MEMBASE_REG,
state->right->right->reg1, G_STRUCT_OFFSET (MonoTypedRef, type), state->left->left->reg1);
state->right->right->reg1, G_STRUCT_OFFSET (MonoTypedRef, value), state->right->left->reg1);
}
-reg: OP_MIN (reg, reg) "2" {
- /* min (x,y) = y + (((x-y)>>31)&(x-y)); */
- int diff = mono_regstate_next_int (s->rs);
- int shifted = mono_regstate_next_int (s->rs);
- int anded = mono_regstate_next_int (s->rs);
- MONO_EMIT_NEW_BIALU (s, CEE_SUB, diff, state->left->reg1, state->right->reg1);
- MONO_EMIT_NEW_BIALU_IMM (s, OP_SHR_IMM, shifted, diff, (sizeof(void*)*8-1));
- MONO_EMIT_NEW_BIALU (s, CEE_AND, anded, shifted, diff);
- MONO_EMIT_NEW_BIALU (s, CEE_ADD, state->reg1, anded, state->right->reg1);
-}
-
-reg: OP_MAX (reg, reg) "2" {
- /* max (x,y) = x - (((x-y)>>31)&(x-y)); */
- int diff = mono_regstate_next_int (s->rs);
- int shifted = mono_regstate_next_int (s->rs);
- int anded = mono_regstate_next_int (s->rs);
- MONO_EMIT_NEW_BIALU (s, CEE_SUB, diff, state->left->reg1, state->right->reg1);
- MONO_EMIT_NEW_BIALU_IMM (s, OP_SHR_IMM, shifted, diff, (sizeof(void*)*8-1));
- MONO_EMIT_NEW_BIALU (s, CEE_AND, anded, shifted, diff);
- MONO_EMIT_NEW_BIALU (s, CEE_SUB, state->reg1, state->left->reg1, anded);
-}
-
%%
#ifdef MONO_ARCH_NEED_GOT_VAR
return NULL;
}
-static int
-is_unsigned_regsize_type (MonoType *type)
-{
- switch (type->type) {
- case MONO_TYPE_U1:
- case MONO_TYPE_U2:
- case MONO_TYPE_U4:
-#if SIZEOF_VOID_P == 8
- /*case MONO_TYPE_U8: this requires different opcodes in inssel.brg */
-#endif
- return TRUE;
- default:
- return FALSE;
- }
-}
-
static MonoInst*
mini_get_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args)
{
store->inst_right = load;
return store;
} else if (cmethod->klass == mono_defaults.math_class) {
- if (strcmp (cmethod->name, "Min") == 0) {
- if (is_unsigned_regsize_type (fsig->params [0])) {
- MONO_INST_NEW (cfg, ins, OP_MIN);
- ins->inst_i0 = args [0];
- ins->inst_i1 = args [1];
- return ins;
- }
- } else if (strcmp (cmethod->name, "Max") == 0) {
- if (is_unsigned_regsize_type (fsig->params [0])) {
- MONO_INST_NEW (cfg, ins, OP_MAX);
- ins->inst_i0 = args [0];
- ins->inst_i1 = args [1];
- return ins;
- }
- }
+ /*
+ * There is general branches code for Min/Max, but it does not work for
+ * all inputs:
+ * http://everything2.com/?node_id=1051618
+ */
} else if (cmethod->klass->image == mono_defaults.corlib &&
(strcmp (cmethod->klass->name_space, "System.Threading") == 0) &&
(strcmp (cmethod->klass->name, "Interlocked") == 0)) {