Skip to content

Commit 4a263b9

Browse files
committed
Ensure mono uses OP_RCONV_TO_* for Single.ConvertIntegerToNative
1 parent c0d450e commit 4a263b9

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/mono/mono/mini/intrinsics.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,6 +2324,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
23242324
}
23252325
} else if ((cmethod->klass == mono_defaults.double_class) || (cmethod->klass == mono_defaults.single_class)) {
23262326
MonoGenericContext *method_context = mono_method_get_context (cmethod);
2327+
bool isDouble = cmethod->klass == mono_defaults.double_class;
23272328
if (!strcmp (cmethod->name, "ConvertToIntegerNative") &&
23282329
method_context != NULL &&
23292330
method_context->method_inst->type_argc == 1) {
@@ -2332,41 +2333,41 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
23322333
MonoStackType tto_stack = STACK_I4;
23332334
switch (tto_type) {
23342335
case MONO_TYPE_I1:
2335-
opcode = OP_FCONV_TO_I1;
2336+
opcode = isDouble ? OP_FCONV_TO_I1 : OP_RCONV_TO_I1;
23362337
break;
23372338
case MONO_TYPE_I2:
2338-
opcode = OP_FCONV_TO_I2;
2339+
opcode = isDouble ? OP_FCONV_TO_I2 : OP_RCONV_TO_I2;
23392340
break;
23402341
#if TARGET_SIZEOF_VOID_P == 4
23412342
case MONO_TYPE_I:
23422343
#endif
23432344
case MONO_TYPE_I4:
2344-
opcode = OP_FCONV_TO_I4;
2345+
opcode = isDouble ? OP_FCONV_TO_I4 : OP_RCONV_TO_I4;
23452346
break;
23462347
#if TARGET_SIZEOF_VOID_P == 8
23472348
case MONO_TYPE_I:
23482349
#endif
23492350
case MONO_TYPE_I8:
2350-
opcode = OP_FCONV_TO_I8;
2351+
opcode = isDouble ? OP_FCONV_TO_I8 : OP_RCONV_TO_I8;
23512352
tto_stack = STACK_I8;
23522353
break;
23532354
case MONO_TYPE_U1:
2354-
opcode = OP_FCONV_TO_U1;
2355+
opcode = isDouble ? OP_FCONV_TO_U1 : OP_RCONV_TO_U1;
23552356
break;
23562357
case MONO_TYPE_U2:
2357-
opcode = OP_FCONV_TO_U2;
2358+
opcode = isDouble ? OP_FCONV_TO_U2 : OP_RCONV_TO_U2;
23582359
break;
23592360
#if TARGET_SIZEOF_VOID_P == 4
23602361
case MONO_TYPE_U:
23612362
#endif
23622363
case MONO_TYPE_U4:
2363-
opcode = OP_FCONV_TO_U4;
2364+
opcode = isDouble ? OP_FCONV_TO_U4 : OP_RCONV_TO_U4;
23642365
break;
23652366
#if TARGET_SIZEOF_VOID_P == 8
23662367
case MONO_TYPE_U:
23672368
#endif
23682369
case MONO_TYPE_U8:
2369-
opcode = OP_FCONV_TO_U8;
2370+
opcode = isDouble ? OP_FCONV_TO_U8 : OP_RCONV_TO_U8;
23702371
tto_stack = STACK_I8;
23712372
break;
23722373
default: return NULL;

0 commit comments

Comments
 (0)