[wasm] Fix type check for PackedSimd.Splat (#81100)
authorRadek Doulik <radek.doulik@gmail.com>
Wed, 25 Jan 2023 00:37:17 +0000 (01:37 +0100)
committerGitHub <noreply@github.com>
Wed, 25 Jan 2023 00:37:17 +0000 (18:37 -0600)
The Splat's 1st parameter is not Vector128'1, but element type.

Fixes this assertion:

    converting llvm method System.Runtime.Intrinsics.Vector128`1<sbyte> System.Runtime.Intrinsics.Wasm.PackedSimd:Splat (sbyte)
    * Assertion at D:\git\wa-local\src\mono\mono\mini\simd-intrinsics.c:690, condition `vector_type->type == MONO_TYPE_GENERICINST' not met

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

index 7073b84c6cc2674a39557113d19dbde14b885e47..d0b68be751e1577b282ec511d9e5e2d71e8c730c 100644 (file)
@@ -4406,7 +4406,8 @@ emit_wasm_supported_intrinsics (
        }
 
        if (feature == MONO_CPU_WASM_SIMD) {
-               if (!is_element_type_primitive (fsig->params [0]))
+               if (id != SN_Splat && !is_element_type_primitive (fsig->params [0]) ||
+                   id == SN_Splat && !MONO_TYPE_IS_VECTOR_PRIMITIVE(fsig->params [0]))
                        return NULL;
 
                switch (id) {