summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFei Peng <fei.peng@intel.com>2018-12-04 12:09:53 -0800
committerFei Peng <fei.peng@intel.com>2018-12-04 12:09:53 -0800
commitddd6ddb6075e74d253146a99cf84fac77e18bb7e (patch)
treeb41c0dd883a3cfc2720029893d065f7041b0e035
parent86e6443684982ffd13f6cdfb4ead82f586063934 (diff)
downloadcoreclr-ddd6ddb6075e74d253146a99cf84fac77e18bb7e.tar.gz
coreclr-ddd6ddb6075e74d253146a99cf84fac77e18bb7e.tar.bz2
coreclr-ddd6ddb6075e74d253146a99cf84fac77e18bb7e.zip
Move more SSE2 intrinsic tests to template
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported.cs12
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx4
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarSimdUnOpTest.template2
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64.Int64.cs267
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64.cs95
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64_r.csproj36
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64_ro.csproj36
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128UInt64.UInt64.cs267
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128UInt64_r.csproj36
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128UInt64_ro.csproj36
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Program.Sse2.X64.cs2
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Sse2.X64_r.csproj3
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Sse2.X64_ro.csproj3
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32.Int32.cs267
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32.cs79
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32_r.csproj36
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32_ro.csproj36
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32.UInt32.cs267
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32.cs79
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32_r.csproj36
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32_ro.csproj36
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Program.Sse2.cs2
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_r.csproj2
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_ro.csproj2
24 files changed, 1098 insertions, 543 deletions
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported.cs b/tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported.cs
index 6bc3cba771..ec074ac77b 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported.cs
@@ -39,7 +39,17 @@ namespace IntelHardwareIntrinsicTest
Convert.ToBoolean(typeof(Avx).GetMethod(issupported).Invoke(null, null)) != Avx.IsSupported ||
Convert.ToBoolean(typeof(Avx2).GetMethod(issupported).Invoke(null, null)) != Avx2.IsSupported ||
Convert.ToBoolean(typeof(Lzcnt).GetMethod(issupported).Invoke(null, null)) != Lzcnt.IsSupported ||
- Convert.ToBoolean(typeof(Popcnt).GetMethod(issupported).Invoke(null, null)) != Popcnt.IsSupported
+ Convert.ToBoolean(typeof(Popcnt).GetMethod(issupported).Invoke(null, null)) != Popcnt.IsSupported ||
+ Convert.ToBoolean(typeof(Bmi1).GetMethod(issupported).Invoke(null, null)) != Bmi1.IsSupported ||
+ Convert.ToBoolean(typeof(Bmi2).GetMethod(issupported).Invoke(null, null)) != Bmi2.IsSupported ||
+ Convert.ToBoolean(typeof(Sse.X64).GetMethod(issupported).Invoke(null, null)) != Sse.X64.IsSupported ||
+ Convert.ToBoolean(typeof(Sse2.X64).GetMethod(issupported).Invoke(null, null)) != Sse2.X64.IsSupported ||
+ Convert.ToBoolean(typeof(Sse41.X64).GetMethod(issupported).Invoke(null, null)) != Sse41.X64.IsSupported ||
+ Convert.ToBoolean(typeof(Sse42.X64).GetMethod(issupported).Invoke(null, null)) != Sse42.X64.IsSupported ||
+ Convert.ToBoolean(typeof(Lzcnt.X64).GetMethod(issupported).Invoke(null, null)) != Lzcnt.X64.IsSupported ||
+ Convert.ToBoolean(typeof(Popcnt.X64).GetMethod(issupported).Invoke(null, null)) != Popcnt.X64.IsSupported ||
+ Convert.ToBoolean(typeof(Bmi1.X64).GetMethod(issupported).Invoke(null, null)) != Bmi1.X64.IsSupported ||
+ Convert.ToBoolean(typeof(Bmi2.X64).GetMethod(issupported).Invoke(null, null)) != Bmi2.X64.IsSupported
)
{
result = false;
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx b/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx
index f13b31e709..ea742f90b2 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx
@@ -182,6 +182,8 @@ private static readonly (string templateFileName, Dictionary<string, string> tem
("SimpleUnOpConvTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertToVector128Single", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits((float)firstOp[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((i < 2) ? BitConverter.SingleToInt32Bits((float)firstOp[i]) : 0)"}),
("SimpleUnOpConvTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertToVector128Single", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits((float)firstOp[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits((float)firstOp[i])"}),
("SimpleBinOpConvTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertScalarToVector128Double", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "(double)right != result[0]"}),
+ ("ScalarSimdUnOpTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertScalarToVector128Int32", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "firstOp != result[0]", ["ValidateRemainingResults"] = "false"}),
+ ("ScalarSimdUnOpTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertScalarToVector128UInt32", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "firstOp != result[0]", ["ValidateRemainingResults"] = "false"}),
("SimpleBinOpTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Divide", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
("SimpleBinOpTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "DivideScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
("ExtractScalarTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}),
@@ -324,6 +326,8 @@ private static readonly (string templateFileName, Dictionary<string, string> tem
("SimdScalarUnOpConvTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2.X64", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertToUInt64", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "firstOp[0] != result"}),
("SimdScalarUnOpConvTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2.X64", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertToInt64WithTruncation", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "(long)firstOp[0] != result"}),
("SimpleBinOpConvTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2.X64", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertScalarToVector128Double", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "(double)right != result[0]"}),
+ ("ScalarSimdUnOpTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2.X64", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertScalarToVector128Int64", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "firstOp != result[0]", ["ValidateRemainingResults"] = "false"}),
+ ("ScalarSimdUnOpTest.template", new Dictionary<string, string> { ["Isa"] = "Sse2.X64", ["LoadIsa"] = "Sse2", ["Method"] = "ConvertScalarToVector128UInt64", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "firstOp != result[0]", ["ValidateRemainingResults"] = "false"}),
};
private static readonly (string templateFileName, Dictionary<string, string> templateData)[] Sse3Inputs = new []
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarSimdUnOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarSimdUnOpTest.template
index f4abd04384..294befea67 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarSimdUnOpTest.template
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarSimdUnOpTest.template
@@ -255,7 +255,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!succeeded)
{
- TestLibrary.TestFramework.LogInformation($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1VectorType}<{Op1BaseType}>): {method} failed:");
+ TestLibrary.TestFramework.LogInformation($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1BaseType}): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64.Int64.cs
new file mode 100644
index 0000000000..5d6fd60fc4
--- /dev/null
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64.Int64.cs
@@ -0,0 +1,267 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file. *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+ public static partial class Program
+ {
+ private static void ConvertScalarToVector128Int64Int64()
+ {
+ var test = new ScalarSimdUnaryOpTest__ConvertScalarToVector128Int64Int64();
+
+ if (test.IsSupported)
+ {
+ // Validates basic functionality works
+ test.RunBasicScenario_UnsafeRead();
+
+ // Validates calling via reflection works
+ test.RunReflectionScenario_UnsafeRead();
+
+ // Validates passing a static member works
+ test.RunClsVarScenario();
+
+ // Validates passing a local works
+ test.RunLclVarScenario_UnsafeRead();
+
+ // Validates passing the field of a local class works
+ test.RunClassLclFldScenario();
+
+ // Validates passing an instance member of a class works
+ test.RunClassFldScenario();
+
+ // Validates passing the field of a local struct works
+ test.RunStructLclFldScenario();
+
+ // Validates passing an instance member of a struct works
+ test.RunStructFldScenario();
+ }
+ else
+ {
+ // Validates we throw on unsupported hardware
+ test.RunUnsupportedScenario();
+ }
+
+ if (!test.Succeeded)
+ {
+ throw new Exception("One or more scenarios did not complete as expected.");
+ }
+ }
+ }
+
+ public sealed unsafe class ScalarSimdUnaryOpTest__ConvertScalarToVector128Int64Int64
+ {
+ private struct TestStruct
+ {
+ public Int64 _fld;
+
+ public static TestStruct Create()
+ {
+ var testStruct = new TestStruct();
+
+ testStruct._fld = TestLibrary.Generator.GetInt64();
+ return testStruct;
+ }
+
+ public void RunStructFldScenario(ScalarSimdUnaryOpTest__ConvertScalarToVector128Int64Int64 testClass)
+ {
+ var result = Sse2.X64.ConvertScalarToVector128Int64(_fld);
+
+ Unsafe.Write(testClass._dataTable.outArrayPtr, result);
+ testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr);
+ }
+ }
+
+ private static readonly int LargestVectorSize = 16;
+
+ private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64);
+
+ private static Int64 _data;
+
+ private static Int64 _clsVar;
+
+ private Int64 _fld;
+
+ private ScalarSimdUnaryOpTest__DataTable<Int64> _dataTable;
+
+ static ScalarSimdUnaryOpTest__ConvertScalarToVector128Int64Int64()
+ {
+ _clsVar = TestLibrary.Generator.GetInt64();
+ }
+
+ public ScalarSimdUnaryOpTest__ConvertScalarToVector128Int64Int64()
+ {
+ Succeeded = true;
+
+ _fld = TestLibrary.Generator.GetInt64();
+ _data = TestLibrary.Generator.GetInt64();
+ _dataTable = new ScalarSimdUnaryOpTest__DataTable<Int64>(new Int64[RetElementCount], LargestVectorSize);
+ }
+
+ public bool IsSupported => Sse2.X64.IsSupported;
+
+ public bool Succeeded { get; set; }
+
+ public void RunBasicScenario_UnsafeRead()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
+
+ var result = Sse2.X64.ConvertScalarToVector128Int64(
+ Unsafe.ReadUnaligned<Int64>(ref Unsafe.As<Int64, byte>(ref _data))
+ );
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(_data, _dataTable.outArrayPtr);
+ }
+
+ public void RunReflectionScenario_UnsafeRead()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
+
+ var result = typeof(Sse2.X64).GetMethod(nameof(Sse2.X64.ConvertScalarToVector128Int64), new Type[] { typeof(Int64) })
+ .Invoke(null, new object[] {
+ Unsafe.ReadUnaligned<Int64>(ref Unsafe.As<Int64, byte>(ref _data))
+ });
+
+ Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result));
+ ValidateResult(_data, _dataTable.outArrayPtr);
+ }
+
+ public void RunClsVarScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
+
+ var result = Sse2.X64.ConvertScalarToVector128Int64(
+ _clsVar
+ );
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(_clsVar, _dataTable.outArrayPtr);
+ }
+
+ public void RunLclVarScenario_UnsafeRead()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
+
+ var data = Unsafe.ReadUnaligned<Int64>(ref Unsafe.As<Int64, byte>(ref _data));
+ var result = Sse2.X64.ConvertScalarToVector128Int64(data);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(data, _dataTable.outArrayPtr);
+ }
+
+ public void RunClassLclFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
+
+ var test = new ScalarSimdUnaryOpTest__ConvertScalarToVector128Int64Int64();
+ var result = Sse2.X64.ConvertScalarToVector128Int64(test._fld);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(test._fld, _dataTable.outArrayPtr);
+ }
+
+ public void RunClassFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
+
+ var result = Sse2.X64.ConvertScalarToVector128Int64(_fld);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(_fld, _dataTable.outArrayPtr);
+ }
+
+ public void RunStructLclFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
+
+ var test = TestStruct.Create();
+ var result = Sse2.X64.ConvertScalarToVector128Int64(test._fld);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(test._fld, _dataTable.outArrayPtr);
+ }
+
+ public void RunStructFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
+
+ var test = TestStruct.Create();
+ test.RunStructFldScenario(this);
+ }
+
+ public void RunUnsupportedScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario));
+
+ bool succeeded = false;
+
+ try
+ {
+ RunBasicScenario_UnsafeRead();
+ }
+ catch (PlatformNotSupportedException)
+ {
+ succeeded = true;
+ }
+
+ if (!succeeded)
+ {
+ Succeeded = false;
+ }
+ }
+
+ private void ValidateResult(Int64 firstOp, void* result, [CallerMemberName] string method = "")
+ {
+ Int64[] outArray = new Int64[RetElementCount];
+
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>());
+
+ ValidateResult(firstOp, outArray, method);
+ }
+
+ private void ValidateResult(Int64 firstOp, Int64[] result, [CallerMemberName] string method = "")
+ {
+ bool succeeded = true;
+
+ if (firstOp != result[0])
+ {
+ succeeded = false;
+ }
+ else
+ {
+ for (var i = 1; i < RetElementCount; i++)
+ {
+ if (false)
+ {
+ succeeded = false;
+ break;
+ }
+ }
+ }
+
+ if (!succeeded)
+ {
+ TestLibrary.TestFramework.LogInformation($"{nameof(Sse2.X64)}.{nameof(Sse2.X64.ConvertScalarToVector128Int64)}<Int64>(Int64): {method} failed:");
+ TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
+ TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
+ TestLibrary.TestFramework.LogInformation(string.Empty);
+
+ Succeeded = false;
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64.cs
deleted file mode 100644
index 32d7bf1afb..0000000000
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-// 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;
-
- using (TestTable<long> longTable = new TestTable<long>(new long[2] { 1, -5 }, new long[2]))
- {
- if (Sse2.X64.IsSupported)
- {
- var vd = Sse2.X64.ConvertScalarToVector128Int64((long)-5);
- Unsafe.Write(longTable.outArrayPtr, vd);
-
- if (!longTable.CheckResult((x, y) => (y[0] == -5) && (y[1] == 0)))
- {
- Console.WriteLine("SSE2.X64 ConvertScalarToVector128Int32 failed on long:");
- foreach (var item in longTable.outArray)
- {
- Console.Write(item + ", ");
- }
- Console.WriteLine();
- testResult = Fail;
- }
- }
- else
- {
- try
- {
- var vd = Sse2.X64.ConvertScalarToVector128Int64(-5l);
- testResult = Fail;
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.X64.ConvertScalarToVector128Int64)} failed: expected PlatformNotSupportedException exception.");
- }
- catch (PlatformNotSupportedException)
- {
-
- }
- catch (Exception ex)
- {
- testResult = Fail;
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.X64.ConvertScalarToVector128Int64)}-{ex} failed: expected PlatformNotSupportedException exception.");
- }
- }
- }
-
- return testResult;
- }
-
- public unsafe struct TestTable<T> : IDisposable where T : struct
- {
- public T[] inArray;
- public T[] outArray;
-
- public void* inArrayPtr => inHandle.AddrOfPinnedObject().ToPointer();
- public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer();
-
- GCHandle inHandle;
- GCHandle outHandle;
- public TestTable(T[] a, T[] b)
- {
- this.inArray = a;
- this.outArray = b;
-
- inHandle = GCHandle.Alloc(inArray, GCHandleType.Pinned);
- outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned);
- }
- public bool CheckResult(Func<T[], T[], bool> check)
- {
- return check(inArray, outArray);
- }
-
- public void Dispose()
- {
- inHandle.Free();
- outHandle.Free();
- }
- }
-
- }
-}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64_r.csproj
deleted file mode 100644
index ec6993425a..0000000000
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64_r.csproj
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{B734C778-AAEE-4A98-970D-19C61FA245AC}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <PropertyGroup>
- <DebugType>Embedded</DebugType>
- <Optimize></Optimize>
- </PropertyGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ConvertScalarToVector128Int64.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64_ro.csproj
deleted file mode 100644
index 7f54535498..0000000000
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128Int64_ro.csproj
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{553F8403-75AB-4711-BDF8-C20F04B207CD}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <PropertyGroup>
- <DebugType>Embedded</DebugType>
- <Optimize>True</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ConvertScalarToVector128Int64.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128UInt64.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128UInt64.UInt64.cs
new file mode 100644
index 0000000000..df4c60fec7
--- /dev/null
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128UInt64.UInt64.cs
@@ -0,0 +1,267 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file. *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+ public static partial class Program
+ {
+ private static void ConvertScalarToVector128UInt64UInt64()
+ {
+ var test = new ScalarSimdUnaryOpTest__ConvertScalarToVector128UInt64UInt64();
+
+ if (test.IsSupported)
+ {
+ // Validates basic functionality works
+ test.RunBasicScenario_UnsafeRead();
+
+ // Validates calling via reflection works
+ test.RunReflectionScenario_UnsafeRead();
+
+ // Validates passing a static member works
+ test.RunClsVarScenario();
+
+ // Validates passing a local works
+ test.RunLclVarScenario_UnsafeRead();
+
+ // Validates passing the field of a local class works
+ test.RunClassLclFldScenario();
+
+ // Validates passing an instance member of a class works
+ test.RunClassFldScenario();
+
+ // Validates passing the field of a local struct works
+ test.RunStructLclFldScenario();
+
+ // Validates passing an instance member of a struct works
+ test.RunStructFldScenario();
+ }
+ else
+ {
+ // Validates we throw on unsupported hardware
+ test.RunUnsupportedScenario();
+ }
+
+ if (!test.Succeeded)
+ {
+ throw new Exception("One or more scenarios did not complete as expected.");
+ }
+ }
+ }
+
+ public sealed unsafe class ScalarSimdUnaryOpTest__ConvertScalarToVector128UInt64UInt64
+ {
+ private struct TestStruct
+ {
+ public UInt64 _fld;
+
+ public static TestStruct Create()
+ {
+ var testStruct = new TestStruct();
+
+ testStruct._fld = TestLibrary.Generator.GetUInt64();
+ return testStruct;
+ }
+
+ public void RunStructFldScenario(ScalarSimdUnaryOpTest__ConvertScalarToVector128UInt64UInt64 testClass)
+ {
+ var result = Sse2.X64.ConvertScalarToVector128UInt64(_fld);
+
+ Unsafe.Write(testClass._dataTable.outArrayPtr, result);
+ testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr);
+ }
+ }
+
+ private static readonly int LargestVectorSize = 16;
+
+ private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt64>>() / sizeof(UInt64);
+
+ private static UInt64 _data;
+
+ private static UInt64 _clsVar;
+
+ private UInt64 _fld;
+
+ private ScalarSimdUnaryOpTest__DataTable<UInt64> _dataTable;
+
+ static ScalarSimdUnaryOpTest__ConvertScalarToVector128UInt64UInt64()
+ {
+ _clsVar = TestLibrary.Generator.GetUInt64();
+ }
+
+ public ScalarSimdUnaryOpTest__ConvertScalarToVector128UInt64UInt64()
+ {
+ Succeeded = true;
+
+ _fld = TestLibrary.Generator.GetUInt64();
+ _data = TestLibrary.Generator.GetUInt64();
+ _dataTable = new ScalarSimdUnaryOpTest__DataTable<UInt64>(new UInt64[RetElementCount], LargestVectorSize);
+ }
+
+ public bool IsSupported => Sse2.X64.IsSupported;
+
+ public bool Succeeded { get; set; }
+
+ public void RunBasicScenario_UnsafeRead()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
+
+ var result = Sse2.X64.ConvertScalarToVector128UInt64(
+ Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data))
+ );
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(_data, _dataTable.outArrayPtr);
+ }
+
+ public void RunReflectionScenario_UnsafeRead()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
+
+ var result = typeof(Sse2.X64).GetMethod(nameof(Sse2.X64.ConvertScalarToVector128UInt64), new Type[] { typeof(UInt64) })
+ .Invoke(null, new object[] {
+ Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data))
+ });
+
+ Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt64>)(result));
+ ValidateResult(_data, _dataTable.outArrayPtr);
+ }
+
+ public void RunClsVarScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
+
+ var result = Sse2.X64.ConvertScalarToVector128UInt64(
+ _clsVar
+ );
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(_clsVar, _dataTable.outArrayPtr);
+ }
+
+ public void RunLclVarScenario_UnsafeRead()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
+
+ var data = Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data));
+ var result = Sse2.X64.ConvertScalarToVector128UInt64(data);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(data, _dataTable.outArrayPtr);
+ }
+
+ public void RunClassLclFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
+
+ var test = new ScalarSimdUnaryOpTest__ConvertScalarToVector128UInt64UInt64();
+ var result = Sse2.X64.ConvertScalarToVector128UInt64(test._fld);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(test._fld, _dataTable.outArrayPtr);
+ }
+
+ public void RunClassFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
+
+ var result = Sse2.X64.ConvertScalarToVector128UInt64(_fld);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(_fld, _dataTable.outArrayPtr);
+ }
+
+ public void RunStructLclFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
+
+ var test = TestStruct.Create();
+ var result = Sse2.X64.ConvertScalarToVector128UInt64(test._fld);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(test._fld, _dataTable.outArrayPtr);
+ }
+
+ public void RunStructFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
+
+ var test = TestStruct.Create();
+ test.RunStructFldScenario(this);
+ }
+
+ public void RunUnsupportedScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario));
+
+ bool succeeded = false;
+
+ try
+ {
+ RunBasicScenario_UnsafeRead();
+ }
+ catch (PlatformNotSupportedException)
+ {
+ succeeded = true;
+ }
+
+ if (!succeeded)
+ {
+ Succeeded = false;
+ }
+ }
+
+ private void ValidateResult(UInt64 firstOp, void* result, [CallerMemberName] string method = "")
+ {
+ UInt64[] outArray = new UInt64[RetElementCount];
+
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt64>>());
+
+ ValidateResult(firstOp, outArray, method);
+ }
+
+ private void ValidateResult(UInt64 firstOp, UInt64[] result, [CallerMemberName] string method = "")
+ {
+ bool succeeded = true;
+
+ if (firstOp != result[0])
+ {
+ succeeded = false;
+ }
+ else
+ {
+ for (var i = 1; i < RetElementCount; i++)
+ {
+ if (false)
+ {
+ succeeded = false;
+ break;
+ }
+ }
+ }
+
+ if (!succeeded)
+ {
+ TestLibrary.TestFramework.LogInformation($"{nameof(Sse2.X64)}.{nameof(Sse2.X64.ConvertScalarToVector128UInt64)}<UInt64>(UInt64): {method} failed:");
+ TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
+ TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
+ TestLibrary.TestFramework.LogInformation(string.Empty);
+
+ Succeeded = false;
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128UInt64_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128UInt64_r.csproj
deleted file mode 100644
index 4d9ff52056..0000000000
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128UInt64_r.csproj
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{037BE502-9140-47B9-B51F-F18717E32E17}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <PropertyGroup>
- <DebugType>Embedded</DebugType>
- <Optimize></Optimize>
- </PropertyGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ConvertScalarToVector128UInt64.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128UInt64_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128UInt64_ro.csproj
deleted file mode 100644
index 7228f5c9f2..0000000000
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/ConvertScalarToVector128UInt64_ro.csproj
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{11507378-A92B-4557-95A0-A0567822BDE7}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <PropertyGroup>
- <DebugType>Embedded</DebugType>
- <Optimize>True</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ConvertScalarToVector128UInt64.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Program.Sse2.X64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Program.Sse2.X64.cs
index dc0895797f..b6a9e5cd11 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Program.Sse2.X64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Program.Sse2.X64.cs
@@ -17,6 +17,8 @@ namespace JIT.HardwareIntrinsics.X86
["ConvertToUInt64.Vector128UInt64"] = ConvertToUInt64Vector128UInt64,
["ConvertToInt64WithTruncation.Vector128Double"] = ConvertToInt64WithTruncationVector128Double,
["ConvertScalarToVector128Double.Double"] = ConvertScalarToVector128DoubleDouble,
+ ["ConvertScalarToVector128Int64.Int64"] = ConvertScalarToVector128Int64Int64,
+ ["ConvertScalarToVector128UInt64.UInt64"] = ConvertScalarToVector128UInt64UInt64,
};
}
}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Sse2.X64_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Sse2.X64_r.csproj
index 3cdfdfa8ef..3f55cf97f5 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Sse2.X64_r.csproj
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Sse2.X64_r.csproj
@@ -32,8 +32,11 @@
<Compile Include="ConvertToUInt64.Vector128UInt64.cs" />
<Compile Include="ConvertToInt64WithTruncation.Vector128Double.cs" />
<Compile Include="ConvertScalarToVector128Double.Double.cs" />
+ <Compile Include="ConvertScalarToVector128Int64.Int64.cs" />
+ <Compile Include="ConvertScalarToVector128UInt64.UInt64.cs" />
<Compile Include="..\Shared\SimpleBinOpConvTest_DataTable.cs" />
<Compile Include="..\Shared\SimdScalarUnOpTest_DataTable.cs" />
+ <Compile Include="..\Shared\ScalarSimdUnOpTest_DataTable.cs" />
<Compile Include="..\Shared\Program.cs" />
<Compile Include="Program.Sse2.X64.cs" />
</ItemGroup>
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Sse2.X64_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Sse2.X64_ro.csproj
index 86d895688f..eef35f5838 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Sse2.X64_ro.csproj
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2.X64/Sse2.X64_ro.csproj
@@ -32,8 +32,11 @@
<Compile Include="ConvertToUInt64.Vector128UInt64.cs" />
<Compile Include="ConvertToInt64WithTruncation.Vector128Double.cs" />
<Compile Include="ConvertScalarToVector128Double.Double.cs" />
+ <Compile Include="ConvertScalarToVector128Int64.Int64.cs" />
+ <Compile Include="ConvertScalarToVector128UInt64.UInt64.cs" />
<Compile Include="..\Shared\SimpleBinOpConvTest_DataTable.cs" />
<Compile Include="..\Shared\SimdScalarUnOpTest_DataTable.cs" />
+ <Compile Include="..\Shared\ScalarSimdUnOpTest_DataTable.cs" />
<Compile Include="..\Shared\Program.cs" />
<Compile Include="Program.Sse2.X64.cs" />
</ItemGroup>
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32.Int32.cs
new file mode 100644
index 0000000000..ecd4f557a6
--- /dev/null
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32.Int32.cs
@@ -0,0 +1,267 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file. *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+ public static partial class Program
+ {
+ private static void ConvertScalarToVector128Int32Int32()
+ {
+ var test = new ScalarSimdUnaryOpTest__ConvertScalarToVector128Int32Int32();
+
+ if (test.IsSupported)
+ {
+ // Validates basic functionality works
+ test.RunBasicScenario_UnsafeRead();
+
+ // Validates calling via reflection works
+ test.RunReflectionScenario_UnsafeRead();
+
+ // Validates passing a static member works
+ test.RunClsVarScenario();
+
+ // Validates passing a local works
+ test.RunLclVarScenario_UnsafeRead();
+
+ // Validates passing the field of a local class works
+ test.RunClassLclFldScenario();
+
+ // Validates passing an instance member of a class works
+ test.RunClassFldScenario();
+
+ // Validates passing the field of a local struct works
+ test.RunStructLclFldScenario();
+
+ // Validates passing an instance member of a struct works
+ test.RunStructFldScenario();
+ }
+ else
+ {
+ // Validates we throw on unsupported hardware
+ test.RunUnsupportedScenario();
+ }
+
+ if (!test.Succeeded)
+ {
+ throw new Exception("One or more scenarios did not complete as expected.");
+ }
+ }
+ }
+
+ public sealed unsafe class ScalarSimdUnaryOpTest__ConvertScalarToVector128Int32Int32
+ {
+ private struct TestStruct
+ {
+ public Int32 _fld;
+
+ public static TestStruct Create()
+ {
+ var testStruct = new TestStruct();
+
+ testStruct._fld = TestLibrary.Generator.GetInt32();
+ return testStruct;
+ }
+
+ public void RunStructFldScenario(ScalarSimdUnaryOpTest__ConvertScalarToVector128Int32Int32 testClass)
+ {
+ var result = Sse2.ConvertScalarToVector128Int32(_fld);
+
+ Unsafe.Write(testClass._dataTable.outArrayPtr, result);
+ testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr);
+ }
+ }
+
+ private static readonly int LargestVectorSize = 16;
+
+ private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32);
+
+ private static Int32 _data;
+
+ private static Int32 _clsVar;
+
+ private Int32 _fld;
+
+ private ScalarSimdUnaryOpTest__DataTable<Int32> _dataTable;
+
+ static ScalarSimdUnaryOpTest__ConvertScalarToVector128Int32Int32()
+ {
+ _clsVar = TestLibrary.Generator.GetInt32();
+ }
+
+ public ScalarSimdUnaryOpTest__ConvertScalarToVector128Int32Int32()
+ {
+ Succeeded = true;
+
+ _fld = TestLibrary.Generator.GetInt32();
+ _data = TestLibrary.Generator.GetInt32();
+ _dataTable = new ScalarSimdUnaryOpTest__DataTable<Int32>(new Int32[RetElementCount], LargestVectorSize);
+ }
+
+ public bool IsSupported => Sse2.IsSupported;
+
+ public bool Succeeded { get; set; }
+
+ public void RunBasicScenario_UnsafeRead()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
+
+ var result = Sse2.ConvertScalarToVector128Int32(
+ Unsafe.ReadUnaligned<Int32>(ref Unsafe.As<Int32, byte>(ref _data))
+ );
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(_data, _dataTable.outArrayPtr);
+ }
+
+ public void RunReflectionScenario_UnsafeRead()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
+
+ var result = typeof(Sse2).GetMethod(nameof(Sse2.ConvertScalarToVector128Int32), new Type[] { typeof(Int32) })
+ .Invoke(null, new object[] {
+ Unsafe.ReadUnaligned<Int32>(ref Unsafe.As<Int32, byte>(ref _data))
+ });
+
+ Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result));
+ ValidateResult(_data, _dataTable.outArrayPtr);
+ }
+
+ public void RunClsVarScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
+
+ var result = Sse2.ConvertScalarToVector128Int32(
+ _clsVar
+ );
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(_clsVar, _dataTable.outArrayPtr);
+ }
+
+ public void RunLclVarScenario_UnsafeRead()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
+
+ var data = Unsafe.ReadUnaligned<Int32>(ref Unsafe.As<Int32, byte>(ref _data));
+ var result = Sse2.ConvertScalarToVector128Int32(data);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(data, _dataTable.outArrayPtr);
+ }
+
+ public void RunClassLclFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
+
+ var test = new ScalarSimdUnaryOpTest__ConvertScalarToVector128Int32Int32();
+ var result = Sse2.ConvertScalarToVector128Int32(test._fld);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(test._fld, _dataTable.outArrayPtr);
+ }
+
+ public void RunClassFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
+
+ var result = Sse2.ConvertScalarToVector128Int32(_fld);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(_fld, _dataTable.outArrayPtr);
+ }
+
+ public void RunStructLclFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
+
+ var test = TestStruct.Create();
+ var result = Sse2.ConvertScalarToVector128Int32(test._fld);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(test._fld, _dataTable.outArrayPtr);
+ }
+
+ public void RunStructFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
+
+ var test = TestStruct.Create();
+ test.RunStructFldScenario(this);
+ }
+
+ public void RunUnsupportedScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario));
+
+ bool succeeded = false;
+
+ try
+ {
+ RunBasicScenario_UnsafeRead();
+ }
+ catch (PlatformNotSupportedException)
+ {
+ succeeded = true;
+ }
+
+ if (!succeeded)
+ {
+ Succeeded = false;
+ }
+ }
+
+ private void ValidateResult(Int32 firstOp, void* result, [CallerMemberName] string method = "")
+ {
+ Int32[] outArray = new Int32[RetElementCount];
+
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>());
+
+ ValidateResult(firstOp, outArray, method);
+ }
+
+ private void ValidateResult(Int32 firstOp, Int32[] result, [CallerMemberName] string method = "")
+ {
+ bool succeeded = true;
+
+ if (firstOp != result[0])
+ {
+ succeeded = false;
+ }
+ else
+ {
+ for (var i = 1; i < RetElementCount; i++)
+ {
+ if (false)
+ {
+ succeeded = false;
+ break;
+ }
+ }
+ }
+
+ if (!succeeded)
+ {
+ TestLibrary.TestFramework.LogInformation($"{nameof(Sse2)}.{nameof(Sse2.ConvertScalarToVector128Int32)}<Int32>(Int32): {method} failed:");
+ TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
+ TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
+ TestLibrary.TestFramework.LogInformation(string.Empty);
+
+ Succeeded = false;
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32.cs
deleted file mode 100644
index cdfb2870f6..0000000000
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-// 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 (Sse2.IsSupported)
- {
- using (TestTable<int> intTable = new TestTable<int>(new int[4] { 1, -5, 7, 19 }, new int[4]))
- {
- var vf1 = Unsafe.Read<Vector128<int>>(intTable.inArrayPtr);
- var vf2 = Sse2.ConvertScalarToVector128Int32(5);
- Unsafe.Write(intTable.outArrayPtr, vf2);
-
- if (!intTable.CheckResult((x, y) => (y[0] == 5)
- && (y[1] == 0) && (y[2] == 0) && (y[3] == 0)))
- {
- Console.WriteLine("SSE2 ConvertScalarToVector128Int32 failed on int:");
- foreach (var item in intTable.outArray)
- {
- Console.Write(item + ", ");
- }
- Console.WriteLine();
- testResult = Fail;
- }
- }
- }
-
- return testResult;
- }
-
- public unsafe struct TestTable<T> : IDisposable where T : struct
- {
- public T[] inArray;
- public T[] outArray;
-
- public void* inArrayPtr => inHandle.AddrOfPinnedObject().ToPointer();
- public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer();
-
- GCHandle inHandle;
- GCHandle outHandle;
- public TestTable(T[] a, T[] b)
- {
- this.inArray = a;
- this.outArray = b;
-
- inHandle = GCHandle.Alloc(inArray, GCHandleType.Pinned);
- outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned);
- }
- public bool CheckResult(Func<T[], T[], bool> check)
- {
- return check(inArray, outArray);
- }
-
- public void Dispose()
- {
- inHandle.Free();
- outHandle.Free();
- }
- }
-
- }
-}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32_r.csproj
deleted file mode 100644
index 17724c72cb..0000000000
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32_r.csproj
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{E42146CD-285E-43A8-B254-5B252594EAFB}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <PropertyGroup>
- <DebugType>Embedded</DebugType>
- <Optimize></Optimize>
- </PropertyGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ConvertScalarToVector128Int32.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32_ro.csproj
deleted file mode 100644
index f2e662f8bf..0000000000
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128Int32_ro.csproj
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{38DA713E-D154-4724-9BA8-5E7A19A160C4}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <PropertyGroup>
- <DebugType>Embedded</DebugType>
- <Optimize>True</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ConvertScalarToVector128Int32.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32.UInt32.cs
new file mode 100644
index 0000000000..14608d5b15
--- /dev/null
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32.UInt32.cs
@@ -0,0 +1,267 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file. *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+ public static partial class Program
+ {
+ private static void ConvertScalarToVector128UInt32UInt32()
+ {
+ var test = new ScalarSimdUnaryOpTest__ConvertScalarToVector128UInt32UInt32();
+
+ if (test.IsSupported)
+ {
+ // Validates basic functionality works
+ test.RunBasicScenario_UnsafeRead();
+
+ // Validates calling via reflection works
+ test.RunReflectionScenario_UnsafeRead();
+
+ // Validates passing a static member works
+ test.RunClsVarScenario();
+
+ // Validates passing a local works
+ test.RunLclVarScenario_UnsafeRead();
+
+ // Validates passing the field of a local class works
+ test.RunClassLclFldScenario();
+
+ // Validates passing an instance member of a class works
+ test.RunClassFldScenario();
+
+ // Validates passing the field of a local struct works
+ test.RunStructLclFldScenario();
+
+ // Validates passing an instance member of a struct works
+ test.RunStructFldScenario();
+ }
+ else
+ {
+ // Validates we throw on unsupported hardware
+ test.RunUnsupportedScenario();
+ }
+
+ if (!test.Succeeded)
+ {
+ throw new Exception("One or more scenarios did not complete as expected.");
+ }
+ }
+ }
+
+ public sealed unsafe class ScalarSimdUnaryOpTest__ConvertScalarToVector128UInt32UInt32
+ {
+ private struct TestStruct
+ {
+ public UInt32 _fld;
+
+ public static TestStruct Create()
+ {
+ var testStruct = new TestStruct();
+
+ testStruct._fld = TestLibrary.Generator.GetUInt32();
+ return testStruct;
+ }
+
+ public void RunStructFldScenario(ScalarSimdUnaryOpTest__ConvertScalarToVector128UInt32UInt32 testClass)
+ {
+ var result = Sse2.ConvertScalarToVector128UInt32(_fld);
+
+ Unsafe.Write(testClass._dataTable.outArrayPtr, result);
+ testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr);
+ }
+ }
+
+ private static readonly int LargestVectorSize = 16;
+
+ private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt32>>() / sizeof(UInt32);
+
+ private static UInt32 _data;
+
+ private static UInt32 _clsVar;
+
+ private UInt32 _fld;
+
+ private ScalarSimdUnaryOpTest__DataTable<UInt32> _dataTable;
+
+ static ScalarSimdUnaryOpTest__ConvertScalarToVector128UInt32UInt32()
+ {
+ _clsVar = TestLibrary.Generator.GetUInt32();
+ }
+
+ public ScalarSimdUnaryOpTest__ConvertScalarToVector128UInt32UInt32()
+ {
+ Succeeded = true;
+
+ _fld = TestLibrary.Generator.GetUInt32();
+ _data = TestLibrary.Generator.GetUInt32();
+ _dataTable = new ScalarSimdUnaryOpTest__DataTable<UInt32>(new UInt32[RetElementCount], LargestVectorSize);
+ }
+
+ public bool IsSupported => Sse2.IsSupported;
+
+ public bool Succeeded { get; set; }
+
+ public void RunBasicScenario_UnsafeRead()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
+
+ var result = Sse2.ConvertScalarToVector128UInt32(
+ Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data))
+ );
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(_data, _dataTable.outArrayPtr);
+ }
+
+ public void RunReflectionScenario_UnsafeRead()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
+
+ var result = typeof(Sse2).GetMethod(nameof(Sse2.ConvertScalarToVector128UInt32), new Type[] { typeof(UInt32) })
+ .Invoke(null, new object[] {
+ Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data))
+ });
+
+ Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt32>)(result));
+ ValidateResult(_data, _dataTable.outArrayPtr);
+ }
+
+ public void RunClsVarScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
+
+ var result = Sse2.ConvertScalarToVector128UInt32(
+ _clsVar
+ );
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(_clsVar, _dataTable.outArrayPtr);
+ }
+
+ public void RunLclVarScenario_UnsafeRead()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
+
+ var data = Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data));
+ var result = Sse2.ConvertScalarToVector128UInt32(data);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(data, _dataTable.outArrayPtr);
+ }
+
+ public void RunClassLclFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
+
+ var test = new ScalarSimdUnaryOpTest__ConvertScalarToVector128UInt32UInt32();
+ var result = Sse2.ConvertScalarToVector128UInt32(test._fld);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(test._fld, _dataTable.outArrayPtr);
+ }
+
+ public void RunClassFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
+
+ var result = Sse2.ConvertScalarToVector128UInt32(_fld);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(_fld, _dataTable.outArrayPtr);
+ }
+
+ public void RunStructLclFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
+
+ var test = TestStruct.Create();
+ var result = Sse2.ConvertScalarToVector128UInt32(test._fld);
+
+ Unsafe.Write(_dataTable.outArrayPtr, result);
+ ValidateResult(test._fld, _dataTable.outArrayPtr);
+ }
+
+ public void RunStructFldScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
+
+ var test = TestStruct.Create();
+ test.RunStructFldScenario(this);
+ }
+
+ public void RunUnsupportedScenario()
+ {
+ TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario));
+
+ bool succeeded = false;
+
+ try
+ {
+ RunBasicScenario_UnsafeRead();
+ }
+ catch (PlatformNotSupportedException)
+ {
+ succeeded = true;
+ }
+
+ if (!succeeded)
+ {
+ Succeeded = false;
+ }
+ }
+
+ private void ValidateResult(UInt32 firstOp, void* result, [CallerMemberName] string method = "")
+ {
+ UInt32[] outArray = new UInt32[RetElementCount];
+
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt32>>());
+
+ ValidateResult(firstOp, outArray, method);
+ }
+
+ private void ValidateResult(UInt32 firstOp, UInt32[] result, [CallerMemberName] string method = "")
+ {
+ bool succeeded = true;
+
+ if (firstOp != result[0])
+ {
+ succeeded = false;
+ }
+ else
+ {
+ for (var i = 1; i < RetElementCount; i++)
+ {
+ if (false)
+ {
+ succeeded = false;
+ break;
+ }
+ }
+ }
+
+ if (!succeeded)
+ {
+ TestLibrary.TestFramework.LogInformation($"{nameof(Sse2)}.{nameof(Sse2.ConvertScalarToVector128UInt32)}<UInt32>(UInt32): {method} failed:");
+ TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
+ TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
+ TestLibrary.TestFramework.LogInformation(string.Empty);
+
+ Succeeded = false;
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32.cs
deleted file mode 100644
index 4ca1586290..0000000000
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-// 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<float> floatTable = new TestTable<float>(new float[4] { 1, -5, 100, 0 }, new float[4]))
- {
- var vf1 = Unsafe.Read<Vector128<float>>(floatTable.inArrayPtr);
- var vf2 = Sse.ConvertScalarToVector128Single(vf1, 5);
- Unsafe.Write(floatTable.outArrayPtr, vf2);
-
- if (!floatTable.CheckResult((x, y) => (y[0] == 5)
- && (y[1] == x[1]) && (y[2] == x[2]) && (y[3] == x[3])))
- {
- Console.WriteLine("SSE ConvertScalarToVector128Single failed on float:");
- foreach (var item in floatTable.outArray)
- {
- Console.Write(item + ", ");
- }
- Console.WriteLine();
- testResult = Fail;
- }
- }
- }
-
- return testResult;
- }
-
- public unsafe struct TestTable<T> : IDisposable where T : struct
- {
- public T[] inArray;
- public T[] outArray;
-
- public void* inArrayPtr => inHandle.AddrOfPinnedObject().ToPointer();
- public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer();
-
- GCHandle inHandle;
- GCHandle outHandle;
- public TestTable(T[] a, T[] b)
- {
- this.inArray = a;
- this.outArray = b;
-
- inHandle = GCHandle.Alloc(inArray, GCHandleType.Pinned);
- outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned);
- }
- public bool CheckResult(Func<T[], T[], bool> check)
- {
- return check(inArray, outArray);
- }
-
- public void Dispose()
- {
- inHandle.Free();
- outHandle.Free();
- }
- }
-
- }
-}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32_r.csproj
deleted file mode 100644
index eff63f273c..0000000000
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32_r.csproj
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{1023B51C-E7CF-4956-91C4-DA08CBED4B73}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <PropertyGroup>
- <DebugType>Embedded</DebugType>
- <Optimize></Optimize>
- </PropertyGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ConvertScalarToVector128UInt32.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32_ro.csproj
deleted file mode 100644
index b68e5484c1..0000000000
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertScalarToVector128UInt32_ro.csproj
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{5B9D2F20-BFA3-446F-A8F9-27F2E08D895D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <PropertyGroup>
- <DebugType>Embedded</DebugType>
- <Optimize>True</Optimize>
- </PropertyGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ConvertScalarToVector128UInt32.cs" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
- <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Program.Sse2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Program.Sse2.cs
index 61a501d379..2bdcf190fa 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Program.Sse2.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Program.Sse2.cs
@@ -107,6 +107,8 @@ namespace JIT.HardwareIntrinsics.X86
["ConvertToVector128Single.Vector128Double"] = ConvertToVector128SingleVector128Double,
["ConvertToVector128Single.Vector128Int32"] = ConvertToVector128SingleVector128Int32,
["ConvertScalarToVector128Double.Double"] = ConvertScalarToVector128DoubleDouble,
+ ["ConvertScalarToVector128Int32.Int32"] = ConvertScalarToVector128Int32Int32,
+ ["ConvertScalarToVector128UInt32.UInt32"] = ConvertScalarToVector128UInt32UInt32,
["Divide.Double"] = DivideDouble,
["DivideScalar.Double"] = DivideScalarDouble,
["Extract.UInt16.1"] = ExtractUInt161,
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_r.csproj
index fb6dd081b6..fa9f5969ce 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_r.csproj
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_r.csproj
@@ -122,6 +122,8 @@
<Compile Include="ConvertToVector128Single.Vector128Double.cs" />
<Compile Include="ConvertToVector128Single.Vector128Int32.cs" />
<Compile Include="ConvertScalarToVector128Double.Double.cs" />
+ <Compile Include="ConvertScalarToVector128Int32.Int32.cs" />
+ <Compile Include="ConvertScalarToVector128UInt32.UInt32.cs" />
<Compile Include="Divide.Double.cs" />
<Compile Include="DivideScalar.Double.cs" />
<Compile Include="Extract.UInt16.1.cs" />
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_ro.csproj
index 38d2002c43..f0331c69e4 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_ro.csproj
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_ro.csproj
@@ -122,6 +122,8 @@
<Compile Include="ConvertToVector128Single.Vector128Double.cs" />
<Compile Include="ConvertToVector128Single.Vector128Int32.cs" />
<Compile Include="ConvertScalarToVector128Double.Double.cs" />
+ <Compile Include="ConvertScalarToVector128Int32.Int32.cs" />
+ <Compile Include="ConvertScalarToVector128UInt32.UInt32.cs" />
<Compile Include="Divide.Double.cs" />
<Compile Include="DivideScalar.Double.cs" />
<Compile Include="Extract.UInt16.1.cs" />