Browse Source

Expand v128 native shuffle (float) support

pull/2918/head
James Jackson-South 1 year ago
parent
commit
55a8c73232
  1. 4
      src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs
  2. 19
      src/ImageSharp/Common/Helpers/Vector128Utilities.cs

4
src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs

@ -68,7 +68,7 @@ internal static partial class SimdUtils
{
if ((Vector512.IsHardwareAccelerated && Vector512_.SupportsShuffleNativeFloat) ||
(Vector256.IsHardwareAccelerated && Vector256_.SupportsShuffleNativeFloat) ||
(Vector128.IsHardwareAccelerated && Vector128_.SupportsShuffleNativeFloat))
Vector128.IsHardwareAccelerated)
{
int remainder = 0;
if (Vector512.IsHardwareAccelerated)
@ -305,7 +305,7 @@ internal static partial class SimdUtils
}
}
}
else if (Vector128.IsHardwareAccelerated && Vector128_.SupportsShuffleNativeFloat)
else if (Vector128.IsHardwareAccelerated)
{
ref Vector128<float> sourceBase = ref Unsafe.As<float, Vector128<float>>(ref MemoryMarshal.GetReference(source));
ref Vector128<float> destinationBase = ref Unsafe.As<float, Vector128<float>>(ref MemoryMarshal.GetReference(destination));

19
src/ImageSharp/Common/Helpers/Vector128Utilities.cs

@ -24,15 +24,6 @@ namespace SixLabors.ImageSharp.Common.Helpers;
internal static class Vector128_
#pragma warning restore SA1649 // File name should match first type name
{
/// <summary>
/// Gets a value indicating whether shuffle operations are supported.
/// </summary>
public static bool SupportsShuffleNativeFloat
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => Sse.IsSupported;
}
/// <summary>
/// Gets a value indicating whether shuffle operations are supported.
/// </summary>
@ -87,8 +78,14 @@ internal static class Vector128_
return Sse.Shuffle(vector, vector, control);
}
ThrowUnreachableException();
return default;
// Don't use InverseMMShuffle here as we want to avoid the cast.
Vector128<int> indices = Vector128.Create(
control & 0x3,
(control >> 2) & 0x3,
(control >> 4) & 0x3,
(control >> 6) & 0x3);
return Vector128.Shuffle(vector, indices);
}
/// <summary>

Loading…
Cancel
Save