From: Fan Yang <52458914+fanyang-mono@users.noreply.github.com> Date: Wed, 30 Nov 2022 15:45:04 +0000 (-0500) Subject: [Mono] Fix Vector128 divide by scalar (#78784) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~5232 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8158cb8be51bd6269c75e4010e2e25ada78578f0;p=platform%2Fupstream%2Fdotnet%2Fruntime.git [Mono] Fix Vector128 divide by scalar (#78784) * Fix divide by scalar * Add missing vector/vector and vector*vector case --- diff --git a/src/mono/mono/mini/simd-intrinsics.c b/src/mono/mono/mini/simd-intrinsics.c index c8208b3..aa5b040 100644 --- a/src/mono/mono/mini/simd-intrinsics.c +++ b/src/mono/mono/mini/simd-intrinsics.c @@ -302,6 +302,20 @@ emit_simd_ins_for_binary_op (MonoCompile *cfg, MonoClass *klass, MonoMethodSigna break; case SN_Divide: case SN_op_Division: + if (strcmp ("Vector4", m_class_get_name (klass)) && strcmp ("Vector2", m_class_get_name (klass))) { + if ((fsig->params [0]->type == MONO_TYPE_GENERICINST) && (fsig->params [1]->type != MONO_TYPE_GENERICINST)) { + MonoInst* ins = emit_simd_ins (cfg, klass, OP_CREATE_SCALAR_UNSAFE, args [1]->dreg, -1); + ins->inst_c1 = arg_type; + ins = emit_simd_ins (cfg, klass, OP_XBINOP_BYSCALAR, args [0]->dreg, ins->dreg); + ins->inst_c0 = OP_FDIV; + return ins; + } else if ((fsig->params [0]->type == MONO_TYPE_GENERICINST) && (fsig->params [1]->type == MONO_TYPE_GENERICINST)) { + instc0 = OP_FDIV; + break; + } else { + return NULL; + } + } instc0 = OP_FDIV; break; case SN_Max: @@ -325,6 +339,11 @@ emit_simd_ins_for_binary_op (MonoCompile *cfg, MonoClass *klass, MonoMethodSigna ins = emit_simd_ins (cfg, klass, OP_XBINOP_BYSCALAR, ins->dreg, args [1]->dreg); ins->inst_c0 = OP_FMUL; return ins; + } else if ((fsig->params [0]->type == MONO_TYPE_GENERICINST) && (fsig->params [1]->type == MONO_TYPE_GENERICINST)) { + instc0 = OP_FMUL; + break; + } else { + return NULL; } } instc0 = OP_FMUL;