From 342af4ccedda5f248931c5bdb7e9985580f23432 Mon Sep 17 00:00:00 2001 From: LDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com> Date: Sun, 31 Mar 2019 23:53:28 +0200 Subject: [PATCH] Update VectorHelper.cs --- ChocolArm64/Instructions/VectorHelper.cs | 87 +++++------------------- 1 file changed, 16 insertions(+), 71 deletions(-) diff --git a/ChocolArm64/Instructions/VectorHelper.cs b/ChocolArm64/Instructions/VectorHelper.cs index edb3428d85..d1dfaced41 100644 --- a/ChocolArm64/Instructions/VectorHelper.cs +++ b/ChocolArm64/Instructions/VectorHelper.cs @@ -26,8 +26,8 @@ namespace ChocolArm64.Instructions { if (float.IsNaN(value)) return 0; - return value > int.MaxValue ? int.MaxValue : - value < int.MinValue ? int.MinValue : (int)value; + return value >= int.MaxValue ? int.MaxValue : + value <= int.MinValue ? int.MinValue : (int)value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -35,8 +35,8 @@ namespace ChocolArm64.Instructions { if (float.IsNaN(value)) return 0; - return value > long.MaxValue ? long.MaxValue : - value < long.MinValue ? long.MinValue : (long)value; + return value >= long.MaxValue ? long.MaxValue : + value <= long.MinValue ? long.MinValue : (long)value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -44,8 +44,8 @@ namespace ChocolArm64.Instructions { if (float.IsNaN(value)) return 0; - return value > uint.MaxValue ? uint.MaxValue : - value < uint.MinValue ? uint.MinValue : (uint)value; + return value >= uint.MaxValue ? uint.MaxValue : + value <= uint.MinValue ? uint.MinValue : (uint)value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -53,8 +53,8 @@ namespace ChocolArm64.Instructions { if (float.IsNaN(value)) return 0; - return value > ulong.MaxValue ? ulong.MaxValue : - value < ulong.MinValue ? ulong.MinValue : (ulong)value; + return value >= ulong.MaxValue ? ulong.MaxValue : + value <= ulong.MinValue ? ulong.MinValue : (ulong)value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -62,8 +62,8 @@ namespace ChocolArm64.Instructions { if (double.IsNaN(value)) return 0; - return value > int.MaxValue ? int.MaxValue : - value < int.MinValue ? int.MinValue : (int)value; + return value >= int.MaxValue ? int.MaxValue : + value <= int.MinValue ? int.MinValue : (int)value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -71,8 +71,8 @@ namespace ChocolArm64.Instructions { if (double.IsNaN(value)) return 0; - return value > long.MaxValue ? long.MaxValue : - value < long.MinValue ? long.MinValue : (long)value; + return value >= long.MaxValue ? long.MaxValue : + value <= long.MinValue ? long.MinValue : (long)value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -80,8 +80,8 @@ namespace ChocolArm64.Instructions { if (double.IsNaN(value)) return 0; - return value > uint.MaxValue ? uint.MaxValue : - value < uint.MinValue ? uint.MinValue : (uint)value; + return value >= uint.MaxValue ? uint.MaxValue : + value <= uint.MinValue ? uint.MinValue : (uint)value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -89,8 +89,8 @@ namespace ChocolArm64.Instructions { if (double.IsNaN(value)) return 0; - return value > ulong.MaxValue ? ulong.MaxValue : - value < ulong.MinValue ? ulong.MinValue : (ulong)value; + return value >= ulong.MaxValue ? ulong.MaxValue : + value <= ulong.MinValue ? ulong.MinValue : (ulong)value; } public static double Round(double value, CpuThreadState state) @@ -500,50 +500,6 @@ namespace ChocolArm64.Instructions return Sse41.Insert(vector, value, 0b1110); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector128 VectorSByteZero() - { - if (Sse2.IsSupported) - { - return Sse2.SetZeroVector128(); - } - - throw new PlatformNotSupportedException(); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector128 VectorInt16Zero() - { - if (Sse2.IsSupported) - { - return Sse2.SetZeroVector128(); - } - - throw new PlatformNotSupportedException(); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector128 VectorInt32Zero() - { - if (Sse2.IsSupported) - { - return Sse2.SetZeroVector128(); - } - - throw new PlatformNotSupportedException(); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector128 VectorInt64Zero() - { - if (Sse2.IsSupported) - { - return Sse2.SetZeroVector128(); - } - - throw new PlatformNotSupportedException(); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector128 VectorSingleZero() { @@ -554,16 +510,5 @@ namespace ChocolArm64.Instructions throw new PlatformNotSupportedException(); } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector128 VectorDoubleZero() - { - if (Sse2.IsSupported) - { - return Sse2.SetZeroVector128(); - } - - throw new PlatformNotSupportedException(); - } } }