Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1761,64 +1761,10 @@ private static Vector128<T> Unzip<T>(Vector128<T> left, Vector128<T> right, bool
/// <inheritdoc cref="Vector.Reverse{T}(Vector{T})" />
[Intrinsic]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector128<T> Reverse<T>(Vector128<T> vector)
{
if (typeof(T) == typeof(byte))
{
return Shuffle(vector.As<T, byte>(), CreateSequence((byte)(Vector128<byte>.Count - 1), byte.MaxValue)).As<byte, T>();
}
if (typeof(T) == typeof(double))
{
return Shuffle(vector.As<T, double>(), CreateSequence(Vector128<long>.Count - 1, -1L)).As<double, T>();
}
if (typeof(T) == typeof(short))
{
return Shuffle(vector.As<T, short>(), CreateSequence((short)(Vector128<short>.Count - 1), (short)-1)).As<short, T>();
}
if (typeof(T) == typeof(int))
{
return Shuffle(vector.As<T, int>(), CreateSequence(Vector128<int>.Count - 1, -1)).As<int, T>();
}
if (typeof(T) == typeof(long))
{
return Shuffle(vector.As<T, long>(), CreateSequence(Vector128<long>.Count - 1, -1L)).As<long, T>();
}
if (typeof(T) == typeof(nint))
{
return Unsafe.SizeOf<nint>() == sizeof(long)
? Shuffle(vector.As<T, long>(), CreateSequence(Vector128<long>.Count - 1, -1L)).As<long, T>()
: Shuffle(vector.As<T, int>(), CreateSequence(Vector128<int>.Count - 1, -1)).As<int, T>();
}
if (typeof(T) == typeof(sbyte))
{
return Shuffle(vector.As<T, sbyte>(), CreateSequence((sbyte)(Vector128<sbyte>.Count - 1), (sbyte)-1)).As<sbyte, T>();
}
if (typeof(T) == typeof(float))
{
return Shuffle(vector.As<T, float>(), CreateSequence(Vector128<int>.Count - 1, -1)).As<float, T>();
}
if (typeof(T) == typeof(ushort))
{
return Shuffle(vector.As<T, ushort>(), CreateSequence((ushort)(Vector128<ushort>.Count - 1), ushort.MaxValue)).As<ushort, T>();
}
if (typeof(T) == typeof(uint))
{
return Shuffle(vector.As<T, uint>(), CreateSequence((uint)(Vector128<uint>.Count - 1), uint.MaxValue)).As<uint, T>();
}
if (typeof(T) == typeof(ulong))
{
return Shuffle(vector.As<T, ulong>(), CreateSequence((ulong)(Vector128<ulong>.Count - 1), ulong.MaxValue)).As<ulong, T>();
}
if (typeof(T) == typeof(nuint))
{
return Unsafe.SizeOf<nuint>() == sizeof(ulong)
? Shuffle(vector.As<T, ulong>(), CreateSequence((ulong)(Vector128<ulong>.Count - 1), ulong.MaxValue)).As<ulong, T>()
: Shuffle(vector.As<T, uint>(), CreateSequence((uint)(Vector128<uint>.Count - 1), uint.MaxValue)).As<uint, T>();
}

ThrowHelper.ThrowForUnsupportedIntrinsicsVector128BaseType<T>();
return default;
}
public static Vector128<T> Reverse<T>(Vector128<T> vector) => Create(
Vector64.Reverse(vector.GetUpper()),
Vector64.Reverse(vector.GetLower())
);

/// <inheritdoc cref="Vector64.DegreesToRadians(Vector64{double})" />
[Intrinsic]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1836,64 +1836,10 @@ public static (Vector256<T> Even, Vector256<T> Odd) Unzip<T>(Vector256<T> left,
/// <inheritdoc cref="Vector.Reverse{T}(Vector{T})" />
[Intrinsic]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector256<T> Reverse<T>(Vector256<T> vector)
{
if (typeof(T) == typeof(byte))
{
return Shuffle(vector.As<T, byte>(), CreateSequence((byte)(Vector256<byte>.Count - 1), byte.MaxValue)).As<byte, T>();
}
if (typeof(T) == typeof(double))
{
return Shuffle(vector.As<T, double>(), CreateSequence(Vector256<long>.Count - 1, -1L)).As<double, T>();
}
if (typeof(T) == typeof(short))
{
return Shuffle(vector.As<T, short>(), CreateSequence((short)(Vector256<short>.Count - 1), (short)-1)).As<short, T>();
}
if (typeof(T) == typeof(int))
{
return Shuffle(vector.As<T, int>(), CreateSequence(Vector256<int>.Count - 1, -1)).As<int, T>();
}
if (typeof(T) == typeof(long))
{
return Shuffle(vector.As<T, long>(), CreateSequence(Vector256<long>.Count - 1, -1L)).As<long, T>();
}
if (typeof(T) == typeof(nint))
{
return Unsafe.SizeOf<nint>() == sizeof(long)
? Shuffle(vector.As<T, long>(), CreateSequence(Vector256<long>.Count - 1, -1L)).As<long, T>()
: Shuffle(vector.As<T, int>(), CreateSequence(Vector256<int>.Count - 1, -1)).As<int, T>();
}
if (typeof(T) == typeof(sbyte))
{
return Shuffle(vector.As<T, sbyte>(), CreateSequence((sbyte)(Vector256<sbyte>.Count - 1), (sbyte)-1)).As<sbyte, T>();
}
if (typeof(T) == typeof(float))
{
return Shuffle(vector.As<T, float>(), CreateSequence(Vector256<int>.Count - 1, -1)).As<float, T>();
}
if (typeof(T) == typeof(ushort))
{
return Shuffle(vector.As<T, ushort>(), CreateSequence((ushort)(Vector256<ushort>.Count - 1), ushort.MaxValue)).As<ushort, T>();
}
if (typeof(T) == typeof(uint))
{
return Shuffle(vector.As<T, uint>(), CreateSequence((uint)(Vector256<uint>.Count - 1), uint.MaxValue)).As<uint, T>();
}
if (typeof(T) == typeof(ulong))
{
return Shuffle(vector.As<T, ulong>(), CreateSequence((ulong)(Vector256<ulong>.Count - 1), ulong.MaxValue)).As<ulong, T>();
}
if (typeof(T) == typeof(nuint))
{
return Unsafe.SizeOf<nuint>() == sizeof(ulong)
? Shuffle(vector.As<T, ulong>(), CreateSequence((ulong)(Vector256<ulong>.Count - 1), ulong.MaxValue)).As<ulong, T>()
: Shuffle(vector.As<T, uint>(), CreateSequence((uint)(Vector256<uint>.Count - 1), uint.MaxValue)).As<uint, T>();
}

ThrowHelper.ThrowForUnsupportedIntrinsicsVector256BaseType<T>();
return default;
}
public static Vector256<T> Reverse<T>(Vector256<T> vector) => Create(
Vector128.Reverse(vector.GetUpper()),
Vector128.Reverse(vector.GetLower())
);

/// <inheritdoc cref="Vector128.DegreesToRadians(Vector128{double})" />
[Intrinsic]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1896,64 +1896,10 @@ public static (Vector512<T> Even, Vector512<T> Odd) Unzip<T>(Vector512<T> left,
/// <inheritdoc cref="Vector.Reverse{T}(Vector{T})" />
[Intrinsic]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector512<T> Reverse<T>(Vector512<T> vector)
{
if (typeof(T) == typeof(byte))
{
return Shuffle(vector.As<T, byte>(), CreateSequence((byte)(Vector512<byte>.Count - 1), byte.MaxValue)).As<byte, T>();
}
if (typeof(T) == typeof(double))
{
return Shuffle(vector.As<T, double>(), CreateSequence(Vector512<long>.Count - 1, -1L)).As<double, T>();
}
if (typeof(T) == typeof(short))
{
return Shuffle(vector.As<T, short>(), CreateSequence((short)(Vector512<short>.Count - 1), (short)-1)).As<short, T>();
}
if (typeof(T) == typeof(int))
{
return Shuffle(vector.As<T, int>(), CreateSequence(Vector512<int>.Count - 1, -1)).As<int, T>();
}
if (typeof(T) == typeof(long))
{
return Shuffle(vector.As<T, long>(), CreateSequence(Vector512<long>.Count - 1, -1L)).As<long, T>();
}
if (typeof(T) == typeof(nint))
{
return Unsafe.SizeOf<nint>() == sizeof(long)
? Shuffle(vector.As<T, long>(), CreateSequence(Vector512<long>.Count - 1, -1L)).As<long, T>()
: Shuffle(vector.As<T, int>(), CreateSequence(Vector512<int>.Count - 1, -1)).As<int, T>();
}
if (typeof(T) == typeof(sbyte))
{
return Shuffle(vector.As<T, sbyte>(), CreateSequence((sbyte)(Vector512<sbyte>.Count - 1), (sbyte)-1)).As<sbyte, T>();
}
if (typeof(T) == typeof(float))
{
return Shuffle(vector.As<T, float>(), CreateSequence(Vector512<int>.Count - 1, -1)).As<float, T>();
}
if (typeof(T) == typeof(ushort))
{
return Shuffle(vector.As<T, ushort>(), CreateSequence((ushort)(Vector512<ushort>.Count - 1), ushort.MaxValue)).As<ushort, T>();
}
if (typeof(T) == typeof(uint))
{
return Shuffle(vector.As<T, uint>(), CreateSequence((uint)(Vector512<uint>.Count - 1), uint.MaxValue)).As<uint, T>();
}
if (typeof(T) == typeof(ulong))
{
return Shuffle(vector.As<T, ulong>(), CreateSequence((ulong)(Vector512<ulong>.Count - 1), ulong.MaxValue)).As<ulong, T>();
}
if (typeof(T) == typeof(nuint))
{
return Unsafe.SizeOf<nuint>() == sizeof(ulong)
? Shuffle(vector.As<T, ulong>(), CreateSequence((ulong)(Vector512<ulong>.Count - 1), ulong.MaxValue)).As<ulong, T>()
: Shuffle(vector.As<T, uint>(), CreateSequence((uint)(Vector512<uint>.Count - 1), uint.MaxValue)).As<uint, T>();
}

ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
return default;
}
public static Vector512<T> Reverse<T>(Vector512<T> vector) => Create(
Vector256.Reverse(vector._upper),
Vector256.Reverse(vector._lower)
);

/// <inheritdoc cref="Vector256.DegreesToRadians(Vector256{double})" />
[Intrinsic]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1662,61 +1662,14 @@ public static Vector64<T> UnzipOdd<T>(Vector64<T> left, Vector64<T> right)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector64<T> Reverse<T>(Vector64<T> vector)
{
if (typeof(T) == typeof(byte))
{
return Shuffle(vector.As<T, byte>(), CreateSequence((byte)(Vector64<byte>.Count - 1), byte.MaxValue)).As<byte, T>();
}
if (typeof(T) == typeof(double))
{
return vector;
}
if (typeof(T) == typeof(short))
{
return Shuffle(vector.As<T, short>(), CreateSequence((short)(Vector64<short>.Count - 1), (short)-1)).As<short, T>();
}
if (typeof(T) == typeof(int))
{
return Shuffle(vector.As<T, int>(), CreateSequence(Vector64<int>.Count - 1, -1)).As<int, T>();
}
if (typeof(T) == typeof(long))
{
return vector;
}
if (typeof(T) == typeof(nint))
{
return Unsafe.SizeOf<nint>() == sizeof(long)
? vector
: Shuffle(vector.As<T, int>(), CreateSequence(Vector64<int>.Count - 1, -1)).As<int, T>();
}
if (typeof(T) == typeof(sbyte))
{
return Shuffle(vector.As<T, sbyte>(), CreateSequence((sbyte)(Vector64<sbyte>.Count - 1), (sbyte)-1)).As<sbyte, T>();
}
if (typeof(T) == typeof(float))
{
return Shuffle(vector.As<T, float>(), CreateSequence(Vector64<int>.Count - 1, -1)).As<float, T>();
}
if (typeof(T) == typeof(ushort))
{
return Shuffle(vector.As<T, ushort>(), CreateSequence((ushort)(Vector64<ushort>.Count - 1), ushort.MaxValue)).As<ushort, T>();
}
if (typeof(T) == typeof(uint))
{
return Shuffle(vector.As<T, uint>(), CreateSequence((uint)(Vector64<uint>.Count - 1), uint.MaxValue)).As<uint, T>();
}
if (typeof(T) == typeof(ulong))
{
return vector;
}
if (typeof(T) == typeof(nuint))
Unsafe.SkipInit(out Vector64<T> result);

for (int index = 0; index < Vector64<T>.Count; index++)
{
return Unsafe.SizeOf<nuint>() == sizeof(ulong)
? vector
: Shuffle(vector.As<T, uint>(), CreateSequence((uint)(Vector64<uint>.Count - 1), uint.MaxValue)).As<uint, T>();
result.SetElementUnsafe(index, vector.GetElementUnsafe(Vector64<T>.Count - 1 - index));
}

ThrowHelper.ThrowForUnsupportedIntrinsicsVector64BaseType<T>();
return default;
return result;
}

internal static Vector64<T> DegreesToRadians<T>(Vector64<T> degrees)
Expand Down