Skip to content

[wasm][aot] Reenable AOT System.Runtime.Intrinsics/tests and fix problems that exposed #115204

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

Merged
merged 6 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,11 @@
<GrpcTestProject Include="$(RepoRoot)\src\tests\FunctionalTests\Android\Device_Emulator\gRPC\Android.Device_Emulator.gRPC.Test.csproj" />
</ItemGroup>

<!-- browser smoke tests -->
<ItemGroup Condition="'$(TargetOS)' == 'browser'">
<SmokeTestProject Include="$(MSBuildThisFileDirectory)System.Runtime.Intrinsics\tests\System.Runtime.Intrinsics.Tests.csproj" />
</ItemGroup>

<!-- wasi/interp smoke tests -->
<ItemGroup Condition="'$(TargetOS)' == 'wasi' and '$(RunAOTCompilation)' != 'true'">
<SmokeTestProject Include="$(MSBuildThisFileDirectory)Microsoft.XmlSerializer.Generator\tests\Microsoft.XmlSerializer.Generator.Tests.csproj" />
Expand Down
35 changes: 22 additions & 13 deletions src/mono/mono/mini/mini-llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -10449,20 +10449,29 @@ MONO_RESTORE_WARNING
break;
}
case OP_WASM_SIMD_SWIZZLE: {
LLVMValueRef bidx = LLVMBuildBitCast (builder, rhs, LLVMVectorType (i1_t, 16), "");
int nelems = LLVMGetVectorSize (LLVMTypeOf (lhs));
if (nelems == 16) {
LLVMValueRef args [] = { lhs, rhs };
values [ins->dreg] = call_intrins (ctx, INTRINS_WASM_SWIZZLE, args, "");
break;
}

LLVMValueRef indexes [16];
for (int i = 0; i < nelems; ++i)
indexes [i] = LLVMBuildExtractElement (builder, rhs, const_int32 (i), "");
LLVMValueRef shuffle_val = LLVMConstNull (LLVMVectorType (i4_t, nelems));
for (int i = 0; i < nelems; ++i)
shuffle_val = LLVMBuildInsertElement (builder, shuffle_val, convert (ctx, indexes [i], i4_t), const_int32 (i), "");
values [ins->dreg] = LLVMBuildShuffleVector (builder, lhs, LLVMGetUndef (LLVMTypeOf (lhs)), shuffle_val, "");
if (nelems < 16) {
int shift = nelems == 8 ? 1 : (nelems == 4 ? 2 : 3);
LLVMValueRef fill = LLVMConstNull (LLVMVectorType (i1_t, 16));
LLVMValueRef offset = LLVMConstNull (LLVMVectorType (i1_t, 16));
int stride = 16 / nelems;
for (int i = 0; i < nelems; ++i) {
for (int j = 0; j < stride; ++j) {
offset = LLVMBuildInsertElement (builder, offset, const_int8 (j), const_int8 (i * stride + j), "");
fill = LLVMBuildInsertElement (builder, fill, const_int8 (i * stride), const_int8 (i * stride + j), "");
}
}
LLVMValueRef shiftv = create_shift_vector (ctx, bidx, const_int32 (shift));
bidx = LLVMBuildShl (builder, bidx, shiftv, "");
LLVMValueRef args [] = { bidx, fill };
bidx = call_intrins (ctx, INTRINS_WASM_SWIZZLE, args, "");
bidx = LLVMBuildAdd (builder, bidx, offset, "");
}
LLVMValueRef lhs_b = LLVMBuildBitCast (builder, lhs, LLVMVectorType (i1_t, 16), "");
LLVMValueRef args [] = { lhs_b, bidx };
LLVMValueRef result_b = call_intrins (ctx, INTRINS_WASM_SWIZZLE, args, "");
values [ins->dreg] = LLVMBuildBitCast (builder, result_b, LLVMTypeOf (lhs), "");
break;
}
case OP_WASM_EXTRACT_NARROW: {
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/mini/simd-intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -6154,8 +6154,8 @@ static SimdIntrinsic packedsimd_methods [] = {
{SN_LoadScalarVector128},
{SN_LoadVector128, OP_LOADX_MEMBASE},
{SN_LoadWideningVector128, OP_WASM_SIMD_LOAD_WIDENING},
{SN_Max, OP_XBINOP, OP_IMIN, OP_XBINOP, OP_IMIN_UN, OP_XBINOP, OP_FMIN},
{SN_Min, OP_XBINOP, OP_IMAX, OP_XBINOP, OP_IMAX_UN, OP_XBINOP, OP_FMAX},
{SN_Max, OP_XBINOP, OP_IMAX, OP_XBINOP, OP_IMAX_UN, OP_XBINOP, OP_FMAX},
{SN_Min, OP_XBINOP, OP_IMIN, OP_XBINOP, OP_IMIN_UN, OP_XBINOP, OP_FMIN},
{SN_Multiply},
{SN_MultiplyRoundedSaturateQ15, OP_XOP_X_X_X, INTRINS_WASM_Q15MULR_SAT_SIGNED},
{SN_MultiplyWideningLower, OP_WASM_EXTMUL_LOWER, 0, OP_WASM_EXTMUL_LOWER_U},
Expand Down
Loading