Use more accurate ReciprocalSqrt when available

Utilizes the AVX512 variant of `ReciprocalSqrt`([vrsqrt14ps](https://www.felixcloutier.com/x86/vrsqrt14ps)) that is accurate up to 14 bits of precision(rather than 12) when the host supports it.
This commit is contained in:
Wunkolo
2025-03-04 08:48:08 -08:00
parent 627804e330
commit 05ec427fec
+5
View File
@@ -114,6 +114,11 @@ internal static class Intrinsics
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector256<float> ReciprocalSqrt(Vector256<float> data) public static Vector256<float> ReciprocalSqrt(Vector256<float> data)
{ {
// Accurate to 14 bits
if (Avx512F.VL.IsSupported)
return Avx512F.VL.ReciprocalSqrt14(data);
// Accurate to 12 bits
if (Avx.IsSupported) if (Avx.IsSupported)
return Avx.ReciprocalSqrt(data); return Avx.ReciprocalSqrt(data);