From 4037f16b0e4c825765c381ac650d705fc92764b0 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Fri, 15 Dec 2017 20:04:06 -0500 Subject: [PATCH] [Arm64] Add Simd HWIntrinsic test --- tests/src/JIT/HardwareIntrinsics/Arm64/Simd.cs | 2217 ++++++++++++++++++++ tests/src/JIT/HardwareIntrinsics/Arm64/Simd.csproj | 36 + 2 files changed, 2253 insertions(+) create mode 100644 tests/src/JIT/HardwareIntrinsics/Arm64/Simd.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/Arm64/Simd.csproj diff --git a/tests/src/JIT/HardwareIntrinsics/Arm64/Simd.cs b/tests/src/JIT/HardwareIntrinsics/Arm64/Simd.cs new file mode 100644 index 0000000..20f8eb2 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/Arm64/Simd.cs @@ -0,0 +1,2217 @@ +using System; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE +using System.Runtime.Intrinsics.Arm.Arm64; +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + +namespace Arm64intrisicsTest +{ + struct DataSet + where TBaseType : struct + where TVectorType : new() + { + private static TVectorType _vectorX; + private static TVectorType _vectorY; + + public static TVectorType vectorX { get { return _vectorX; }} + public static TVectorType vectorY { get { return _vectorY; }} + + public static TBaseType[] arrayX { get; private set; } + public static TBaseType[] arrayY { get; private set; } + + public static unsafe void setData(TBaseType[] x, TBaseType[] y) + { + arrayX = x; + arrayY = y; + + GCHandle handleSrc = GCHandle.Alloc(x, GCHandleType.Pinned); + + try + { + var ptrSrc = (byte*) handleSrc.AddrOfPinnedObject().ToPointer(); + + _vectorX = Unsafe.Read(ptrSrc); + } + finally + { + handleSrc.Free(); + } + + + handleSrc = GCHandle.Alloc(y, GCHandleType.Pinned); + + try + { + var ptrSrc = (byte*) handleSrc.AddrOfPinnedObject().ToPointer(); + + _vectorY = Unsafe.Read(ptrSrc); + } + finally + { + handleSrc.Free(); + } + } + }; + + class Program + { + static unsafe TBaseType[] writeVector(TVectorType src) + where TBaseType : struct + where TVectorType : new() + { + var length = Unsafe.SizeOf() / Unsafe.SizeOf(); + var dst = new TBaseType[length]; + + GCHandle handleSrc = GCHandle.Alloc(src, GCHandleType.Pinned); + GCHandle handleDst = GCHandle.Alloc(dst, GCHandleType.Pinned); + + try + { + var ptrSrc = (byte*) handleSrc.AddrOfPinnedObject().ToPointer(); + var ptrDst = (byte*) handleDst.AddrOfPinnedObject().ToPointer(); + + for (int i = 0; i < Unsafe.SizeOf(); ++i) + { + ptrDst[i] = ptrSrc[i]; + } + } + finally + { + handleSrc.Free(); + handleDst.Free(); + } + + return dst; + } + + static void testBinOp(String testCaseDescription, + Func binOp, + Func check) + where TBaseType : struct, IComparable + where TVectorType : new() + { + testBinOp(testCaseDescription, binOp, check); + } + + static void testBinOp(String testCaseDescription, + Func binOp, + Func check) + where TBaseType : struct, IComparable + where TVectorType : new() + where TBaseReturnType : struct, IComparable + where TVectorReturnType : new() + { + bool failed = false; + try + { + var vLeft = DataSet.vectorX; + var vRight = DataSet.vectorY; + + var vResult = binOp(vLeft, vRight); + + var result = writeVector(vResult); + + var left = DataSet.arrayX; + var right = DataSet.arrayY; + + for (int i = 0; i < result.Length; i++) + { + var expected = check(left[i], right[i]); + + if (result[i].CompareTo(expected) != 0) + { + if(!failed) + { + Console.WriteLine($"testBinOp<{typeof(TBaseType).Name}, {typeof(TVectorType).Name} >{testCaseDescription}: Check Failed"); + } + Console.WriteLine($"check({left[i]}, {right[i]}) : result[{i}] = {result[i]}, expected {expected}"); + failed = true; + } + } + } + catch + { + Console.WriteLine($"testBinOp<{typeof(TBaseType).Name}, {typeof(TVectorType).Name} >{testCaseDescription}: Unexpected exception"); + throw; + } + + if (failed) + { + throw new Exception($"testBinOp<{typeof(TBaseType).Name}, {typeof(TVectorType).Name} >{testCaseDescription}: Failed"); + } + } + + static void testExtractOp(String testCaseDescription, + Func extractOp, + Func check) + where TBaseType : struct, IComparable + where TVectorType : new() + { + bool failed = false; + try + { + var vLeft = DataSet.vectorX; + + var vResult = extractOp(vLeft); + + var left = DataSet.arrayX; + + var expected = check(left); + + if (vResult.CompareTo(expected) != 0) + { + if(!failed) + { + Console.WriteLine($"testExtractOp<{typeof(TBaseType).Name}, {typeof(TVectorType).Name} >{testCaseDescription}: Check Failed"); + } + Console.WriteLine($"check(left) : vResult = {vResult}, expected {expected}"); + failed = true; + } + } + catch + { + Console.WriteLine($"testBinOp<{typeof(TBaseType).Name}, {typeof(TVectorType).Name} >{testCaseDescription}: Unexpected exception"); + throw; + } + + if (failed) + { + throw new Exception($"testBinOp<{typeof(TBaseType).Name}, {typeof(TVectorType).Name} >{testCaseDescription}: Failed"); + } + } + + static void testThrowsArgumentOutOfRangeException(String testCaseDescription, + Func binOp) + where TBaseType : struct + where TVectorType : struct + { + var v = DataSet.vectorX; + + bool caughtArgRangeEx = false; + + try + { + binOp(v,v); + } + catch (ArgumentOutOfRangeException) + { + caughtArgRangeEx = true; + } + catch + { + Console.WriteLine($"testThrowsArgumentOutOfRangeException: Unexpected exception"); + throw; + } + + if (caughtArgRangeEx == false) + { + throw new Exception($"testThrowsArgumentOutOfRangeException<{typeof(TBaseType).Name}, {typeof(TVectorType).Name} >{testCaseDescription}: Failed"); + } + } + + static void testThrowsTypeNotSupported(String testCaseDescription, + Func binOp) + where TVectorType : new() + { + TVectorType v = new TVectorType(); + + bool notSupported = false; + + try + { + binOp(v,v); + } + catch (NotSupportedException e) + { + notSupported = true; + } + catch + { + Console.WriteLine($"testThrowsTypeNotSupported: Unexpected exception"); + throw; + } + + if (notSupported == false) + { + throw new Exception($"testThrowsTypeNotSupported<{typeof(TVectorType).Name} >{testCaseDescription}: Failed"); + } + } + + static void testThrowsPlatformNotSupported(String testCaseDescription, + Func binOp) + where TVectorType : new() + { + testThrowsPlatformNotSupported(testCaseDescription, binOp); + } + + static void testThrowsPlatformNotSupported(String testCaseDescription, + Func binOp) + where TVectorType : new() + { + TVectorType v = new TVectorType(); + + bool notSupported = false; + + try + { + binOp(v,v); + } + catch (PlatformNotSupportedException) + { + notSupported = true; + } + catch + { + Console.WriteLine($"testThrowsPlatformNotSupported: Unexpected exception"); + throw; + } + + if (notSupported == false) + { + throw new Exception($"testThrowsPlatformNotSupported<{typeof(TVectorType).Name} >{testCaseDescription}: Failed"); + } + } + + static uint bits(float x) + { + return BitConverter.ToUInt32(BitConverter.GetBytes(x)); + } + + static ulong bits(double x) + { + return BitConverter.ToUInt64(BitConverter.GetBytes(x)); + } + + static float bitsToFloat(uint x) + { + return BitConverter.ToSingle(BitConverter.GetBytes(x)); + } + + static double bitsToDouble(ulong x) + { + return BitConverter.ToDouble(BitConverter.GetBytes(x)); + } + + static ulong bitsToUint64(T x) + { + return Unsafe.As(ref x) & ~(~0UL << 8*Unsafe.SizeOf()); + } + + static T boolTo(bool x) + where T : IConvertible + { + ulong result = x ? ~0UL : 0UL; + + if (typeof(T) == typeof(double)) return (T) Convert.ChangeType( bitsToDouble(result), typeof(T)); + if (typeof(T) == typeof(float)) return (T) Convert.ChangeType(bitsToFloat((uint)result), typeof(T)); + if (typeof(T) == typeof(byte) ) return (T) Convert.ChangeType( (byte) result, typeof(T)); + if (typeof(T) == typeof(sbyte) ) return (T) Convert.ChangeType( (sbyte) result, typeof(T)); + if (typeof(T) == typeof(ushort)) return (T) Convert.ChangeType( (ushort)result, typeof(T)); + if (typeof(T) == typeof(short) ) return (T) Convert.ChangeType( (short) result, typeof(T)); + if (typeof(T) == typeof(uint) ) return (T) Convert.ChangeType( (uint) result, typeof(T)); + if (typeof(T) == typeof(int) ) return (T) Convert.ChangeType( (int) result, typeof(T)); + if (typeof(T) == typeof(ulong) ) return (T) Convert.ChangeType( (ulong) result, typeof(T)); + if (typeof(T) == typeof(long) ) return (T) Convert.ChangeType( (long) result, typeof(T)); + + throw new Exception("Unexpected Type"); + } + + static T popCount(T x) + where T : IConvertible + { + ulong result = 0; + ulong value = bitsToUint64(x); + + while(value != 0) + { + result++; + value = value & (value - 1); + } + + return (T) Convert.ChangeType(result, typeof(T)); + + throw new Exception("Unexpected Type"); + } + + static T leadingZero(T x) + where T : IConvertible + { + ulong compare = 0x1UL << (8*Unsafe.SizeOf() - 1); + ulong result = 0; + ulong value = bitsToUint64(x); + + while(value < compare) + { + result++; + compare >>= 1; + } + + return (T) Convert.ChangeType(result, typeof(T)); + + throw new Exception("Unexpected Type"); + } + + static T leadingSign(T x) + where T : IConvertible + { + ulong value = bitsToUint64(x); + ulong signBit = value & (0x1UL << (8*Unsafe.SizeOf() - 1)); + ulong result = 0; + + if (signBit == 0) + { + result = (ulong) Convert.ChangeType(leadingZero(x), typeof(ulong)); + } + else + { + result = (ulong) Convert.ChangeType(leadingZero((T) Convert.ChangeType(value ^ (signBit + (signBit - 1)), typeof(T))), typeof(ulong)); + } + + return (T) Convert.ChangeType(result - 1, typeof(T)); + } + + static void TestAbs() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "Abs"; + + if (Simd.IsSupported) + { + testBinOp , float, Vector128>(name, (x, y) => Simd.Abs(x), (x, y) => Math.Abs(x)); + testBinOp, double, Vector128>(name, (x, y) => Simd.Abs(x), (x, y) => Math.Abs(x)); + testBinOp , byte, Vector128>(name, (x, y) => Simd.Abs(x), (x, y) => (byte) Math.Abs(x)); + testBinOp , ushort, Vector128>(name, (x, y) => Simd.Abs(x), (x, y) => (ushort) Math.Abs(x)); + testBinOp , uint, Vector128>(name, (x, y) => Simd.Abs(x), (x, y) => (uint) Math.Abs(x)); + testBinOp , ulong, Vector128>(name, (x, y) => Simd.Abs(x), (x, y) => (ulong) Math.Abs(x)); + testBinOp , float, Vector64< float >>(name, (x, y) => Simd.Abs(x), (x, y) => Math.Abs(x)); + testBinOp , byte, Vector64< byte >>(name, (x, y) => Simd.Abs(x), (x, y) => (byte) Math.Abs(x)); + testBinOp , ushort, Vector64< ushort>>(name, (x, y) => Simd.Abs(x), (x, y) => (ushort) Math.Abs(x)); + testBinOp , uint, Vector64< uint >>(name, (x, y) => Simd.Abs(x), (x, y) => (uint) Math.Abs(x)); + } + else + { + testThrowsPlatformNotSupported , Vector64< float >>(name, (x, y) => Simd.Abs(x)); + testThrowsPlatformNotSupported , Vector64< byte >>(name, (x, y) => Simd.Abs(x)); + testThrowsPlatformNotSupported , Vector64< ushort>>(name, (x, y) => Simd.Abs(x)); + testThrowsPlatformNotSupported , Vector64< uint >>(name, (x, y) => Simd.Abs(x)); + testThrowsPlatformNotSupported , Vector128>(name, (x, y) => Simd.Abs(x)); + testThrowsPlatformNotSupported, Vector128>(name, (x, y) => Simd.Abs(x)); + testThrowsPlatformNotSupported , Vector128>(name, (x, y) => Simd.Abs(x)); + testThrowsPlatformNotSupported , Vector128>(name, (x, y) => Simd.Abs(x)); + testThrowsPlatformNotSupported , Vector128>(name, (x, y) => Simd.Abs(x)); + testThrowsPlatformNotSupported , Vector128>(name, (x, y) => Simd.Abs(x)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestAdd() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "Add"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (sbyte) (x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (byte) (x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (short) (x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (ushort)(x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (sbyte) (x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (byte) (x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (short) (x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (ushort)(x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (x + y)); + testBinOp>(name, (x, y) => Simd.Add(x, y), (x, y) => (x + y)); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.Add(x, y)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.Add(x, y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Add(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestAnd() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "And"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => bitsToFloat (bits(x) & bits(y))); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => bitsToDouble(bits(x) & bits(y))); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => (sbyte) ( x & y )); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => (byte) ( x & y )); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => (short) ( x & y )); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => (ushort) ( x & y )); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => ( x & y )); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => ( x & y )); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => ( x & y )); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => ( x & y )); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => bitsToFloat (bits(x) & bits(y))); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => (sbyte) ( x & y )); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => (byte) ( x & y )); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => (short) ( x & y )); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => (ushort) ( x & y )); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => ( x & y )); + testBinOp>(name, (x, y) => Simd.And(x, y), (x, y) => ( x & y )); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.And(x, y)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.And(x, y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.And(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestAndNot() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "AndNot"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => bitsToFloat (bits(x) & ~bits(y))); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => bitsToDouble(bits(x) & ~bits(y))); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => (sbyte) ( x & ~ y )); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => (byte) ( x & ~ y )); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => (short) ( x & ~ y )); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => (ushort) ( x & ~ y )); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => ( x & ~ y )); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => ( x & ~ y )); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => ( x & ~ y )); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => ( x & ~ y )); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => bitsToFloat (bits(x) & ~bits(y))); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => (sbyte) ( x & ~ y )); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => (byte) ( x & ~ y )); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => (short) ( x & ~ y )); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => (ushort) ( x & ~ y )); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => ( x & ~ y )); + testBinOp>(name, (x, y) => Simd.AndNot(x, y), (x, y) => ( x & ~ y )); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.AndNot(x, y)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.AndNot(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestBitwiseSelect() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "BitwiseSelect"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => bitsToFloat (bits(y) ^ (bits(x + y) & (bits(x) ^ bits(y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => bitsToDouble(bits(y) ^ (bits(x + y) & (bits(x) ^ bits(y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => (sbyte) ( (y) ^ ( (x + y) & ( (x) ^ (y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => (byte) ( (y) ^ ( (x + y) & ( (x) ^ (y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => (short) ( (y) ^ ( (x + y) & ( (x) ^ (y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => (ushort) ( (y) ^ ( (x + y) & ( (x) ^ (y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => ( (y) ^ ( (x + y) & ( (x) ^ (y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => ( (y) ^ ( (x + y) & ( (x) ^ (y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => ( (y) ^ ( (x + y) & ( (x) ^ (y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => ( (y) ^ ( (x + y) & ( (x) ^ (y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => bitsToFloat (bits(y) ^ (bits(x + y) & (bits(x) ^ bits(y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => (sbyte) ( (y) ^ ( (x + y) & ( (x) ^ (y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => (byte) ( (y) ^ ( (x + y) & ( (x) ^ (y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => (short) ( (y) ^ ( (x + y) & ( (x) ^ (y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => (ushort) ( (y) ^ ( (x + y) & ( (x) ^ (y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => ( (y) ^ ( (x + y) & ( (x) ^ (y))))); + testBinOp>(name, (x, y) => Simd.BitwiseSelect(Simd.Add(x,y), x, y), (x, y) => ( (y) ^ ( (x + y) & ( (x) ^ (y))))); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.BitwiseSelect(x, x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestCompareEqual() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "CompareEqual"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + testBinOp>(name, (x, y) => Simd.CompareEqual(x, y), (x, y) => boolTo(x == y)); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.CompareEqual(x, y)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqual(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestCompareEqualZero() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "CompareEqualZero"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + testBinOp>(name, (x, y) => Simd.CompareEqualZero(x), (x, y) => boolTo(x == 0)); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.CompareEqualZero(x)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareEqualZero(x)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestCompareGreaterThan() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "CompareGreaterThan"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThan(x, y), (x, y) => boolTo(x > y)); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThan(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestCompareGreaterThanZero() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "CompareGreaterThanZero"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanZero(x), (x, y) => boolTo(x > 0)); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanZero(x)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestCompareGreaterThanOrEqual() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "CompareGreaterThanOrEqual"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y), (x, y) => boolTo(x >= y)); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqual(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestCompareGreaterThanOrEqualZero() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "CompareGreaterThanOrEqualZero"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + testBinOp>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x), (x, y) => boolTo(x >= 0)); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareGreaterThanOrEqualZero(x)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestCompareLessThanZero() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "CompareLessThanZero"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanZero(x), (x, y) => boolTo(x < 0)); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.CompareLessThanZero(x)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanZero(x)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestCompareLessThanOrEqualZero() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "CompareLessThanOrEqualZero"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + testBinOp>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x), (x, y) => boolTo(x <= 0)); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareLessThanOrEqualZero(x)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestCompareTest() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "CompareTest"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo((bits(x) & bits(y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo((bits(x) & bits(y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo(( (x) & (y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo(( (x) & (y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo(( (x) & (y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo(( (x) & (y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo(( (x) & (y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo(( (x) & (y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo(( (x) & (y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo(( (x) & (y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo((bits(x) & bits(y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo(( (x) & (y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo(( (x) & (y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo(( (x) & (y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo(( (x) & (y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo(( (x) & (y)) != 0)); + testBinOp>(name, (x, y) => Simd.CompareTest(x, y), (x, y) => boolTo(( (x) & (y)) != 0)); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.CompareTest(x, y)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.CompareTest(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestDivide() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "Divide"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.Divide(x, y), (x, y) => (x / y)); + testBinOp>(name, (x, y) => Simd.Divide(x, y), (x, y) => (x / y)); + testBinOp>(name, (x, y) => Simd.Divide(x, y), (x, y) => (x / y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Divide(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Divide(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Divide(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + [MethodImplAttribute(MethodImplOptions.NoInlining)] + static T simdExtract(Vector64 vector, byte index) + where T : struct + { + return Simd.Extract(vector, index); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + static T simdExtract(Vector128 vector, byte index) + where T : struct + { + return Simd.Extract(vector, index); + } +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + + static void TestExtract() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "Extract"; + + if (Simd.IsSupported) + { + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => Simd.Extract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => Simd.Extract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => Simd.Extract(x, 4), (x) => x[ 4]); + testExtractOp>(name, (x) => Simd.Extract(x, 5), (x) => x[ 5]); + testExtractOp>(name, (x) => Simd.Extract(x, 6), (x) => x[ 6]); + testExtractOp>(name, (x) => Simd.Extract(x, 7), (x) => x[ 7]); + testExtractOp>(name, (x) => Simd.Extract(x, 8), (x) => x[ 8]); + testExtractOp>(name, (x) => Simd.Extract(x, 9), (x) => x[ 9]); + testExtractOp>(name, (x) => Simd.Extract(x,10), (x) => x[10]); + testExtractOp>(name, (x) => Simd.Extract(x,11), (x) => x[11]); + testExtractOp>(name, (x) => Simd.Extract(x,12), (x) => x[12]); + testExtractOp>(name, (x) => Simd.Extract(x,13), (x) => x[13]); + testExtractOp>(name, (x) => Simd.Extract(x,14), (x) => x[14]); + testExtractOp>(name, (x) => Simd.Extract(x,15), (x) => x[15]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => Simd.Extract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => Simd.Extract(x, 4), (x) => x[ 4]); + testExtractOp>(name, (x) => Simd.Extract(x, 5), (x) => x[ 5]); + testExtractOp>(name, (x) => Simd.Extract(x, 6), (x) => x[ 6]); + testExtractOp>(name, (x) => Simd.Extract(x, 7), (x) => x[ 7]); + testExtractOp>(name, (x) => Simd.Extract(x, 8), (x) => x[ 8]); + testExtractOp>(name, (x) => Simd.Extract(x, 9), (x) => x[ 9]); + testExtractOp>(name, (x) => Simd.Extract(x,10), (x) => x[10]); + testExtractOp>(name, (x) => Simd.Extract(x,11), (x) => x[11]); + testExtractOp>(name, (x) => Simd.Extract(x,12), (x) => x[12]); + testExtractOp>(name, (x) => Simd.Extract(x,13), (x) => x[13]); + testExtractOp>(name, (x) => Simd.Extract(x,14), (x) => x[14]); + testExtractOp>(name, (x) => Simd.Extract(x,15), (x) => x[15]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => Simd.Extract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => Simd.Extract(x, 4), (x) => x[ 4]); + testExtractOp>(name, (x) => Simd.Extract(x, 5), (x) => x[ 5]); + testExtractOp>(name, (x) => Simd.Extract(x, 6), (x) => x[ 6]); + testExtractOp>(name, (x) => Simd.Extract(x, 7), (x) => x[ 7]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => Simd.Extract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => Simd.Extract(x, 4), (x) => x[ 4]); + testExtractOp>(name, (x) => Simd.Extract(x, 5), (x) => x[ 5]); + testExtractOp>(name, (x) => Simd.Extract(x, 6), (x) => x[ 6]); + testExtractOp>(name, (x) => Simd.Extract(x, 7), (x) => x[ 7]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => Simd.Extract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => Simd.Extract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => Simd.Extract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => Simd.Extract(x, 4), (x) => x[ 4]); + testExtractOp>(name, (x) => Simd.Extract(x, 5), (x) => x[ 5]); + testExtractOp>(name, (x) => Simd.Extract(x, 6), (x) => x[ 6]); + testExtractOp>(name, (x) => Simd.Extract(x, 7), (x) => x[ 7]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => Simd.Extract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => Simd.Extract(x, 4), (x) => x[ 4]); + testExtractOp>(name, (x) => Simd.Extract(x, 5), (x) => x[ 5]); + testExtractOp>(name, (x) => Simd.Extract(x, 6), (x) => x[ 6]); + testExtractOp>(name, (x) => Simd.Extract(x, 7), (x) => x[ 7]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => Simd.Extract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => Simd.Extract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => Simd.Extract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => Simd.Extract(x, 1), (x) => x[ 1]); + + // Test non-constant call + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => simdExtract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => simdExtract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => simdExtract(x, 4), (x) => x[ 4]); + testExtractOp>(name, (x) => simdExtract(x, 5), (x) => x[ 5]); + testExtractOp>(name, (x) => simdExtract(x, 6), (x) => x[ 6]); + testExtractOp>(name, (x) => simdExtract(x, 7), (x) => x[ 7]); + testExtractOp>(name, (x) => simdExtract(x, 8), (x) => x[ 8]); + testExtractOp>(name, (x) => simdExtract(x, 9), (x) => x[ 9]); + testExtractOp>(name, (x) => simdExtract(x,10), (x) => x[10]); + testExtractOp>(name, (x) => simdExtract(x,11), (x) => x[11]); + testExtractOp>(name, (x) => simdExtract(x,12), (x) => x[12]); + testExtractOp>(name, (x) => simdExtract(x,13), (x) => x[13]); + testExtractOp>(name, (x) => simdExtract(x,14), (x) => x[14]); + testExtractOp>(name, (x) => simdExtract(x,15), (x) => x[15]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => simdExtract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => simdExtract(x, 4), (x) => x[ 4]); + testExtractOp>(name, (x) => simdExtract(x, 5), (x) => x[ 5]); + testExtractOp>(name, (x) => simdExtract(x, 6), (x) => x[ 6]); + testExtractOp>(name, (x) => simdExtract(x, 7), (x) => x[ 7]); + testExtractOp>(name, (x) => simdExtract(x, 8), (x) => x[ 8]); + testExtractOp>(name, (x) => simdExtract(x, 9), (x) => x[ 9]); + testExtractOp>(name, (x) => simdExtract(x,10), (x) => x[10]); + testExtractOp>(name, (x) => simdExtract(x,11), (x) => x[11]); + testExtractOp>(name, (x) => simdExtract(x,12), (x) => x[12]); + testExtractOp>(name, (x) => simdExtract(x,13), (x) => x[13]); + testExtractOp>(name, (x) => simdExtract(x,14), (x) => x[14]); + testExtractOp>(name, (x) => simdExtract(x,15), (x) => x[15]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => simdExtract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => simdExtract(x, 4), (x) => x[ 4]); + testExtractOp>(name, (x) => simdExtract(x, 5), (x) => x[ 5]); + testExtractOp>(name, (x) => simdExtract(x, 6), (x) => x[ 6]); + testExtractOp>(name, (x) => simdExtract(x, 7), (x) => x[ 7]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => simdExtract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => simdExtract(x, 4), (x) => x[ 4]); + testExtractOp>(name, (x) => simdExtract(x, 5), (x) => x[ 5]); + testExtractOp>(name, (x) => simdExtract(x, 6), (x) => x[ 6]); + testExtractOp>(name, (x) => simdExtract(x, 7), (x) => x[ 7]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => simdExtract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => simdExtract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => simdExtract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => simdExtract(x, 4), (x) => x[ 4]); + testExtractOp>(name, (x) => simdExtract(x, 5), (x) => x[ 5]); + testExtractOp>(name, (x) => simdExtract(x, 6), (x) => x[ 6]); + testExtractOp>(name, (x) => simdExtract(x, 7), (x) => x[ 7]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => simdExtract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => simdExtract(x, 4), (x) => x[ 4]); + testExtractOp>(name, (x) => simdExtract(x, 5), (x) => x[ 5]); + testExtractOp>(name, (x) => simdExtract(x, 6), (x) => x[ 6]); + testExtractOp>(name, (x) => simdExtract(x, 7), (x) => x[ 7]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => simdExtract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 2), (x) => x[ 2]); + testExtractOp>(name, (x) => simdExtract(x, 3), (x) => x[ 3]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + testExtractOp>(name, (x) => simdExtract(x, 0), (x) => x[ 0]); + testExtractOp>(name, (x) => simdExtract(x, 1), (x) => x[ 1]); + + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 4)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 2)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x,16)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x,16)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 8)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 8)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 4)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 4)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 2)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 2)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 2)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 8)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 8)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 4)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 4)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 2)); + testThrowsArgumentOutOfRangeException>(name, (x, y) => Simd.Extract(x, 2)); + + testThrowsTypeNotSupported>(name, (x, y) => { return Simd.Extract(x, 1) > 1 ? x : y; }); + testThrowsTypeNotSupported>(name, (x, y) => { return Simd.Extract(x, 1) > 1 ? x : y; }); + testThrowsTypeNotSupported>(name, (x, y) => { return Simd.Extract(x, 1) > 1 ? x : y; }); + } + else + { + testThrowsPlatformNotSupported , float >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , double>(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , sbyte >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , byte >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , short >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , ushort>(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , int >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , uint >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , long >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , ulong >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , float >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported, double>(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , sbyte >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , byte >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , short >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported, ushort>(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , int >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , uint >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , long >(name, (x, y) => Simd.Extract(x, 1)); + testThrowsPlatformNotSupported , ulong >(name, (x, y) => Simd.Extract(x, 1)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestLeadingSignCount() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "LeadingSignCount"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.LeadingSignCount(x), (x, y) => leadingSign(x)); + testBinOp>(name, (x, y) => Simd.LeadingSignCount(x), (x, y) => leadingSign(x)); + testBinOp>(name, (x, y) => Simd.LeadingSignCount(x), (x, y) => leadingSign(x)); + testBinOp>(name, (x, y) => Simd.LeadingSignCount(x), (x, y) => leadingSign(x)); + testBinOp>(name, (x, y) => Simd.LeadingSignCount(x), (x, y) => leadingSign(x)); + testBinOp>(name, (x, y) => Simd.LeadingSignCount(x), (x, y) => leadingSign(x)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingSignCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingSignCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingSignCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingSignCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingSignCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingSignCount(x)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestLeadingZeroCount() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "LeadingZeroCount"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.LeadingZeroCount(x), (x, y) => leadingZero(x)); + testBinOp>(name, (x, y) => Simd.LeadingZeroCount(x), (x, y) => leadingZero(x)); + testBinOp>(name, (x, y) => Simd.LeadingZeroCount(x), (x, y) => leadingZero(x)); + testBinOp>(name, (x, y) => Simd.LeadingZeroCount(x), (x, y) => leadingZero(x)); + testBinOp>(name, (x, y) => Simd.LeadingZeroCount(x), (x, y) => leadingZero(x)); + testBinOp>(name, (x, y) => Simd.LeadingZeroCount(x), (x, y) => leadingZero(x)); + testBinOp>(name, (x, y) => Simd.LeadingZeroCount(x), (x, y) => leadingZero(x)); + testBinOp>(name, (x, y) => Simd.LeadingZeroCount(x), (x, y) => leadingZero(x)); + testBinOp>(name, (x, y) => Simd.LeadingZeroCount(x), (x, y) => leadingZero(x)); + testBinOp>(name, (x, y) => Simd.LeadingZeroCount(x), (x, y) => leadingZero(x)); + testBinOp>(name, (x, y) => Simd.LeadingZeroCount(x), (x, y) => leadingZero(x)); + testBinOp>(name, (x, y) => Simd.LeadingZeroCount(x), (x, y) => leadingZero(x)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingZeroCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingZeroCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingZeroCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingZeroCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingZeroCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingZeroCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingZeroCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingZeroCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingZeroCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingZeroCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingZeroCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.LeadingZeroCount(x)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestMax() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "Max"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => ((x > y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => ((x > y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => (sbyte) ((x > y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => (byte) ((x > y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => (short) ((x > y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => (ushort)((x > y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => ((x > y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => ((x > y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => ((x > y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => (sbyte) ((x > y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => (byte) ((x > y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => (short) ((x > y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => (ushort)((x > y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => ((x > y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Max(x, y), (x, y) => ((x > y) ? x : y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Max(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestMin() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "Min"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => ((x < y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => ((x < y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => (sbyte) ((x < y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => (byte) ((x < y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => (short) ((x < y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => (ushort)((x < y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => ((x < y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => ((x < y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => ((x < y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => (sbyte) ((x < y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => (byte) ((x < y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => (short) ((x < y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => (ushort)((x < y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => ((x < y) ? x : y)); + testBinOp>(name, (x, y) => Simd.Min(x, y), (x, y) => ((x < y) ? x : y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Min(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestMultiply() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "Multiply"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (x * y)); + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (x * y)); + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (sbyte) (x * y)); + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (byte) (x * y)); + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (short) (x * y)); + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (ushort)(x * y)); + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (x * y)); + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (x * y)); + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (x * y)); + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (sbyte) (x * y)); + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (byte) (x * y)); + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (short) (x * y)); + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (ushort)(x * y)); + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (x * y)); + testBinOp>(name, (x, y) => Simd.Multiply(x, y), (x, y) => (x * y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Multiply(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestNegate() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "Negate"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.Negate(x), (x, y) => (-x)); + testBinOp>(name, (x, y) => Simd.Negate(x), (x, y) => (-x)); + testBinOp>(name, (x, y) => Simd.Negate(x), (x, y) => (sbyte) (-x)); + testBinOp>(name, (x, y) => Simd.Negate(x), (x, y) => (short) (-x)); + testBinOp>(name, (x, y) => Simd.Negate(x), (x, y) => (-x)); + testBinOp>(name, (x, y) => Simd.Negate(x), (x, y) => (-x)); + testBinOp>(name, (x, y) => Simd.Negate(x), (x, y) => (-x)); + testBinOp>(name, (x, y) => Simd.Negate(x), (x, y) => (sbyte) (-x)); + testBinOp>(name, (x, y) => Simd.Negate(x), (x, y) => (short) (-x)); + testBinOp>(name, (x, y) => Simd.Negate(x), (x, y) => (-x)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Negate(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Negate(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Negate(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Negate(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Negate(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Negate(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Negate(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Negate(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Negate(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Negate(x)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestNot() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "Not"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => bitsToFloat (~bits(x))); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => bitsToDouble(~bits(x))); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => (sbyte) (~ x )); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => (byte) (~ x )); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => (short) (~ x )); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => (ushort) (~ x )); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => (~ x )); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => (~ x )); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => (~ x )); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => (~ x )); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => bitsToFloat (~bits(x))); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => (sbyte) (~ x )); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => (byte) (~ x )); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => (short) (~ x )); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => (ushort) (~ x )); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => (~ x )); + testBinOp>(name, (x, y) => Simd.Not(x), (x, y) => (~ x )); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.Not(x)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.Not(x)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Not(x)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestOr() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "Or"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => bitsToFloat (bits(x) | bits(y))); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => bitsToDouble(bits(x) | bits(y))); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => (sbyte) ( x | y )); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => (byte) ( x | y )); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => (short) ( x | y )); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => (ushort) ( x | y )); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => ( x | y )); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => ( x | y )); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => ( x | y )); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => ( x | y )); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => bitsToFloat (bits(x) | bits(y))); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => (sbyte) ( x | y )); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => (byte) ( x | y )); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => (short) ( x | y )); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => (ushort) ( x | y )); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => ( x | y )); + testBinOp>(name, (x, y) => Simd.Or(x, y), (x, y) => ( x | y )); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.Or(x, y)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.Or(x, y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Or(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestOrNot() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "OrNot"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => bitsToFloat (bits(x) | ~bits(y))); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => bitsToDouble(bits(x) | ~bits(y))); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => (sbyte) ( x | ~ y )); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => (byte) ( x | ~ y )); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => (short) ( x | ~ y )); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => (ushort) ( x | ~ y )); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => ( x | ~ y )); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => ( x | ~ y )); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => ( x | ~ y )); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => ( x | ~ y )); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => bitsToFloat (bits(x) | ~bits(y))); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => (sbyte) ( x | ~ y )); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => (byte) ( x | ~ y )); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => (short) ( x | ~ y )); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => (ushort) ( x | ~ y )); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => ( x | ~ y )); + testBinOp>(name, (x, y) => Simd.OrNot(x, y), (x, y) => ( x | ~ y )); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.OrNot(x, y)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.OrNot(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestPopCount() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "PopCount"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.PopCount(x), (x, y) => popCount(x)); + testBinOp>(name, (x, y) => Simd.PopCount(x), (x, y) => popCount(x)); + testBinOp>(name, (x, y) => Simd.PopCount(x), (x, y) => popCount(x)); + testBinOp>(name, (x, y) => Simd.PopCount(x), (x, y) => popCount(x)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.PopCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.PopCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.PopCount(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.PopCount(x)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestSetAllVector() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "SetAllVector"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.SetAllVector128((float )4), (x, y) => (float )4); + testBinOp>(name, (x, y) => Simd.SetAllVector128((double)4), (x, y) => (double)4); + testBinOp>(name, (x, y) => Simd.SetAllVector128((sbyte )4), (x, y) => (sbyte )4); + testBinOp>(name, (x, y) => Simd.SetAllVector128((byte )4), (x, y) => (byte )4); + testBinOp>(name, (x, y) => Simd.SetAllVector128((short )4), (x, y) => (short )4); + testBinOp>(name, (x, y) => Simd.SetAllVector128((ushort)4), (x, y) => (ushort)4); + testBinOp>(name, (x, y) => Simd.SetAllVector128((int )4), (x, y) => (int )4); + testBinOp>(name, (x, y) => Simd.SetAllVector128((uint )4), (x, y) => (uint )4); + testBinOp>(name, (x, y) => Simd.SetAllVector128((long )4), (x, y) => (long )4); + testBinOp>(name, (x, y) => Simd.SetAllVector128((ulong )4), (x, y) => (ulong )4); + testBinOp>(name, (x, y) => Simd.SetAllVector64( (float )4), (x, y) => (float )4); + testBinOp>(name, (x, y) => Simd.SetAllVector64( (sbyte )4), (x, y) => (sbyte )4); + testBinOp>(name, (x, y) => Simd.SetAllVector64( (byte )4), (x, y) => (byte )4); + testBinOp>(name, (x, y) => Simd.SetAllVector64( (short )4), (x, y) => (short )4); + testBinOp>(name, (x, y) => Simd.SetAllVector64( (ushort)4), (x, y) => (ushort)4); + testBinOp>(name, (x, y) => Simd.SetAllVector64( (int )4), (x, y) => (int )4); + testBinOp>(name, (x, y) => Simd.SetAllVector64( (uint )4), (x, y) => (uint )4); + + //testThrowsTypeNotSupported >>(name, (x, y) => Simd.SetAllVector128(Simd.SetAllVector128((long )5))); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.SetAllVector64((long )6)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.SetAllVector64((ulong )6)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.SetAllVector64((double)6)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector64((float )7)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector64((sbyte )7)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector64((byte )7)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector64((short )7)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector64((ushort)7)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector64((int )7)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector64((uint )7)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector64((long )7)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector64((ulong )7)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector64((double)7)); + + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector128((float )8)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector128((double)8)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector128((sbyte )8)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector128((byte )8)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector128((short )8)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector128((ushort)8)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector128((int )8)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector128((uint )8)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector128((long )8)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.SetAllVector128((ulong )8)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestSqrt() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "Sqrt"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.Sqrt(x), (x, y) => ((float) Math.Sqrt(x))); + testBinOp>(name, (x, y) => Simd.Sqrt(x), (x, y) => ( Math.Sqrt(x))); + testBinOp>(name, (x, y) => Simd.Sqrt(x), (x, y) => ((float) Math.Sqrt(x))); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Sqrt(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Sqrt(x)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Sqrt(x)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestSubtract() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "Subtract"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (sbyte) (x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (byte) (x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (short) (x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (ushort)(x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (sbyte) (x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (byte) (x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (short) (x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (ushort)(x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (x - y)); + testBinOp>(name, (x, y) => Simd.Subtract(x, y), (x, y) => (x - y)); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.Subtract(x, y)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Subtract(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void TestXor() + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + String name = "Xor"; + + if (Simd.IsSupported) + { + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => bitsToFloat (bits(x) ^ bits(y))); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => bitsToDouble(bits(x) ^ bits(y))); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => (sbyte) ( x ^ y )); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => (byte) ( x ^ y )); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => (short) ( x ^ y )); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => (ushort) ( x ^ y )); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => ( x ^ y )); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => ( x ^ y )); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => ( x ^ y )); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => ( x ^ y )); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => bitsToFloat (bits(x) ^ bits(y))); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => (sbyte) ( x ^ y )); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => (byte) ( x ^ y )); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => (short) ( x ^ y )); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => (ushort) ( x ^ y )); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => ( x ^ y )); + testBinOp>(name, (x, y) => Simd.Xor(x, y), (x, y) => ( x ^ y )); + + testThrowsTypeNotSupported >>(name, (x, y) => Simd.Xor(x, y)); + + testThrowsTypeNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsTypeNotSupported>(name, (x, y) => Simd.Xor(x, y)); + } + else + { + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + testThrowsPlatformNotSupported>(name, (x, y) => Simd.Xor(x, y)); + } + + Console.WriteLine($"Test{name} passed"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + } + + static void initializeDataSetDefault() + { + DataSet>.setData(new float[] { 1, -5 }, new float[] { 22, -1 }); + DataSet>.setData(new sbyte[] { 1, -5, 100, 0, 7, 8, -2, -9 }, new sbyte[] { 22, -1, -50, 0, 7, 5, 3, -33 }); + DataSet>.setData(new byte[] { 1, 5, 100, 0, 7, 8, 2, 9 }, new byte[] { 22, 1, 50, 0, 7, 5, 3, 33 }); + DataSet>.setData(new short[] { 1, -5, 100, 0 }, new short[] { 22, -1, -50, 0 }); + DataSet>.setData(new ushort[] { 1, 5, 100, 0 }, new ushort[]{ 22, 1, 50, 0 }); + DataSet>.setData(new int[] { 1, -5 }, new int[] { 22, -1 }); + DataSet>.setData(new uint[] { 1, 5 }, new uint[] { 22, 1 }); + DataSet>.setData(new float[] { 1, -5, 100, 0 }, new float[] { 22, -1, -50, 0 }); + DataSet>.setData(new double[] { 1, -5 }, new double[]{ 22, -1 }); + DataSet>.setData(new sbyte[] { 1, -5, 100, 0, 7, 8, -2, -9, 1, -5, 100, 0, 7, 8, -2, -9 }, new sbyte[] { 22, -1, -50, 0, 7, 5, 3, -33, -17, 4, 100, 120, 27, 6, -2, -6 }); + DataSet>.setData(new byte[] { 1, 5, 100, 0, 7, 8, 2, 9, 1, 5, 100, 0, 7, 8, 2, 9 }, new byte[] { 22, 1, 50, 0, 7, 5, 3, 33, 17, 4, 100, 120, 27, 6, 2, 6 }); + DataSet>.setData(new short[] { 1, -5, 100, 0, 7, 8, -2, -9 }, new short[] { 22, -1, -50, 0, 7, 5, 3, -33 }); + DataSet>.setData(new ushort[] { 1, 5, 100, 0, 7, 8, 2, 9 }, new ushort[]{ 22, 1, 50, 0, 7, 5, 3, 33 }); + DataSet>.setData(new int[] { 1, -5, 100, 0 }, new int[] { 22, -1, -50, 0 }); + DataSet>.setData(new uint[] { 1, 5, 100, 0 }, new uint[] { 22, 1, 50, 0 }); + DataSet>.setData(new long[] { 1, -5 }, new long[] { 22, -1 }); + DataSet>.setData(new ulong[] { 1, 5 }, new ulong[] { 22, 1 }); + + Console.WriteLine("Using default data set"); + } + + static void initializeDataSetCompare() + { + DataSet>.setData(new float[] { 1, 0 }, new float[] { 1, 17 }); + DataSet>.setData(new sbyte[] { 1, 0, 100, 0, 7, 8, -2, -9 }, new sbyte[] { 1, 17, -50, 0, 7, 5, 3, -33 }); + DataSet>.setData(new byte[] { 1, 0, 100, 0, 7, 8, 2, 9 }, new byte[] { 1, 17, 50, 0, 7, 5, 3, 33 }); + DataSet>.setData(new short[] { 1, 0, 100, 0 }, new short[] { 1, 17, -50, 0 }); + DataSet>.setData(new ushort[] { 1, 0, 100, 0 }, new ushort[]{ 1, 17, 50, 0 }); + DataSet>.setData(new int[] { 1, 0 }, new int[] { 1, 17 }); + DataSet>.setData(new uint[] { 1, 0 }, new uint[] { 1, 17 }); + DataSet>.setData(new float[] { 1, 0, 100, 0 }, new float[] { 1, 17, -50, 0 }); + DataSet>.setData(new double[] { 1, 0 }, new double[]{ 1, 17 }); + DataSet>.setData(new sbyte[] { 1, 0, 100, 0, 7, 8, -2, -9, 1, -5, 100, 0, 7, 8, -2, -9 }, new sbyte[] { 1, 17, -50, 0, 7, 5, 3, -33, -17, 4, 100, 120, 27, 6, -2, -6 }); + DataSet>.setData(new byte[] { 1, 0, 100, 0, 7, 8, 2, 9, 1, 5, 100, 0, 7, 8, 2, 9 }, new byte[] { 1, 17, 50, 0, 7, 5, 3, 33, 17, 4, 100, 120, 27, 6, 2, 6 }); + DataSet>.setData(new short[] { 1, 0, 100, 0, 7, 8, -2, -9 }, new short[] { 1, 17, -50, 0, 7, 5, 3, -33 }); + DataSet>.setData(new ushort[] { 1, 0, 100, 0, 7, 8, 2, 9 }, new ushort[]{ 1, 17, 50, 0, 7, 5, 3, 33 }); + DataSet>.setData(new int[] { 1, 0, 100, 0 }, new int[] { 1, 17, -50, 0 }); + DataSet>.setData(new uint[] { 1, 0, 100, 0 }, new uint[] { 1, 17, 50, 0 }); + DataSet>.setData(new long[] { 1, 0 }, new long[] { 1, 17 }); + DataSet>.setData(new ulong[] { 1, 0 }, new ulong[] { 1, 17 }); + + Console.WriteLine("Using compare data set"); + } + + static void ExecuteAllTests() + { + TestAbs(); + TestAdd(); + TestAnd(); + TestAndNot(); + TestBitwiseSelect(); + TestCompareEqual(); + TestCompareEqualZero(); + TestCompareGreaterThan(); + TestCompareGreaterThanZero(); + TestCompareGreaterThanOrEqual(); + TestCompareGreaterThanOrEqualZero(); + TestCompareLessThanZero(); + TestCompareLessThanOrEqualZero(); + TestCompareTest(); + TestDivide(); + TestExtract(); + //TestInsert(); + TestLeadingSignCount(); + TestLeadingZeroCount(); + TestMax(); + TestMin(); + TestMultiply(); + TestNegate(); + TestNot(); + TestOr(); + TestOrNot(); + TestPopCount(); + TestSetAllVector(); + TestSqrt(); + TestSubtract(); + TestXor(); + } + + static int Main(string[] args) + { +#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + Console.WriteLine($"System.Runtime.Intrinsics.Arm.Arm64.Simd.IsSupported = {Simd.IsSupported}"); + + // Reflection call + var issupported = "get_IsSupported"; + bool reflectedIsSupported = Convert.ToBoolean(typeof(Simd).GetMethod(issupported).Invoke(null, null)); + + Debug.Assert(reflectedIsSupported == Simd.IsSupported, "Reflection result does not match"); +#endif // ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE + + initializeDataSetDefault(); + + ExecuteAllTests(); + + initializeDataSetCompare(); + + ExecuteAllTests(); + + return 100; + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/Arm64/Simd.csproj b/tests/src/JIT/HardwareIntrinsics/Arm64/Simd.csproj new file mode 100644 index 0000000..3916866 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/Arm64/Simd.csproj @@ -0,0 +1,36 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + + + -- 2.7.4