Skip to content

Commit 72e6953

Browse files
authored
[wasm] Fix Vector128 SIMD fmin and fmax (#93556)
* [wasm] Fix SIMD fmin and fmax So that it propagates NaNs * Revert "[wasm] Disable `TensorPrimitivesTests.ConvertToHalf_SpecialValues` (#92953)" This reverts commit 01cab29.
1 parent c5e7081 commit 72e6953

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/libraries/System.Numerics.Tensors/tests/TensorPrimitivesTests.netcore.cs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public static void ConvertToHalf(int tensorLength)
3737
}
3838

3939
[Theory]
40-
[ActiveIssue("https://github.com/dotnet/runtime/issues/92885", typeof(PlatformDetection), nameof(PlatformDetection.IsBrowser), nameof(PlatformDetection.IsMonoAOT))]
4140
[MemberData(nameof(TensorLengths))]
4241
public static void ConvertToHalf_SpecialValues(int tensorLength)
4342
{

src/mono/mono/mini/llvm-intrinsics.h

+2
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ INTRINS_OVR_2_ARG(WASM_NARROW_UNSIGNED_V16, wasm_narrow_unsigned, Wasm, sse_i1_t
289289
INTRINS_OVR_2_ARG(WASM_NARROW_UNSIGNED_V8, wasm_narrow_unsigned, Wasm, sse_i2_t, sse_i4_t)
290290
INTRINS_OVR_2_ARG(WASM_CONV_R8_TO_I4, fptosi_sat, Generic, v64_i4_t, v128_r8_t)
291291
INTRINS_OVR_2_ARG(WASM_CONV_R8_TO_U4, fptoui_sat, Generic, v64_i4_t, v128_r8_t)
292+
INTRINS_OVR_TAG(WASM_FMAX, maximum, Generic, V128 | R4 | R8)
293+
INTRINS_OVR_TAG(WASM_FMIN, minimum, Generic, V128 | R4 | R8)
292294
INTRINS_OVR_TAG(WASM_PMAX, wasm_pmax, Wasm, V128 | R4 | R8)
293295
INTRINS_OVR_TAG(WASM_PMIN, wasm_pmin, Wasm, V128 | R4 | R8)
294296
INTRINS_OVR(WASM_PMAX_V4, fabs, Generic, sse_r4_t)

src/mono/mono/mini/mini-llvm.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -8276,9 +8276,13 @@ MONO_RESTORE_WARNING
82768276
result = fcmp_and_select (builder, ins, l, r);
82778277
}
82788278

8279-
#elif defined(TARGET_ARM64)
8279+
#elif defined(TARGET_ARM64) || defined(TARGET_WASM)
82808280
LLVMValueRef min_max_args [] = { l, r };
8281+
#ifdef TARGET_WASM
8282+
IntrinsicId iid = ins->inst_c0 == OP_FMAX ? INTRINS_WASM_FMAX : INTRINS_WASM_FMIN;
8283+
#else
82818284
IntrinsicId iid = ins->inst_c0 == OP_FMAX ? INTRINS_AARCH64_ADV_SIMD_FMAX : INTRINS_AARCH64_ADV_SIMD_FMIN;
8285+
#endif
82828286
llvm_ovr_tag_t ovr_tag = ovr_tag_from_mono_vector_class (ins->klass);
82838287
result = call_overloaded_intrins (ctx, iid, ovr_tag, min_max_args, "");
82848288
#else

0 commit comments

Comments
 (0)