Skip to content

Commit

Permalink
[wasm] Fix Vector128 SIMD fmin and fmax (#93556)
Browse files Browse the repository at this point in the history
* [wasm] Fix SIMD fmin and fmax

So that it propagates NaNs

* Revert "[wasm] Disable `TensorPrimitivesTests.ConvertToHalf_SpecialValues` (#92953)"

This reverts commit 01cab29.
  • Loading branch information
radekdoulik authored Oct 17, 2023
1 parent c5e7081 commit 72e6953
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public static void ConvertToHalf(int tensorLength)
}

[Theory]
[ActiveIssue("https://github.com/dotnet/runtime/issues/92885", typeof(PlatformDetection), nameof(PlatformDetection.IsBrowser), nameof(PlatformDetection.IsMonoAOT))]
[MemberData(nameof(TensorLengths))]
public static void ConvertToHalf_SpecialValues(int tensorLength)
{
Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono/mini/llvm-intrinsics.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ INTRINS_OVR_2_ARG(WASM_NARROW_UNSIGNED_V16, wasm_narrow_unsigned, Wasm, sse_i1_t
INTRINS_OVR_2_ARG(WASM_NARROW_UNSIGNED_V8, wasm_narrow_unsigned, Wasm, sse_i2_t, sse_i4_t)
INTRINS_OVR_2_ARG(WASM_CONV_R8_TO_I4, fptosi_sat, Generic, v64_i4_t, v128_r8_t)
INTRINS_OVR_2_ARG(WASM_CONV_R8_TO_U4, fptoui_sat, Generic, v64_i4_t, v128_r8_t)
INTRINS_OVR_TAG(WASM_FMAX, maximum, Generic, V128 | R4 | R8)
INTRINS_OVR_TAG(WASM_FMIN, minimum, Generic, V128 | R4 | R8)
INTRINS_OVR_TAG(WASM_PMAX, wasm_pmax, Wasm, V128 | R4 | R8)
INTRINS_OVR_TAG(WASM_PMIN, wasm_pmin, Wasm, V128 | R4 | R8)
INTRINS_OVR(WASM_PMAX_V4, fabs, Generic, sse_r4_t)
Expand Down
6 changes: 5 additions & 1 deletion src/mono/mono/mini/mini-llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -8276,9 +8276,13 @@ MONO_RESTORE_WARNING
result = fcmp_and_select (builder, ins, l, r);
}

#elif defined(TARGET_ARM64)
#elif defined(TARGET_ARM64) || defined(TARGET_WASM)
LLVMValueRef min_max_args [] = { l, r };
#ifdef TARGET_WASM
IntrinsicId iid = ins->inst_c0 == OP_FMAX ? INTRINS_WASM_FMAX : INTRINS_WASM_FMIN;
#else
IntrinsicId iid = ins->inst_c0 == OP_FMAX ? INTRINS_AARCH64_ADV_SIMD_FMAX : INTRINS_AARCH64_ADV_SIMD_FMIN;
#endif
llvm_ovr_tag_t ovr_tag = ovr_tag_from_mono_vector_class (ins->klass);
result = call_overloaded_intrins (ctx, iid, ovr_tag, min_max_args, "");
#else
Expand Down

0 comments on commit 72e6953

Please sign in to comment.