From 77fa074b4674b7b9803954ccf471d4cd37e93fae Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 14 Dec 2017 22:08:23 -0800 Subject: Adding tests for the SSE compare eq, gt, ge, lt, le, ne, ord, and unord intrinsics Adding tests for the SSE compare gt, and gte intrinsics --- .../JIT/HardwareIntrinsics/X86/Sse/CompareEqual.cs | 94 ++++++++++++++++++++++ .../X86/Sse/CompareEqual_r.csproj | 34 ++++++++ .../X86/Sse/CompareEqual_ro.csproj | 34 ++++++++ .../X86/Sse/CompareGreaterThan.cs | 94 ++++++++++++++++++++++ .../X86/Sse/CompareGreaterThanOrEqual.cs | 94 ++++++++++++++++++++++ .../X86/Sse/CompareGreaterThanOrEqual_r.csproj | 34 ++++++++ .../X86/Sse/CompareGreaterThanOrEqual_ro.csproj | 34 ++++++++ .../X86/Sse/CompareGreaterThan_r.csproj | 34 ++++++++ .../X86/Sse/CompareGreaterThan_ro.csproj | 34 ++++++++ .../HardwareIntrinsics/X86/Sse/CompareLessThan.cs | 94 ++++++++++++++++++++++ .../X86/Sse/CompareLessThanOrEqual.cs | 94 ++++++++++++++++++++++ .../X86/Sse/CompareLessThanOrEqual_r.csproj | 34 ++++++++ .../X86/Sse/CompareLessThanOrEqual_ro.csproj | 34 ++++++++ .../X86/Sse/CompareLessThan_r.csproj | 34 ++++++++ .../X86/Sse/CompareLessThan_ro.csproj | 34 ++++++++ .../HardwareIntrinsics/X86/Sse/CompareNotEqual.cs | 94 ++++++++++++++++++++++ .../X86/Sse/CompareNotEqual_r.csproj | 34 ++++++++ .../X86/Sse/CompareNotEqual_ro.csproj | 34 ++++++++ .../X86/Sse/CompareNotGreaterThan.cs | 94 ++++++++++++++++++++++ .../X86/Sse/CompareNotGreaterThanOrEqual.cs | 94 ++++++++++++++++++++++ .../X86/Sse/CompareNotGreaterThanOrEqual_r.csproj | 34 ++++++++ .../X86/Sse/CompareNotGreaterThanOrEqual_ro.csproj | 34 ++++++++ .../X86/Sse/CompareNotGreaterThan_r.csproj | 34 ++++++++ .../X86/Sse/CompareNotGreaterThan_ro.csproj | 34 ++++++++ .../X86/Sse/CompareNotLessThan.cs | 94 ++++++++++++++++++++++ .../X86/Sse/CompareNotLessThanOrEqual.cs | 94 ++++++++++++++++++++++ .../X86/Sse/CompareNotLessThanOrEqual_r.csproj | 34 ++++++++ .../X86/Sse/CompareNotLessThanOrEqual_ro.csproj | 34 ++++++++ .../X86/Sse/CompareNotLessThan_r.csproj | 34 ++++++++ .../X86/Sse/CompareNotLessThan_ro.csproj | 34 ++++++++ .../HardwareIntrinsics/X86/Sse/CompareOrdered.cs | 94 ++++++++++++++++++++++ .../X86/Sse/CompareOrdered_r.csproj | 34 ++++++++ .../X86/Sse/CompareOrdered_ro.csproj | 34 ++++++++ .../HardwareIntrinsics/X86/Sse/CompareUnordered.cs | 94 ++++++++++++++++++++++ .../X86/Sse/CompareUnordered_r.csproj | 34 ++++++++ .../X86/Sse/CompareUnordered_ro.csproj | 34 ++++++++ 36 files changed, 1944 insertions(+) create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered_ro.csproj (limited to 'tests') diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual.cs new file mode 100644 index 0000000000..46a7789668 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { 1, -5, 100, 0 }, new float[4] { 22, -1, -50, 0 }, new float[4])) + { + + var vf1 = Unsafe.Read>(floatTable.inArray1Ptr); + var vf2 = Unsafe.Read>(floatTable.inArray2Ptr); + var vf3 = Sse.CompareEqual(vf1, vf2); + Unsafe.Write(floatTable.outArrayPtr, vf3); + + if (!floatTable.CheckResult((x, y, z) => BitConverter.SingleToInt32Bits(z) == ((x == y) ? -1 : 0))) + { + Console.WriteLine("SSE CompareEqual failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] inArray1; + public T[] inArray2; + public T[] outArray; + + public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); + public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle inHandle1; + GCHandle inHandle2; + GCHandle outHandle; + public TestTable(T[] a, T[] b, T[] c) + { + this.inArray1 = a; + this.inArray2 = b; + this.outArray = c; + + inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); + inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + for (int i = 0; i < inArray1.Length; i++) + { + if (!check(inArray1[i], inArray2[i], outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual_r.csproj new file mode 100644 index 0000000000..0261014260 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual_ro.csproj new file mode 100644 index 0000000000..aebb467439 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan.cs new file mode 100644 index 0000000000..d2ce38cd38 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { 1, -5, 100, 0 }, new float[4] { 22, -1, -50, 0 }, new float[4])) + { + + var vf1 = Unsafe.Read>(floatTable.inArray1Ptr); + var vf2 = Unsafe.Read>(floatTable.inArray2Ptr); + var vf3 = Sse.CompareGreaterThan(vf1, vf2); + Unsafe.Write(floatTable.outArrayPtr, vf3); + + if (!floatTable.CheckResult((x, y, z) => BitConverter.SingleToInt32Bits(z) == ((x > y) ? -1 : 0))) + { + Console.WriteLine("SSE CompareGreaterThan failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] inArray1; + public T[] inArray2; + public T[] outArray; + + public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); + public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle inHandle1; + GCHandle inHandle2; + GCHandle outHandle; + public TestTable(T[] a, T[] b, T[] c) + { + this.inArray1 = a; + this.inArray2 = b; + this.outArray = c; + + inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); + inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + for (int i = 0; i < inArray1.Length; i++) + { + if (!check(inArray1[i], inArray2[i], outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual.cs new file mode 100644 index 0000000000..daa4a2a572 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { 1, -5, 100, 0 }, new float[4] { 22, -1, -50, 0 }, new float[4])) + { + + var vf1 = Unsafe.Read>(floatTable.inArray1Ptr); + var vf2 = Unsafe.Read>(floatTable.inArray2Ptr); + var vf3 = Sse.CompareGreaterThanOrEqual(vf1, vf2); + Unsafe.Write(floatTable.outArrayPtr, vf3); + + if (!floatTable.CheckResult((x, y, z) => BitConverter.SingleToInt32Bits(z) == ((x >= y) ? -1 : 0))) + { + Console.WriteLine("SSE CompareGreaterThanOrEqual failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] inArray1; + public T[] inArray2; + public T[] outArray; + + public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); + public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle inHandle1; + GCHandle inHandle2; + GCHandle outHandle; + public TestTable(T[] a, T[] b, T[] c) + { + this.inArray1 = a; + this.inArray2 = b; + this.outArray = c; + + inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); + inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + for (int i = 0; i < inArray1.Length; i++) + { + if (!check(inArray1[i], inArray2[i], outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual_r.csproj new file mode 100644 index 0000000000..0742a6190f --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual_ro.csproj new file mode 100644 index 0000000000..790d50ee1b --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan_r.csproj new file mode 100644 index 0000000000..425e4e92f3 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan_ro.csproj new file mode 100644 index 0000000000..0fd6ed7426 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan.cs new file mode 100644 index 0000000000..2bcd468998 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { 1, -5, 100, 0 }, new float[4] { 22, -1, -50, 0 }, new float[4])) + { + + var vf1 = Unsafe.Read>(floatTable.inArray1Ptr); + var vf2 = Unsafe.Read>(floatTable.inArray2Ptr); + var vf3 = Sse.CompareLessThan(vf1, vf2); + Unsafe.Write(floatTable.outArrayPtr, vf3); + + if (!floatTable.CheckResult((x, y, z) => BitConverter.SingleToInt32Bits(z) == ((x < y) ? -1 : 0))) + { + Console.WriteLine("SSE CompareLessThan failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] inArray1; + public T[] inArray2; + public T[] outArray; + + public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); + public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle inHandle1; + GCHandle inHandle2; + GCHandle outHandle; + public TestTable(T[] a, T[] b, T[] c) + { + this.inArray1 = a; + this.inArray2 = b; + this.outArray = c; + + inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); + inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + for (int i = 0; i < inArray1.Length; i++) + { + if (!check(inArray1[i], inArray2[i], outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual.cs new file mode 100644 index 0000000000..942aa16018 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { 1, -5, 100, 0 }, new float[4] { 22, -1, -50, 0 }, new float[4])) + { + + var vf1 = Unsafe.Read>(floatTable.inArray1Ptr); + var vf2 = Unsafe.Read>(floatTable.inArray2Ptr); + var vf3 = Sse.CompareLessThanOrEqual(vf1, vf2); + Unsafe.Write(floatTable.outArrayPtr, vf3); + + if (!floatTable.CheckResult((x, y, z) => BitConverter.SingleToInt32Bits(z) == ((x <= y) ? -1 : 0))) + { + Console.WriteLine("SSE CompareLessThanOrEqual failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] inArray1; + public T[] inArray2; + public T[] outArray; + + public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); + public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle inHandle1; + GCHandle inHandle2; + GCHandle outHandle; + public TestTable(T[] a, T[] b, T[] c) + { + this.inArray1 = a; + this.inArray2 = b; + this.outArray = c; + + inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); + inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + for (int i = 0; i < inArray1.Length; i++) + { + if (!check(inArray1[i], inArray2[i], outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual_r.csproj new file mode 100644 index 0000000000..1d1169149f --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual_ro.csproj new file mode 100644 index 0000000000..f6e4c91165 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan_r.csproj new file mode 100644 index 0000000000..ab46b2be74 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan_ro.csproj new file mode 100644 index 0000000000..481f6e19de --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual.cs new file mode 100644 index 0000000000..58cba3946b --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { 1, -5, 100, 0 }, new float[4] { 22, -1, -50, 0 }, new float[4])) + { + + var vf1 = Unsafe.Read>(floatTable.inArray1Ptr); + var vf2 = Unsafe.Read>(floatTable.inArray2Ptr); + var vf3 = Sse.CompareNotEqual(vf1, vf2); + Unsafe.Write(floatTable.outArrayPtr, vf3); + + if (!floatTable.CheckResult((x, y, z) => BitConverter.SingleToInt32Bits(z) == ((x != y) ? -1 : 0))) + { + Console.WriteLine("SSE CompareNotEqual failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] inArray1; + public T[] inArray2; + public T[] outArray; + + public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); + public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle inHandle1; + GCHandle inHandle2; + GCHandle outHandle; + public TestTable(T[] a, T[] b, T[] c) + { + this.inArray1 = a; + this.inArray2 = b; + this.outArray = c; + + inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); + inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + for (int i = 0; i < inArray1.Length; i++) + { + if (!check(inArray1[i], inArray2[i], outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual_r.csproj new file mode 100644 index 0000000000..4a3e9fee33 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual_ro.csproj new file mode 100644 index 0000000000..95e82bf28e --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan.cs new file mode 100644 index 0000000000..6de6e06ac1 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { 1, -5, 100, 0 }, new float[4] { 22, -1, -50, 0 }, new float[4])) + { + + var vf1 = Unsafe.Read>(floatTable.inArray1Ptr); + var vf2 = Unsafe.Read>(floatTable.inArray2Ptr); + var vf3 = Sse.CompareNotGreaterThan(vf1, vf2); + Unsafe.Write(floatTable.outArrayPtr, vf3); + + if (!floatTable.CheckResult((x, y, z) => BitConverter.SingleToInt32Bits(z) == (!(x > y) ? -1 : 0))) + { + Console.WriteLine("SSE CompareNotGreaterThan failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] inArray1; + public T[] inArray2; + public T[] outArray; + + public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); + public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle inHandle1; + GCHandle inHandle2; + GCHandle outHandle; + public TestTable(T[] a, T[] b, T[] c) + { + this.inArray1 = a; + this.inArray2 = b; + this.outArray = c; + + inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); + inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + for (int i = 0; i < inArray1.Length; i++) + { + if (!check(inArray1[i], inArray2[i], outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual.cs new file mode 100644 index 0000000000..95fa95e3de --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { 1, -5, 100, 0 }, new float[4] { 22, -1, -50, 0 }, new float[4])) + { + + var vf1 = Unsafe.Read>(floatTable.inArray1Ptr); + var vf2 = Unsafe.Read>(floatTable.inArray2Ptr); + var vf3 = Sse.CompareNotGreaterThanOrEqual(vf1, vf2); + Unsafe.Write(floatTable.outArrayPtr, vf3); + + if (!floatTable.CheckResult((x, y, z) => BitConverter.SingleToInt32Bits(z) == (!(x >= y) ? -1 : 0))) + { + Console.WriteLine("SSE CompareNotGreaterThanOrEqual failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] inArray1; + public T[] inArray2; + public T[] outArray; + + public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); + public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle inHandle1; + GCHandle inHandle2; + GCHandle outHandle; + public TestTable(T[] a, T[] b, T[] c) + { + this.inArray1 = a; + this.inArray2 = b; + this.outArray = c; + + inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); + inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + for (int i = 0; i < inArray1.Length; i++) + { + if (!check(inArray1[i], inArray2[i], outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual_r.csproj new file mode 100644 index 0000000000..7e27cdc919 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual_ro.csproj new file mode 100644 index 0000000000..11ddcf067c --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan_r.csproj new file mode 100644 index 0000000000..e0ffef1cc4 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan_ro.csproj new file mode 100644 index 0000000000..4cdf11ae0f --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan.cs new file mode 100644 index 0000000000..b0168cddee --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { 1, -5, 100, 0 }, new float[4] { 22, -1, -50, 0 }, new float[4])) + { + + var vf1 = Unsafe.Read>(floatTable.inArray1Ptr); + var vf2 = Unsafe.Read>(floatTable.inArray2Ptr); + var vf3 = Sse.CompareNotLessThan(vf1, vf2); + Unsafe.Write(floatTable.outArrayPtr, vf3); + + if (!floatTable.CheckResult((x, y, z) => BitConverter.SingleToInt32Bits(z) == (!(x < y) ? -1 : 0))) + { + Console.WriteLine("SSE CompareNotLessThan failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] inArray1; + public T[] inArray2; + public T[] outArray; + + public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); + public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle inHandle1; + GCHandle inHandle2; + GCHandle outHandle; + public TestTable(T[] a, T[] b, T[] c) + { + this.inArray1 = a; + this.inArray2 = b; + this.outArray = c; + + inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); + inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + for (int i = 0; i < inArray1.Length; i++) + { + if (!check(inArray1[i], inArray2[i], outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual.cs new file mode 100644 index 0000000000..b0ea5aa14b --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { 1, -5, 100, 0 }, new float[4] { 22, -1, -50, 0 }, new float[4])) + { + + var vf1 = Unsafe.Read>(floatTable.inArray1Ptr); + var vf2 = Unsafe.Read>(floatTable.inArray2Ptr); + var vf3 = Sse.CompareNotLessThanOrEqual(vf1, vf2); + Unsafe.Write(floatTable.outArrayPtr, vf3); + + if (!floatTable.CheckResult((x, y, z) => BitConverter.SingleToInt32Bits(z) == (!(x <= y) ? -1 : 0))) + { + Console.WriteLine("SSE CompareNotLessThanOrEqual failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] inArray1; + public T[] inArray2; + public T[] outArray; + + public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); + public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle inHandle1; + GCHandle inHandle2; + GCHandle outHandle; + public TestTable(T[] a, T[] b, T[] c) + { + this.inArray1 = a; + this.inArray2 = b; + this.outArray = c; + + inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); + inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + for (int i = 0; i < inArray1.Length; i++) + { + if (!check(inArray1[i], inArray2[i], outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual_r.csproj new file mode 100644 index 0000000000..67ab4900a7 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual_ro.csproj new file mode 100644 index 0000000000..0876d2a86a --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan_r.csproj new file mode 100644 index 0000000000..c1ca05727e --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan_ro.csproj new file mode 100644 index 0000000000..242acae30b --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered.cs new file mode 100644 index 0000000000..e743d276c0 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { 1, -5, 100, float.NaN }, new float[4] { 22, -1, -50, 0 }, new float[4])) + { + + var vf1 = Unsafe.Read>(floatTable.inArray1Ptr); + var vf2 = Unsafe.Read>(floatTable.inArray2Ptr); + var vf3 = Sse.CompareOrdered(vf1, vf2); + Unsafe.Write(floatTable.outArrayPtr, vf3); + + if (!floatTable.CheckResult((x, y, z) => BitConverter.SingleToInt32Bits(z) == ((!float.IsNaN(x) && !float.IsNaN(y)) ? -1 : 0))) + { + Console.WriteLine("SSE CompareOrdered failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] inArray1; + public T[] inArray2; + public T[] outArray; + + public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); + public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle inHandle1; + GCHandle inHandle2; + GCHandle outHandle; + public TestTable(T[] a, T[] b, T[] c) + { + this.inArray1 = a; + this.inArray2 = b; + this.outArray = c; + + inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); + inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + for (int i = 0; i < inArray1.Length; i++) + { + if (!check(inArray1[i], inArray2[i], outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered_r.csproj new file mode 100644 index 0000000000..995f8764ba --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered_ro.csproj new file mode 100644 index 0000000000..60239f78e3 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered.cs new file mode 100644 index 0000000000..5e7b55e6ca --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { 1, -5, 100, float.NaN }, new float[4] { 22, -1, -50, 0 }, new float[4])) + { + + var vf1 = Unsafe.Read>(floatTable.inArray1Ptr); + var vf2 = Unsafe.Read>(floatTable.inArray2Ptr); + var vf3 = Sse.CompareUnordered(vf1, vf2); + Unsafe.Write(floatTable.outArrayPtr, vf3); + + if (!floatTable.CheckResult((x, y, z) => BitConverter.SingleToInt32Bits(z) == ((float.IsNaN(x) || float.IsNaN(y)) ? -1 : 0))) + { + Console.WriteLine("SSE CompareUnordered failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] inArray1; + public T[] inArray2; + public T[] outArray; + + public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); + public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle inHandle1; + GCHandle inHandle2; + GCHandle outHandle; + public TestTable(T[] a, T[] b, T[] c) + { + this.inArray1 = a; + this.inArray2 = b; + this.outArray = c; + + inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); + inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + for (int i = 0; i < inArray1.Length; i++) + { + if (!check(inArray1[i], inArray2[i], outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered_r.csproj new file mode 100644 index 0000000000..884539f055 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered_ro.csproj new file mode 100644 index 0000000000..ef17dacfdc --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + -- cgit v1.2.3