Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mono] Fix Vector<T>.IsSupported intrinsic #90023

Merged
merged 7 commits into from
Aug 14, 2023
22 changes: 10 additions & 12 deletions src/mono/mono/mini/simd-intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -2346,11 +2346,19 @@ emit_vector64_vector128_t (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign

MonoClass *klass = cmethod->klass;
MonoType *etype = mono_class_get_context (klass)->class_inst->type_argv [0];
gboolean supported = TRUE;
gboolean is_primitive_element_type = MONO_TYPE_IS_VECTOR_PRIMITIVE (etype);

if (!MONO_TYPE_IS_VECTOR_PRIMITIVE (etype))
fanyang-mono marked this conversation as resolved.
Show resolved Hide resolved
// special case SN_get_IsSupported intrinsic which verifies whether a type parameter T is supported for a generic vector
if (id == SN_get_IsSupported) {
MonoInst *ins = NULL;
EMIT_NEW_ICONST (cfg, ins, is_primitive_element_type ? 1 : 0);
return ins;
}

if (!is_primitive_element_type)
return NULL;

gboolean supported = TRUE;
ivanpovazan marked this conversation as resolved.
Show resolved Hide resolved
int size = mono_class_value_size (klass, NULL);
int esize = mono_class_value_size (mono_class_from_mono_type_internal (etype), NULL);
g_assert (size > 0);
Expand Down Expand Up @@ -2383,16 +2391,6 @@ emit_vector64_vector128_t (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
#endif
#endif

switch (id) {
case SN_get_IsSupported: {
MonoInst *ins = NULL;
EMIT_NEW_ICONST (cfg, ins, supported ? 1 : 0);
return ins;
}
default:
break;
}

if (!supported)
return NULL;

Expand Down
Loading