Skip to content

Commit 12ef82b

Browse files
committed
Allow scalar args to splat
1 parent fb7b613 commit 12ef82b

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/libraries/System.Runtime.Intrinsics/tests/Wasm/PackedSimdTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,34 @@ public unsafe void MinMaxSignedUnsignedTest()
377377
Assert.Equal((byte)0, unsignedMin.GetElement(0));
378378
}
379379

380+
[Fact]
381+
public unsafe void SplatTypes()
382+
{
383+
Assert.Equal(Vector128.Create(2.5f, 2.5f, 2.5f, 2.5f), PackedSimd.Splat(2.5f));
384+
Assert.Equal(Vector128.Create(2, 2, 2, 2), PackedSimd.Splat(2L));
385+
Assert.Equal(Vector128.Create(2.5, 2.5), PackedSimd.Splat(2.5));
386+
Assert.Equal(Vector128.Create(2L, 2L, PackedSimd.Splat(2L));
387+
Assert.Equal(Vector128.Create(2UL, 2UL, PackedSimd.Splat(2UL));
388+
Assert.Equal(Vector128.Create(
389+
(byte)2, (byte)2, (byte)2, (byte)2,
390+
(byte)2, (byte)2, (byte)2, (byte)2,
391+
(byte)2, (byte)2, (byte)2, (byte)2,
392+
(byte)2, (byte)2, (byte)2, (byte)2), PackedSimd.Splat((byte)2));
393+
Assert.Equal(Vector128.Create(
394+
(sbyte)-2, (sbyte)-2, (sbyte)-2, (sbyte)-2,
395+
(sbyte)-2, (sbyte)-2, (sbyte)-2, (sbyte)-2,
396+
(sbyte)-2, (sbyte)-2, (sbyte)-2, (sbyte)-2,
397+
(sbyte)-2, (sbyte)-2, (sbyte)-2, (sbyte)-2), PackedSimd.Splat((sbyte)-2));
398+
Assert.Equal(Vector128.Create(
399+
(short)-2, (short)-2, (short)-2, (short)-2,
400+
(short)-2, (short)-2, (short)-2, (short)-2), PackedSimd.Splat((short)-2));
401+
Assert.Equal(Vector128.Create(
402+
(ushort)2, (ushort)2, (ushort)2, (ushort)2,
403+
(ushort)2, (ushort)2, (ushort)2, (ushort)2), PackedSimd.Splat((ushort)2));
404+
Assert.Equal(Vector128.Create([(nint)-2, (nint)-2, (nint)-2, (nint)-2]), PackedSimd.Splat((nint)-2));
405+
Assert.Equal(Vector128.Create([(nuint)2, (nuint)2, (nuint)2, (nuint)2]), PackedSimd.Splat((nuint)2));
406+
}
407+
380408
[Fact]
381409
public unsafe void LoadScalarAndSplatInfinityTest()
382410
{

src/mono/mono/mini/interp/transform-simd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,8 @@ lookup_packedsimd_intrinsic (const char *name, MonoType *arg1)
993993
arg_type = mono_class_get_context (vector_klass)->class_inst->type_argv [0];
994994
} else if (arg1->type == MONO_TYPE_PTR) {
995995
arg_type = m_type_data_get_type_unchecked (arg1);
996+
} else if (MONO_TYPE_IS_VECTOR_PRIMITIVE(arg1))
997+
arg_type = arg1;
996998
} else {
997999
// g_printf ("%s arg1 type was not pointer or simd type: %s\n", name, m_class_get_name (vector_klass));
9981000
return FALSE;

0 commit comments

Comments
 (0)