[mono] Fix some asserts caused by #78182. (#78291)
authorZoltan Varga <vargaz@gmail.com>
Mon, 14 Nov 2022 09:30:20 +0000 (04:30 -0500)
committerGitHub <noreply@github.com>
Mon, 14 Nov 2022 09:30:20 +0000 (04:30 -0500)
Fixes https://github.com/dotnet/runtime/issues/78290.

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

index fbe696f..7f184fc 100644 (file)
@@ -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);