Skip to content

Commit 8158cb8

Browse files
authored
[Mono] Fix Vector128 divide by scalar (#78784)
* Fix divide by scalar * Add missing vector/vector and vector*vector case
1 parent fc2bde4 commit 8158cb8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/mono/mono/mini/simd-intrinsics.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,20 @@ emit_simd_ins_for_binary_op (MonoCompile *cfg, MonoClass *klass, MonoMethodSigna
302302
break;
303303
case SN_Divide:
304304
case SN_op_Division:
305+
if (strcmp ("Vector4", m_class_get_name (klass)) && strcmp ("Vector2", m_class_get_name (klass))) {
306+
if ((fsig->params [0]->type == MONO_TYPE_GENERICINST) && (fsig->params [1]->type != MONO_TYPE_GENERICINST)) {
307+
MonoInst* ins = emit_simd_ins (cfg, klass, OP_CREATE_SCALAR_UNSAFE, args [1]->dreg, -1);
308+
ins->inst_c1 = arg_type;
309+
ins = emit_simd_ins (cfg, klass, OP_XBINOP_BYSCALAR, args [0]->dreg, ins->dreg);
310+
ins->inst_c0 = OP_FDIV;
311+
return ins;
312+
} else if ((fsig->params [0]->type == MONO_TYPE_GENERICINST) && (fsig->params [1]->type == MONO_TYPE_GENERICINST)) {
313+
instc0 = OP_FDIV;
314+
break;
315+
} else {
316+
return NULL;
317+
}
318+
}
305319
instc0 = OP_FDIV;
306320
break;
307321
case SN_Max:
@@ -325,6 +339,11 @@ emit_simd_ins_for_binary_op (MonoCompile *cfg, MonoClass *klass, MonoMethodSigna
325339
ins = emit_simd_ins (cfg, klass, OP_XBINOP_BYSCALAR, ins->dreg, args [1]->dreg);
326340
ins->inst_c0 = OP_FMUL;
327341
return ins;
342+
} else if ((fsig->params [0]->type == MONO_TYPE_GENERICINST) && (fsig->params [1]->type == MONO_TYPE_GENERICINST)) {
343+
instc0 = OP_FMUL;
344+
break;
345+
} else {
346+
return NULL;
328347
}
329348
}
330349
instc0 = OP_FMUL;

0 commit comments

Comments
 (0)