未验证 提交 7cb6fe69 编写于 作者: M Matous Kozak 提交者: GitHub

[mono] Remove Vector128 checks for amd64 APIs (#77534)

* Remove Vector128 checks for amd64 APIs

* refactor emit_sum_vector (amd64)
上级 76d4691b
......@@ -582,12 +582,8 @@ static const int fast_log2 [] = { -1, -1, 1, -1, 2, -1, -1, -1, 3 };
static MonoInst*
emit_sum_vector (MonoCompile *cfg, MonoType *vector_type, MonoTypeEnum element_type, MonoInst *arg)
{
MonoClass *arg_class = mono_class_from_mono_type_internal (vector_type);
int size = mono_class_value_size (arg_class, NULL);
if (size != 16) // Works only with Vector128
return NULL;
MonoClass *vector_class = mono_class_from_mono_type_internal (vector_type);
int instc0 = -1;
switch (element_type) {
case MONO_TYPE_R4:
......@@ -639,12 +635,13 @@ emit_sum_vector (MonoCompile *cfg, MonoType *vector_type, MonoTypeEnum element_t
if (!is_SIMD_feature_supported (cfg, feature))
return NULL;
MonoType *etype = mono_class_get_context (arg_class)->class_inst->type_argv [0];
int vector_size = mono_class_value_size (vector_class, NULL);
MonoType *etype = mono_class_get_context (vector_class)->class_inst->type_argv [0];
int elem_size = mono_class_value_size (mono_class_from_mono_type_internal (etype), NULL);
int num_elems = size / elem_size;
int num_elems = vector_size / elem_size;
int num_rounds = fast_log2[num_elems];
MonoInst *tmp = emit_xzero (cfg, arg_class);
MonoInst *tmp = emit_xzero (cfg, vector_class);
MonoInst *ins = arg;
// HorizontalAdds over vector log2(num_elems) times
for (int i = 0; i < num_rounds; ++i) {
......@@ -1150,10 +1147,6 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi
return emit_simd_ins_for_sig (cfg, klass, OP_XOP_OVR_X_X, iid, arg0_type, fsig, args);
#elif defined(TARGET_AMD64)
MonoClass *arg_class = mono_class_from_mono_type_internal (fsig->params [0]);
int size = mono_class_value_size (arg_class, NULL);
if (size != 16) // Works only with Vector128
return NULL;
if (type_enum_is_float(arg0_type)) {
// args [0] & ~vector(-0.0)
MonoInst *zero = emit_xzero(cfg, arg_class); // 0.0
......@@ -1186,11 +1179,6 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi
#ifdef TARGET_ARM64
return emit_simd_ins_for_sig (cfg, klass, OP_ARM64_BIC, -1, arg0_type, fsig, args);
#elif defined(TARGET_AMD64)
MonoClass* arg_class = mono_class_from_mono_type_internal (fsig->params [0]);
int size = mono_class_value_size (arg_class, NULL);
if (size != 16) // Works only with Vector128
return NULL;
/* Swap lhs and rhs because Vector128 needs lhs & !rhs
whereas SSE2 does !lhs & rhs */
MonoInst *tmp = args[0];
......@@ -1225,11 +1213,6 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi
int ceil_or_floor = id == SN_Ceiling ? INTRINS_AARCH64_ADV_SIMD_FRINTP : INTRINS_AARCH64_ADV_SIMD_FRINTM;
return emit_simd_ins_for_sig (cfg, klass, OP_XOP_OVR_X_X, ceil_or_floor, arg0_type, fsig, args);
#elif defined(TARGET_AMD64)
MonoClass* arg_class = mono_class_from_mono_type_internal (fsig->params [0]);
int size = mono_class_value_size (arg_class, NULL);
if (size != 16) // Supported only on Vector128
return NULL;
if (!is_SIMD_feature_supported (cfg, MONO_CPU_X86_SSE41))
return NULL;
......@@ -1335,11 +1318,6 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi
return emit_sum_vector (cfg, fsig->params [0], arg0_type, pairwise_multiply);
#elif defined(TARGET_AMD64)
MonoClass *arg_class = mono_class_from_mono_type_internal (fsig->params [0]);
int size = mono_class_value_size (arg_class, NULL);
if (size != 16) // Works only with Vector128
return NULL;
int instc =-1;
if (type_enum_is_float (arg0_type)) {
if (is_SIMD_feature_supported (cfg, MONO_CPU_X86_SSE41)) {
......@@ -1609,11 +1587,6 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi
#ifdef TARGET_ARM64
return emit_simd_ins_for_sig (cfg, klass, OP_XOP_OVR_X_X, INTRINS_AARCH64_ADV_SIMD_FSQRT, arg0_type, fsig, args);
#elif defined(TARGET_AMD64)
MonoClass *arg_class = mono_class_from_mono_type_internal (fsig->params [0]);
int size = mono_class_value_size (arg_class, NULL);
if (size != 16) // Only works with Vector128
return NULL;
int instc0 = arg0_type == MONO_TYPE_R4 ? INTRINS_SSE_SQRT_PS : INTRINS_SSE_SQRT_PD;
return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X, instc0, arg0_type, fsig, args);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册