From 4ff7eca4e02f8e09d134e4fac0dd202d484df899 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Mon, 14 Nov 2022 04:30:20 -0500 Subject: [PATCH] [mono] Fix some asserts caused by #78182. (#78291) Fixes https://github.com/dotnet/runtime/issues/78290. --- src/mono/mono/mini/simd-intrinsics.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/mono/mono/mini/simd-intrinsics.c b/src/mono/mono/mini/simd-intrinsics.c index fbe696fe41efc..7f184fc7ab06f 100644 --- a/src/mono/mono/mini/simd-intrinsics.c +++ b/src/mono/mono/mini/simd-intrinsics.c @@ -684,7 +684,8 @@ get_vector_t_elem_type (MonoType *vector_type) } static gboolean -type_is_unsigned (MonoType *type) { +type_is_unsigned (MonoType *type) +{ MonoClass *klass = mono_class_from_mono_type_internal (type); MonoType *etype = mono_class_get_context (klass)->class_inst->type_argv [0]; return type_enum_is_unsigned (etype->type); @@ -705,7 +706,8 @@ type_enum_is_unsigned (MonoTypeEnum type) } static gboolean -type_is_float (MonoType *type) { +type_is_float (MonoType *type) +{ MonoClass *klass = mono_class_from_mono_type_internal (type); MonoType *etype = mono_class_get_context (klass)->class_inst->type_argv [0]; return type_enum_is_float (etype->type); @@ -2145,12 +2147,14 @@ emit_sys_numerics_vector_t (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSig klass = cmethod->klass; type = m_class_get_byval_arg (klass); etype = mono_class_get_context (klass)->class_inst->type_argv [0]; + + if (!MONO_TYPE_IS_VECTOR_PRIMITIVE (etype)) + return NULL; + size = mono_class_value_size (mono_class_from_mono_type_internal (etype), NULL); g_assert (size); len = register_size / size; - if (!MONO_TYPE_IS_VECTOR_PRIMITIVE (etype)) - return NULL; if (cfg->verbose_level > 1) { char *name = mono_method_full_name (cmethod, TRUE); @@ -4193,13 +4197,14 @@ emit_vector256_t (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fs klass = cmethod->klass; etype = mono_class_get_context (klass)->class_inst->type_argv [0]; - size = mono_class_value_size (mono_class_from_mono_type_internal (etype), NULL); - g_assert (size); - len = 32 / size; if (!MONO_TYPE_IS_VECTOR_PRIMITIVE (etype)) return NULL; + size = mono_class_value_size (mono_class_from_mono_type_internal (etype), NULL); + g_assert (size); + len = 32 / size; + if (cfg->verbose_level > 1) { char *name = mono_method_full_name (cmethod, TRUE); printf (" SIMD intrinsic %s\n", name);