diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index 603cd256109134..23ceed3cde357d 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -10638,17 +10638,16 @@ NamedIntrinsic Compiler::lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method) if (isVectorT || (strcmp(className, "Vector") == 0)) { - if (strncmp(methodName, - "System.Runtime.Intrinsics.ISimdVector APIs to still be expanded where // possible but, they all prefix the qualified name of the interface first, so we'll // check for that and skip the prefix before trying to resolve the method. - if (strncmp(methodName + 70, ",T>.", 7) == 0) + if (strncmp(methodName + 60, ",T>.", 7) == 0) { - methodName += 77; + methodName += 67; } } diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 70dde2b702ea3b..a0a98dc9fae023 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -4421,29 +4421,38 @@ private bool notifyInstructionSetUsage(InstructionSet instructionSet, bool suppo } else { + // We want explicitly implemented ISimdVector APIs to still be expanded where possible + // but, they all prefix the qualified name of the interface first, so we'll check for that and + // skip the prefix before trying to resolve the method. ReadOnlySpan methodName = MethodBeingCompiled.Name.AsSpan(); - if (methodName.StartsWith("System.Runtime.Intrinsics.ISimdVector APIs to still be expanded where possible - // but, they all prefix the qualified name of the interface first, so we'll check for that and - // skip the prefix before trying to resolve the method. + ReadOnlySpan partialMethodName = methodName.Slice(45); - ReadOnlySpan partialMethodName = methodName.Slice(70); - - if (partialMethodName.StartsWith(",T>.")) - { - methodName = partialMethodName.Slice(7); - } - else if (partialMethodName.StartsWith("64,T>.")) + if (partialMethodName.StartsWith("Numerics.Vector")) { - methodName = partialMethodName.Slice(9); + partialMethodName = partialMethodName.Slice(15); + + if (partialMethodName.StartsWith(",T>.")) + { + methodName = partialMethodName.Slice(7); + } } - else if (partialMethodName.StartsWith("128,T>.") || - partialMethodName.StartsWith("256,T>.") || - partialMethodName.StartsWith("512,T>.")) + if (partialMethodName.StartsWith("Runtime.Intrinsics.Vector")) { - methodName = partialMethodName.Slice(10); + partialMethodName = partialMethodName.Slice(25); + + if (partialMethodName.StartsWith("64,T>.")) + { + methodName = partialMethodName.Slice(9); + } + else if (partialMethodName.StartsWith("128,T>.") || + partialMethodName.StartsWith("256,T>.") || + partialMethodName.StartsWith("512,T>.")) + { + methodName = partialMethodName.Slice(10); + } } } diff --git a/src/mono/mono/mini/interp/transform-simd.c b/src/mono/mono/mini/interp/transform-simd.c index f98cc584b8dea5..f7496ce839f9ea 100644 --- a/src/mono/mono/mini/interp/transform-simd.c +++ b/src/mono/mono/mini/interp/transform-simd.c @@ -679,20 +679,25 @@ static gboolean emit_sn_vector_t (TransformData *td, MonoMethod *cmethod, MonoMethodSignature *csignature, gboolean newobj) { const char *cmethod_name = cmethod->name; + bool explicitly_implemented = false; - if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector,T>.", 67) == 0) { // We want explicitly implemented ISimdVector APIs to still be expanded where possible // but, they all prefix the qualified name of the interface first, so we'll check for that and // skip the prefix before trying to resolve the method. - if (strncmp(cmethod_name + 70, ",T>.", 7) == 0) { - cmethod_name += 77; - } + cmethod_name += 67; + explicitly_implemented = true; } int id = lookup_intrins (sn_vector_t_methods, sizeof (sn_vector_t_methods), cmethod_name); - if (id == -1) - return FALSE; + if (id == -1) { + if (explicitly_implemented) { + return emit_sri_vector128 (td, cmethod, csignature); + } else { + return FALSE; + } + } gint16 simd_opcode = -1; gint16 simd_intrins = -1; diff --git a/src/mono/mono/mini/intrinsics.c b/src/mono/mono/mini/intrinsics.c index 046dfa79e5b0a7..6b8e8642259826 100644 --- a/src/mono/mono/mini/intrinsics.c +++ b/src/mono/mono/mini/intrinsics.c @@ -2396,19 +2396,21 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign !strncmp ("System.Runtime.Intrinsics", cmethod_klass_name_space, 25))) { const char* cmethod_name = cmethod->name; - if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector APIs to still be expanded where possible - // but, they all prefix the qualified name of the interface first, so we'll check for that and - // skip the prefix before trying to resolve the method. - - if (strncmp(cmethod_name + 70, ",T>.", 7) == 0) { - cmethod_name += 77; - } else if (strncmp(cmethod_name + 70, "64,T>.", 9) == 0) { - cmethod_name += 79; - } else if ((strncmp(cmethod_name + 70, "128,T>.", 10) == 0) || - (strncmp(cmethod_name + 70, "256,T>.", 10) == 0) || - (strncmp(cmethod_name + 70, "512,T>.", 10) == 0)) { - cmethod_name += 80; + if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector APIs to still be expanded where possible + // but, they all prefix the qualified name of the interface first, so we'll check for that and + // skip the prefix before trying to resolve the method. + + if (strncmp(cmethod_name + 70, "64,T>.", 9) == 0) { + cmethod_name += 79; + } else if ((strncmp(cmethod_name + 70, "128,T>.", 10) == 0) || + (strncmp(cmethod_name + 70, "256,T>.", 10) == 0) || + (strncmp(cmethod_name + 70, "512,T>.", 10) == 0)) { + cmethod_name += 80; + } + } else if (strncmp(cmethod_name + 45, "Numerics.Vector,T>.", 22) == 0) { + cmethod_name += 67; } } diff --git a/src/mono/mono/mini/simd-intrinsics.c b/src/mono/mono/mini/simd-intrinsics.c index d5303b4f9542be..f9d8d4b59ef559 100644 --- a/src/mono/mono/mini/simd-intrinsics.c +++ b/src/mono/mono/mini/simd-intrinsics.c @@ -1906,19 +1906,21 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi { const char *cmethod_name = cmethod->name; - if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector APIs to still be expanded where possible // but, they all prefix the qualified name of the interface first, so we'll check for that and // skip the prefix before trying to resolve the method. - if (strncmp(cmethod_name + 70, ",T>.", 7) == 0) { - cmethod_name += 77; - } else if (strncmp(cmethod_name + 70, "64,T>.", 9) == 0) { - cmethod_name += 79; - } else if ((strncmp(cmethod_name + 70, "128,T>.", 10) == 0) || - (strncmp(cmethod_name + 70, "256,T>.", 10) == 0) || - (strncmp(cmethod_name + 70, "512,T>.", 10) == 0)) { - cmethod_name += 80; + if (strncmp(cmethod_name + 70, "64,T>.", 9) == 0) { + cmethod_name += 79; + } else if ((strncmp(cmethod_name + 70, "128,T>.", 10) == 0) || + (strncmp(cmethod_name + 70, "256,T>.", 10) == 0) || + (strncmp(cmethod_name + 70, "512,T>.", 10) == 0)) { + cmethod_name += 80; + } + } else if (strncmp(cmethod_name + 45, "Numerics.Vector,T>.", 22) == 0) { + cmethod_name += 67; } } @@ -2437,7 +2439,7 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi const char *klass_name = m_class_get_name (klass); - if (!strcmp (klass_name, "Vector4")) { + if (strcmp (m_class_get_name_space (klass), "System.Runtime.Intrinsics") != 0) { klass_name = "Vector128`1"; } arg_class = create_class_instance ("System.Runtime.Intrinsics", klass_name, m_class_get_byval_arg (cast_class)); @@ -3371,21 +3373,23 @@ emit_sri_vector_t (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f const char *cmethod_name = cmethod->name; bool explicitly_implemented = false; - if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector APIs to still be expanded where possible - // but, they all prefix the qualified name of the interface first, so we'll check for that and - // skip the prefix before trying to resolve the method. - - if (strncmp(cmethod_name + 70, ",T>.", 7) == 0) { - cmethod_name += 77; - explicitly_implemented = true; - } else if (strncmp(cmethod_name + 70, "64,T>.", 9) == 0) { - cmethod_name += 79; - explicitly_implemented = true; - } else if ((strncmp(cmethod_name + 70, "128,T>.", 10) == 0) || - (strncmp(cmethod_name + 70, "256,T>.", 10) == 0) || - (strncmp(cmethod_name + 70, "512,T>.", 10) == 0)) { - cmethod_name += 80; + if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector APIs to still be expanded where possible + // but, they all prefix the qualified name of the interface first, so we'll check for that and + // skip the prefix before trying to resolve the method. + + if (strncmp(cmethod_name + 70, "64,T>.", 9) == 0) { + cmethod_name += 79; + explicitly_implemented = true; + } else if ((strncmp(cmethod_name + 70, "128,T>.", 10) == 0) || + (strncmp(cmethod_name + 70, "256,T>.", 10) == 0) || + (strncmp(cmethod_name + 70, "512,T>.", 10) == 0)) { + cmethod_name += 80; + explicitly_implemented = true; + } + } else if (strncmp(cmethod_name + 45, "Numerics.Vector,T>.", 22) == 0) { + cmethod_name += 67; explicitly_implemented = true; } }