summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndy Ayers <andya@microsoft.com>2015-12-09 00:57:55 -0800
committerAndy Ayers <andya@microsoft.com>2015-12-09 00:57:55 -0800
commite43afec236172b5aa93cd7442125f235a162b4ad (patch)
treeb6fd721ff80bbabd9c53d8cde20674b972059494 /tests
parent1f6220405b5673e9e711aafa9e397aadc959659d (diff)
parentc370ca3e4a0e8d0e255077c309cad2fefd618be2 (diff)
downloadcoreclr-e43afec236172b5aa93cd7442125f235a162b4ad.tar.gz
coreclr-e43afec236172b5aa93cd7442125f235a162b4ad.tar.bz2
coreclr-e43afec236172b5aa93cd7442125f235a162b4ad.zip
Merge pull request #2271 from AndyAyersMS/SimdTests
Add SIMD tests
Diffstat (limited to 'tests')
-rw-r--r--tests/src/JIT/SIMD/VectorAbs.cs85
-rw-r--r--tests/src/JIT/SIMD/VectorAbs.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorAdd.cs90
-rw-r--r--tests/src/JIT/SIMD/VectorAdd.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorArgs.cs66
-rw-r--r--tests/src/JIT/SIMD/VectorArgs.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorArray.cs170
-rw-r--r--tests/src/JIT/SIMD/VectorArray.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorArrayInit.cs147
-rw-r--r--tests/src/JIT/SIMD/VectorArrayInit.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorCopyToArray.cs148
-rw-r--r--tests/src/JIT/SIMD/VectorCopyToArray.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorDiv.cs111
-rw-r--r--tests/src/JIT/SIMD/VectorDiv.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorDot.cs115
-rw-r--r--tests/src/JIT/SIMD/VectorDot.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorExp.cs71
-rw-r--r--tests/src/JIT/SIMD/VectorExp.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorGet.cs177
-rw-r--r--tests/src/JIT/SIMD/VectorGet.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorHWAccel.cs44
-rw-r--r--tests/src/JIT/SIMD/VectorHWAccel.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorHWAccel2.cs41
-rw-r--r--tests/src/JIT/SIMD/VectorHWAccel2.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorInit.cs47
-rw-r--r--tests/src/JIT/SIMD/VectorInit.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorInitN.cs109
-rw-r--r--tests/src/JIT/SIMD/VectorInitN.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorIntEquals.cs33
-rw-r--r--tests/src/JIT/SIMD/VectorIntEquals.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorMatrix.cs222
-rw-r--r--tests/src/JIT/SIMD/VectorMatrix.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorMax.cs91
-rw-r--r--tests/src/JIT/SIMD/VectorMax.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorMin.cs90
-rw-r--r--tests/src/JIT/SIMD/VectorMin.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorMul.cs123
-rw-r--r--tests/src/JIT/SIMD/VectorMul.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorRelOp.cs159
-rw-r--r--tests/src/JIT/SIMD/VectorRelOp.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorReturn.cs74
-rw-r--r--tests/src/JIT/SIMD/VectorReturn.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorSet.cs80
-rw-r--r--tests/src/JIT/SIMD/VectorSet.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorSqrt.cs52
-rw-r--r--tests/src/JIT/SIMD/VectorSqrt.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorSub.cs86
-rw-r--r--tests/src/JIT/SIMD/VectorSub.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorUnused.cs83
-rw-r--r--tests/src/JIT/SIMD/VectorUnused.csproj44
-rw-r--r--tests/src/JIT/SIMD/VectorUtil.cs214
51 files changed, 3828 insertions, 0 deletions
diff --git a/tests/src/JIT/SIMD/VectorAbs.cs b/tests/src/JIT/SIMD/VectorAbs.cs
new file mode 100644
index 0000000000..476bb73ffe
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorAbs.cs
@@ -0,0 +1,85 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorAbsTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorAbs(T value, T checkValue)
+ {
+ Vector<T> A = new Vector<T>(value);
+ Vector<T> B = Vector.Abs<T>(A);
+
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!(CheckValue<T>(B[i], checkValue)))
+ {
+ return Fail;
+ }
+ }
+ return Pass;
+ }
+ }
+
+ private class Vector4Test
+ {
+ public static int VectorAbs()
+ {
+ Vector4 A = new Vector4(-1f);
+ Vector4 B = Vector4.Abs(A);
+ if (!(CheckValue<float>(B.X, 1f))) return Fail;
+ if (!(CheckValue<float>(B.Y, 1f))) return Fail;
+ if (!(CheckValue<float>(B.Z, 1f))) return Fail;
+ if (!(CheckValue<float>(B.W, 1f))) return Fail;
+ return Pass;
+ }
+ }
+
+ private class Vector3Test
+ {
+ public static int VectorAbs()
+ {
+ Vector3 A = new Vector3(-1f);
+ Vector3 B = Vector3.Abs(A);
+ if (!(CheckValue<float>(B.X, 1f))) return Fail;
+ if (!(CheckValue<float>(B.Y, 1f))) return Fail;
+ if (!(CheckValue<float>(B.Z, 1f))) return Fail;
+ return Pass;
+ }
+ }
+
+ private class Vector2Test
+ {
+ public static int VectorAbs()
+ {
+ Vector2 A = new Vector2(-1f);
+ Vector2 B = Vector2.Abs(A);
+ if (!(CheckValue<float>(B.X, 1f))) return Fail;
+ if (!(CheckValue<float>(B.Y, 1f))) return Fail;
+ return Pass;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+
+ if (VectorAbsTest<float>.VectorAbs(-1f, 1f) != Pass) returnVal = Fail;
+ if (VectorAbsTest<Double>.VectorAbs(-1d, 1d) != Pass) returnVal = Fail;
+ if (VectorAbsTest<int>.VectorAbs(-1, 1) != Pass) returnVal = Fail;
+ if (VectorAbsTest<long>.VectorAbs(-1, 1) != Pass) returnVal = Fail;
+ if (Vector4Test.VectorAbs() != Pass) returnVal = Fail;
+ if (Vector3Test.VectorAbs() != Pass) returnVal = Fail;
+ if (Vector2Test.VectorAbs() != Pass) returnVal = Fail;
+ if (VectorAbsTest<ushort>.VectorAbs((ushort)0xffff, (ushort)0xffff) != Pass) returnVal = Fail;
+ if (VectorAbsTest<byte>.VectorAbs((byte)0xff, (byte)0xff) != Pass) returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorAbs.csproj b/tests/src/JIT/SIMD/VectorAbs.csproj
new file mode 100644
index 0000000000..ed3bb87672
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorAbs.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorAbs.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorAdd.cs b/tests/src/JIT/SIMD/VectorAdd.cs
new file mode 100644
index 0000000000..cbad4951aa
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorAdd.cs
@@ -0,0 +1,90 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorAddTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorAdd(T a, T b, T c)
+ {
+ Vector<T> A = new Vector<T>(a);
+ Vector<T> B = new Vector<T>(b);
+ Vector<T> C = A + B;
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!(CheckValue<T>(C[i], c)))
+ {
+ return Fail;
+ }
+ }
+ return Pass;
+ }
+ }
+ private class Vector4Test
+ {
+ public static int VectorAdd()
+ {
+ Vector4 A = new Vector4(2);
+ Vector4 B = new Vector4(1);
+ Vector4 C = A + B;
+ if (!(CheckValue<float>(C.X, 3))) return Fail;
+ if (!(CheckValue<float>(C.Y, 3))) return Fail;
+ if (!(CheckValue<float>(C.Z, 3))) return Fail;
+ if (!(CheckValue<float>(C.W, 3))) return Fail;
+ return Pass;
+ }
+ }
+
+ private class Vector3Test
+ {
+ public static int VectorAdd()
+ {
+ Vector3 A = new Vector3(2);
+ Vector3 B = new Vector3(1);
+ Vector3 C = A + B;
+ if (!(CheckValue<float>(C.X, 3))) return Fail;
+ if (!(CheckValue<float>(C.Y, 3))) return Fail;
+ if (!(CheckValue<float>(C.Z, 3))) return Fail;
+ return Pass;
+ }
+ }
+
+ private class Vector2Test
+ {
+ public static int VectorAdd()
+ {
+ Vector2 A = new Vector2(2);
+ Vector2 B = new Vector2(1);
+ Vector2 C = A + B;
+ if (!(CheckValue<float>(C.X, 3))) return Fail;
+ if (!(CheckValue<float>(C.Y, 3))) return Fail;
+ return Pass;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+ if (VectorAddTest<float>.VectorAdd(1, 2, (float)(1 + 2)) != Pass) returnVal = Fail;
+ if (VectorAddTest<double>.VectorAdd(1, 2, (double)(1 + 2)) != Pass) returnVal = Fail;
+ if (VectorAddTest<int>.VectorAdd(1, 2, (int)(1 + 2)) != Pass) returnVal = Fail;
+ if (VectorAddTest<long>.VectorAdd(1, 2, (long)(1 + 2)) != Pass) returnVal = Fail;
+ if (Vector4Test.VectorAdd() != Pass) returnVal = Fail;
+ if (Vector3Test.VectorAdd() != Pass) returnVal = Fail;
+ if (Vector2Test.VectorAdd() != Pass) returnVal = Fail;
+ if (VectorAddTest<ushort>.VectorAdd(1, 2, (ushort)(1 + 2)) != Pass) returnVal = Fail;
+ if (VectorAddTest<byte>.VectorAdd(1, 2, (byte)(1 + 2)) != Pass) returnVal = Fail;
+ if (VectorAddTest<short>.VectorAdd(-1, -2, (short)(-1 - 2)) != Pass) returnVal = Fail;
+ if (VectorAddTest<sbyte>.VectorAdd(-1, -2, (sbyte)(-1 - 2)) != Pass) returnVal = Fail;
+ if (VectorAddTest<uint>.VectorAdd(0x41000000u, 0x42000000u, 0x41000000u + 0x42000000u) != Pass) returnVal = Fail;
+ if (VectorAddTest<ulong>.VectorAdd(0x4100000000000000ul, 0x4200000000000000ul, 0x4100000000000000ul + 0x4200000000000000ul) != Pass) returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorAdd.csproj b/tests/src/JIT/SIMD/VectorAdd.csproj
new file mode 100644
index 0000000000..caba8529db
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorAdd.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorAdd.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorArgs.cs b/tests/src/JIT/SIMD/VectorArgs.cs
new file mode 100644
index 0000000000..c365ec6c87
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorArgs.cs
@@ -0,0 +1,66 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal class Color
+{
+ private Vector<float> _rgb;
+
+ public Color(float r, float g, float b)
+ {
+ float[] temp = new float[Vector<float>.Count];
+ temp[0] = r; temp[1] = g; temp[2] = b;
+ _rgb = new Vector<float>(temp);
+ }
+
+ public Color(Vector<float> _rgb)
+ { this._rgb = _rgb; }
+
+ public Color Change(float f)
+ {
+ Vector<float> t = new Vector<float>(f);
+ // t[3] = 0;
+ return new Color(t * _rgb);
+ }
+
+ public Vector<float> RGB { get { return _rgb; } }
+}
+
+internal partial class VectorTest
+{
+ private static int VectorArgs()
+ {
+ const int Pass = 100;
+ const int Fail = -1;
+
+ float[] temp = new float[Vector<float>.Count];
+ for (int i = 0; i < Vector<float>.Count; i++)
+ {
+ temp[i] = 3 - i;
+ }
+ Vector<float> rgb = new Vector<float>(temp);
+
+ float x = 2f;
+ Color c1 = new Color(rgb);
+ Color c2 = c1.Change(x);
+
+ for (int i = 0; i < Vector<float>.Count; i++)
+ {
+ // Round to integer for comparison.
+ if (((int)c2.RGB[i]) != (3 - i) * x)
+ {
+ return Fail;
+ }
+ }
+
+ return Pass;
+ }
+
+ private static int Main()
+ {
+ return VectorArgs();
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorArgs.csproj b/tests/src/JIT/SIMD/VectorArgs.csproj
new file mode 100644
index 0000000000..e2aa8b6299
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorArgs.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorArgs.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorArray.cs b/tests/src/JIT/SIMD/VectorArray.cs
new file mode 100644
index 0000000000..7d76f91120
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorArray.cs
@@ -0,0 +1,170 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorArrayTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ private static void Move(Vector<T>[] pos, ref Vector<T> delta)
+ {
+ for (int i = 0; i < pos.Length; ++i)
+ pos[i] += delta;
+ }
+
+ static public int VectorArray(T deltaValue)
+ {
+ const int Pass = 100;
+ const int Fail = -1;
+
+ Vector<T>[] v = new Vector<T>[3];
+ for (int i = 0; i < v.Length; ++i)
+ v[i] = new Vector<T>(GetValueFromInt<T>(i + 1));
+
+ Vector<T> delta = new Vector<T>(GetValueFromInt<T>(1));
+ Move(v, ref delta);
+
+ for (int i = 0; i < v.Length; i++)
+ {
+ T checkValue = GetValueFromInt<T>(i + 2);
+ for (int j = 0; j < Vector<T>.Count; j++)
+ {
+ if (!(CheckValue<T>(v[i][j], checkValue))) return Fail;
+ }
+ }
+
+ return Pass;
+ }
+ }
+
+ private class Vector4Test
+ {
+ private static void Move(Vector4[] pos, ref Vector4 delta)
+ {
+ for (int i = 0; i < pos.Length; ++i)
+ pos[i] += delta;
+ }
+
+ static public int VectorArray(float deltaValue)
+ {
+ const int Pass = 100;
+ const int Fail = -1;
+
+ Vector4[] v = new Vector4[3];
+ for (int i = 0; i < 3; ++i)
+ v[i] = new Vector4(i + 1);
+
+ Vector4 delta = new Vector4(1);
+ Move(v, ref delta);
+
+ for (int i = 0; i < v.Length; i++)
+ {
+ float checkValue = (float)(i + 2);
+ if (!(CheckValue<float>(v[i].X, checkValue))) return Fail;
+ if (!(CheckValue<float>(v[i].Y, checkValue))) return Fail;
+ if (!(CheckValue<float>(v[i].Z, checkValue))) return Fail;
+ if (!(CheckValue<float>(v[i].W, checkValue))) return Fail;
+ }
+
+ return Pass;
+ }
+ }
+
+ private class Vector3Test
+ {
+ private static void Move(Vector3[] pos, ref Vector3 delta)
+ {
+ for (int i = 0; i < pos.Length; ++i)
+ pos[i] += delta;
+ }
+
+ static public int VectorArray(float deltaValue)
+ {
+ const int Pass = 100;
+ const int Fail = -1;
+
+ Vector3[] v = new Vector3[3];
+ for (int i = 0; i < 3; ++i)
+ v[i] = new Vector3(i + 1);
+
+ Vector3 delta = new Vector3(1);
+ Move(v, ref delta);
+
+ for (int i = 0; i < v.Length; i++)
+ {
+ float checkValue = (float)(i + 2);
+ if (!(CheckValue<float>(v[i].X, checkValue))) return Fail;
+ if (!(CheckValue<float>(v[i].Y, checkValue))) return Fail;
+ if (!(CheckValue<float>(v[i].Z, checkValue))) return Fail;
+ }
+
+ return Pass;
+ }
+ }
+
+ private class Vector2Test
+ {
+ private static void Move(Vector2[] pos, ref Vector2 delta)
+ {
+ for (int i = 0; i < pos.Length; ++i)
+ pos[i] += delta;
+ }
+
+ static public int VectorArray(float deltaValue)
+ {
+ const int Pass = 100;
+ const int Fail = -1;
+
+ Vector2[] v = new Vector2[3];
+ for (int i = 0; i < 3; ++i)
+ v[i] = new Vector2(i + 1);
+
+ Vector2 delta = new Vector2(1);
+ Move(v, ref delta);
+
+ for (int i = 0; i < v.Length; i++)
+ {
+ float checkValue = (float)(i + 2);
+ if (!(CheckValue<float>(v[i].X, checkValue))) return Fail;
+ if (!(CheckValue<float>(v[i].Y, checkValue))) return Fail;
+ }
+
+ return Pass;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+ try
+ {
+ if (VectorArrayTest<float>.VectorArray(1f) != Pass) returnVal = Fail;
+ if (VectorArrayTest<double>.VectorArray(1d) != Pass) returnVal = Fail;
+ if (VectorArrayTest<int>.VectorArray(1) != Pass) returnVal = Fail;
+ if (VectorArrayTest<long>.VectorArray(1L) != Pass) returnVal = Fail;
+ if (Vector4Test.VectorArray(1f) != Pass) returnVal = Fail;
+ if (Vector3Test.VectorArray(1f) != Pass) returnVal = Fail;
+ if (Vector2Test.VectorArray(1f) != Pass) returnVal = Fail;
+ if (VectorArrayTest<ushort>.VectorArray(1) != Pass) returnVal = Fail;
+ if (VectorArrayTest<byte>.VectorArray(1) != Pass) returnVal = Fail;
+ if (VectorArrayTest<short>.VectorArray(1) != Pass) returnVal = Fail;
+ if (VectorArrayTest<sbyte>.VectorArray(1) != Pass) returnVal = Fail;
+ if (VectorArrayTest<uint>.VectorArray(1) != Pass) returnVal = Fail;
+ if (VectorArrayTest<ulong>.VectorArray(1ul) != Pass) returnVal = Fail;
+ }
+ catch (ArgumentException ex)
+ {
+ Console.WriteLine("Argument Exception was raised");
+ Console.WriteLine(ex.StackTrace);
+ return Fail;
+ }
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorArray.csproj b/tests/src/JIT/SIMD/VectorArray.csproj
new file mode 100644
index 0000000000..8a34448eaf
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorArray.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorArray.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorArrayInit.cs b/tests/src/JIT/SIMD/VectorArrayInit.cs
new file mode 100644
index 0000000000..6bf90aedce
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorArrayInit.cs
@@ -0,0 +1,147 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorArrayInitTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorArrayInit(int size, Random random)
+ {
+ int returnVal = Pass;
+
+ if (size < Vector<T>.Count) size = Vector<T>.Count;
+ int index = size - Vector<T>.Count;
+ T[] inputArray = GetRandomArray<T>(size, random);
+ bool caught;
+
+ Vector<T> v1 = new Vector<T>(inputArray);
+ Vector<T> v2 = new Vector<T>(inputArray, index);
+
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!CheckValue(v1[i], inputArray[i])) returnVal = Fail;
+ if (!CheckValue(v2[i], inputArray[index + i])) returnVal = Fail;
+ }
+
+ // Test a null input array.
+ caught = false;
+ try
+ {
+ Vector<T> v = new Vector<T>(null, 0);
+ // Check one of the values so that v is not optimized away.
+ // TODO: Also test without this because it should still throw.
+ if (!CheckValue(v[0], inputArray[0])) returnVal = Fail;
+ }
+ catch (NullReferenceException)
+ {
+ caught = true;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught exception: " + e.GetType());
+ }
+ if (!caught)
+ {
+ Console.WriteLine("Failed to throw NullReferenceException for a null input array.");
+ returnVal = Fail;
+ }
+
+ // Test a negative index.
+ caught = false;
+ try
+ {
+ Vector<T> v = new Vector<T>(inputArray, -1);
+ }
+ catch (IndexOutOfRangeException)
+ {
+ caught = true;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught exception: " + e.GetType());
+ }
+ if (!caught)
+ {
+ Console.WriteLine("Failed to throw IndexOutOfRangeException for a negative index.");
+ returnVal = Fail;
+ }
+
+ // Test an out-of-range index.
+ caught = false;
+ try
+ {
+ Vector<T> v = new Vector<T>(inputArray, inputArray.Length);
+ }
+ catch (IndexOutOfRangeException)
+ {
+ caught = true;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught exception: " + e.GetType());
+ }
+ if (!caught)
+ {
+ Console.WriteLine("Failed to throw IndexOutOfRangeException for an out-of-range index.");
+ returnVal = Fail;
+ }
+
+ // Test insufficient range in target array.
+ caught = false;
+ try
+ {
+ Vector<T> v = new Vector<T>(inputArray, inputArray.Length - 1);
+ }
+ catch (IndexOutOfRangeException)
+ {
+ caught = true;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught exception: " + e.GetType());
+ }
+ if (!caught)
+ {
+ Console.WriteLine("Failed to throw IndexOutOfRangeException for insufficient range in target array.");
+ returnVal = Fail;
+ }
+
+ return returnVal;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+ Random random = new Random(100);
+
+ if (VectorArrayInitTest<Single>.VectorArrayInit(17, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<Single>.VectorArrayInit(12, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<Double>.VectorArrayInit(12, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<Double>.VectorArrayInit(17, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<int>.VectorArrayInit(12, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<int>.VectorArrayInit(17, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<long>.VectorArrayInit(12, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<long>.VectorArrayInit(17, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<ushort>.VectorArrayInit(12, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<ushort>.VectorArrayInit(17, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<byte>.VectorArrayInit(12, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<byte>.VectorArrayInit(17, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<short>.VectorArrayInit(12, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<short>.VectorArrayInit(17, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<sbyte>.VectorArrayInit(12, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<sbyte>.VectorArrayInit(17, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<uint>.VectorArrayInit(12, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<uint>.VectorArrayInit(17, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<ulong>.VectorArrayInit(12, random) == Fail) returnVal = Fail;
+ if (VectorArrayInitTest<ulong>.VectorArrayInit(17, random) == Fail) returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorArrayInit.csproj b/tests/src/JIT/SIMD/VectorArrayInit.csproj
new file mode 100644
index 0000000000..ae6901a6c6
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorArrayInit.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorArrayInit.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorCopyToArray.cs b/tests/src/JIT/SIMD/VectorCopyToArray.cs
new file mode 100644
index 0000000000..817336d6a8
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorCopyToArray.cs
@@ -0,0 +1,148 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorCopyToArrayTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorCopyToArray(int size, Random random)
+ {
+ int returnVal = Pass;
+
+ if (size < Vector<T>.Count) size = Vector<T>.Count;
+ int index = size - Vector<T>.Count;
+ T[] inputArray = GetRandomArray<T>(size, random);
+
+ Vector<T> v1 = new Vector<T>(inputArray);
+ Vector<T> v2 = new Vector<T>(inputArray, index);
+ bool caught;
+
+ T[] outputArray = new T[2 * Vector<T>.Count];
+ v1.CopyTo(outputArray);
+ v2.CopyTo(outputArray, Vector<T>.Count);
+
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!CheckValue(v1[i], outputArray[i])) returnVal = Fail;
+ if (!CheckValue(v2[i], outputArray[i + Vector<T>.Count])) returnVal = Fail;
+ }
+
+ // Test a null input array.
+ caught = false;
+ try
+ {
+ v1.CopyTo(null);
+ }
+ catch (NullReferenceException)
+ {
+ caught = true;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught exception: " + e.GetType());
+ }
+ if (!caught)
+ {
+ Console.WriteLine("Failed to throw NullReferenceException for a null input array.");
+ returnVal = Fail;
+ }
+
+ // Test a negative index.
+ caught = false;
+ try
+ {
+ v1.CopyTo(outputArray, -1);
+ }
+ catch (ArgumentOutOfRangeException)
+ {
+ caught = true;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught exception: " + e.GetType());
+ }
+ if (!caught)
+ {
+ Console.WriteLine("Failed to throw ArgumentOutOfRangeException for a negative index.");
+ returnVal = Fail;
+ }
+
+ // Test an out-of-range index.
+ caught = false;
+ try
+ {
+ v1.CopyTo(outputArray, outputArray.Length);
+ }
+ catch (ArgumentOutOfRangeException)
+ {
+ caught = true;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught exception: " + e.GetType());
+ }
+ if (!caught)
+ {
+ Console.WriteLine("Failed to throw ArgumentOutOfRangeException for an out-of-range index.");
+ returnVal = Fail;
+ }
+
+ // Test insufficient range in target array.
+ caught = false;
+ try
+ {
+ v1.CopyTo(outputArray, outputArray.Length - 1);
+ }
+ catch (ArgumentException)
+ {
+ caught = true;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught exception: " + e.GetType());
+ }
+ if (!caught)
+ {
+ Console.WriteLine("Failed to throw ArgumentException for insufficient range in target array.");
+ returnVal = Fail;
+ }
+
+ return returnVal;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+ Random random = new Random(100);
+
+ if (VectorCopyToArrayTest<Single>.VectorCopyToArray(17, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<Single>.VectorCopyToArray(12, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<Double>.VectorCopyToArray(12, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<Double>.VectorCopyToArray(17, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<int>.VectorCopyToArray(12, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<int>.VectorCopyToArray(17, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<long>.VectorCopyToArray(12, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<long>.VectorCopyToArray(17, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<ushort>.VectorCopyToArray(12, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<ushort>.VectorCopyToArray(17, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<byte>.VectorCopyToArray(12, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<byte>.VectorCopyToArray(17, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<short>.VectorCopyToArray(12, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<short>.VectorCopyToArray(17, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<sbyte>.VectorCopyToArray(12, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<sbyte>.VectorCopyToArray(17, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<uint>.VectorCopyToArray(12, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<uint>.VectorCopyToArray(17, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<ulong>.VectorCopyToArray(12, random) == Fail) returnVal = Fail;
+ if (VectorCopyToArrayTest<ulong>.VectorCopyToArray(17, random) == Fail) returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorCopyToArray.csproj b/tests/src/JIT/SIMD/VectorCopyToArray.csproj
new file mode 100644
index 0000000000..0912c362bf
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorCopyToArray.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorCopyToArray.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorDiv.cs b/tests/src/JIT/SIMD/VectorDiv.cs
new file mode 100644
index 0000000000..2031701cce
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorDiv.cs
@@ -0,0 +1,111 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorMulTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorDiv(T left, T right, T result)
+ {
+ Vector<T> A = new Vector<T>(left);
+ Vector<T> B = new Vector<T>(right);
+
+ Vector<T> C = A / B;
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!(CheckValue<T>(C[i], result)))
+ {
+ return Fail;
+ }
+ }
+ return Pass;
+ }
+ }
+ private class Vector4Test
+ {
+ public static int VectorDiv(float left, float right, float result)
+ {
+ Vector4 A = new Vector4(left);
+ Vector4 B = new Vector4(right);
+ Vector4 C = A / B;
+ if (!(CheckValue<float>(C.X, result))) return Fail;
+ if (!(CheckValue<float>(C.Y, result))) return Fail;
+ if (!(CheckValue<float>(C.Z, result))) return Fail;
+ if (!(CheckValue<float>(C.W, result))) return Fail;
+ return Pass;
+ }
+ }
+
+ private class Vector3Test
+ {
+ public static int VectorDiv(float left, float right, float result)
+ {
+ Vector3 A = new Vector3(left);
+ Vector3 B = new Vector3(right);
+ Vector3 C = A / B;
+ if (!(CheckValue<float>(C.X, result))) return Fail;
+ if (!(CheckValue<float>(C.Y, result))) return Fail;
+ if (!(CheckValue<float>(C.Z, result))) return Fail;
+ return Pass;
+ }
+ }
+
+ private class Vector2Test
+ {
+ public static int VectorDiv(float left, float right, float result)
+ {
+ Vector2 A = new Vector2(left);
+ Vector2 B = new Vector2(right);
+ Vector2 C = A / B;
+ if (!(CheckValue<float>(C.X, result))) return Fail;
+ if (!(CheckValue<float>(C.Y, result))) return Fail;
+ return Pass;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+ if (VectorMulTest<float>.VectorDiv(6f, 2f, 6f / 2f) != Pass) returnVal = Fail;
+ if (VectorMulTest<double>.VectorDiv(8d, 4d, 8d / 4d) != Pass) returnVal = Fail;
+ if (VectorMulTest<int>.VectorDiv(6, 3, 2) != Pass) returnVal = Fail;
+ if (returnVal == Fail)
+ {
+ Console.WriteLine("Failed after int");
+ }
+ if (VectorMulTest<long>.VectorDiv(8, 2, 4) != Pass) returnVal = Fail;
+ if (returnVal == Fail)
+ {
+ Console.WriteLine("Failed after long");
+ }
+ if (Vector4Test.VectorDiv(8f, 3f, 8f / 3f) != Pass)
+ {
+ Console.WriteLine("Vector4Test.VectorDiv failed");
+ returnVal = Fail;
+ }
+ if (Vector3Test.VectorDiv(8f, 3f, 8f / 3f) != Pass)
+ {
+ Console.WriteLine("Vector3Test.VectorDiv failed");
+ returnVal = Fail;
+ }
+ if (Vector2Test.VectorDiv(7f, 2f, 7f / 2f) != Pass)
+ {
+ Console.WriteLine("Vector2Test.VectorDiv failed");
+ returnVal = Fail;
+ }
+ if (VectorMulTest<ushort>.VectorDiv(6, 3, 2) != Pass) returnVal = Fail;
+ if (VectorMulTest<byte>.VectorDiv(6, 3, 2) != Pass) returnVal = Fail;
+ if (VectorMulTest<short>.VectorDiv(6, -3, -2) != Pass) returnVal = Fail;
+ if (VectorMulTest<sbyte>.VectorDiv(6, -3, -2) != Pass) returnVal = Fail;
+ if (VectorMulTest<uint>.VectorDiv(6u, 3u, 2u) != Pass) returnVal = Fail;
+ if (VectorMulTest<ulong>.VectorDiv(8ul, 2ul, 4ul) != Pass) returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorDiv.csproj b/tests/src/JIT/SIMD/VectorDiv.csproj
new file mode 100644
index 0000000000..99e6d81a44
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorDiv.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorDiv.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorDot.cs b/tests/src/JIT/SIMD/VectorDot.cs
new file mode 100644
index 0000000000..340a8d8062
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorDot.cs
@@ -0,0 +1,115 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorDotTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorDot(T left, T right, T checkResult)
+ {
+ const int Pass = 100;
+ const int Fail = -1;
+
+ Vector<T> A = new Vector<T>(left);
+ Vector<T> B = new Vector<T>(right);
+
+ T dotProduct = Vector.Dot<T>(A, B);
+ if (!(CheckValue<T>(dotProduct, checkResult)))
+ {
+ Console.WriteLine("Dot product of Vector<" + typeof(T) + "> failed");
+ return Fail;
+ }
+
+ return Pass;
+ }
+ }
+
+ private class Vector4Test
+ {
+ public static int VectorDot(float left, float right, float checkResult)
+ {
+ const int Pass = 100;
+ const int Fail = -1;
+
+ Vector4 A = new Vector4(left);
+ Vector4 B = new Vector4(right);
+
+ float dotProduct = Vector4.Dot(A, B);
+ if (!(CheckValue<float>(dotProduct, checkResult)))
+ {
+ Console.WriteLine("Dot product of Vector4 failed");
+ return Fail;
+ }
+
+ return Pass;
+ }
+ }
+
+ private class Vector3Test
+ {
+ public static int VectorDot(float left, float right, float checkResult)
+ {
+ const int Pass = 100;
+ const int Fail = -1;
+
+ Vector3 A = new Vector3(left);
+ Vector3 B = new Vector3(right);
+
+ float dotProduct = Vector3.Dot(A, B);
+ if (!(CheckValue<float>(dotProduct, checkResult)))
+ {
+ Console.WriteLine("Dot product of Vector3 failed");
+ return Fail;
+ }
+
+ return Pass;
+ }
+ }
+
+ private class Vector2Test
+ {
+ public static int VectorDot(float left, float right, float checkResult)
+ {
+ const int Pass = 100;
+ const int Fail = -1;
+
+ Vector2 A = new Vector2(left);
+ Vector2 B = new Vector2(right);
+
+ float dotProduct = Vector2.Dot(A, B);
+ if (!(CheckValue<float>(dotProduct, checkResult)))
+ {
+ Console.WriteLine("Dot product of Vector2 failed");
+ return Fail;
+ }
+
+ return Pass;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+ if (VectorDotTest<float>.VectorDot(3f, 2f, 6f * Vector<float>.Count) != Pass) returnVal = Fail;
+ if (VectorDotTest<double>.VectorDot(3d, 2d, 6d * Vector<double>.Count) != Pass) returnVal = Fail;
+ if (VectorDotTest<int>.VectorDot(3, 2, 6 * Vector<int>.Count) != Pass) returnVal = Fail;
+ if (VectorDotTest<long>.VectorDot(3, 2, (long)(6 * Vector<long>.Count)) != Pass) returnVal = Fail;
+ if (Vector4Test.VectorDot(3f, 2f, 24f) != Pass) returnVal = Fail;
+ if (Vector3Test.VectorDot(3f, 2f, 18f) != Pass) returnVal = Fail;
+ if (Vector2Test.VectorDot(3f, 2f, 12f) != Pass) returnVal = Fail;
+ if (VectorDotTest<ushort>.VectorDot(3, 2, (ushort)(6 * Vector<ushort>.Count)) != Pass) returnVal = Fail;
+ if (VectorDotTest<byte>.VectorDot(3, 2, (byte)(6 * Vector<byte>.Count)) != Pass) returnVal = Fail;
+ if (VectorDotTest<short>.VectorDot(3, 2, (short)(6 * Vector<short>.Count)) != Pass) returnVal = Fail;
+ if (VectorDotTest<sbyte>.VectorDot(3, 2, (sbyte)(6 * Vector<sbyte>.Count)) != Pass) returnVal = Fail;
+ if (VectorDotTest<uint>.VectorDot(3u, 2u, (uint)(6 * Vector<uint>.Count)) != Pass) returnVal = Fail;
+ if (VectorDotTest<ulong>.VectorDot(3ul, 2ul, 6ul * (ulong)Vector<ulong>.Count) != Pass) returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorDot.csproj b/tests/src/JIT/SIMD/VectorDot.csproj
new file mode 100644
index 0000000000..a58e4f9905
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorDot.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorDot.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorExp.cs b/tests/src/JIT/SIMD/VectorExp.cs
new file mode 100644
index 0000000000..c67420c08c
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorExp.cs
@@ -0,0 +1,71 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorExpTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorExp(Vector<T> x, T checkValue, T epsilon, T allowableError)
+ {
+ Vector<T> sum = Vector<T>.One;
+ Vector<T> count = Vector<T>.One;
+ Vector<T> term = x;
+ Vector<T> epsilonVec = new Vector<T>(epsilon);
+
+ do
+ {
+ if (Vector.LessThanOrEqualAll<T>(Vector.Abs(term), epsilonVec)) break;
+
+ sum = sum + term;
+ count = count + Vector<T>.One;
+ term = term * (x / count);
+ }
+ while (true);
+
+ if (Vector.LessThanOrEqualAll<T>((Vector.Abs(sum) - new Vector<T>(checkValue)), new Vector<T>(allowableError)))
+ {
+ return Pass;
+ }
+ else
+ {
+ Console.WriteLine("Failed " + typeof(T).Name);
+ VectorPrint(" sum: ", sum);
+ return Fail;
+ }
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+
+ if (VectorExpTest<float>.VectorExp(Vector<float>.One, (float)Math.Exp(1d), Single.Epsilon, 1E-06f) != Pass)
+ {
+ returnVal = Fail;
+ }
+
+ if (VectorExpTest<double>.VectorExp(Vector<double>.One, Math.Exp(1d), Double.Epsilon, 1E-14) != Pass)
+ {
+ returnVal = Fail;
+ }
+
+ if (VectorExpTest<int>.VectorExp(Vector<int>.One, (int)Math.Exp(1), 0, 0) != Pass)
+ {
+ returnVal = Fail;
+ }
+
+ if (VectorExpTest<long>.VectorExp(Vector<long>.One, (long)Math.Exp(1), 0, 0) != Pass)
+ {
+ returnVal = Fail;
+ }
+
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorExp.csproj b/tests/src/JIT/SIMD/VectorExp.csproj
new file mode 100644
index 0000000000..cde12b6214
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorExp.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorExp.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorGet.cs b/tests/src/JIT/SIMD/VectorGet.cs
new file mode 100644
index 0000000000..e92d6d02cb
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorGet.cs
@@ -0,0 +1,177 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+using System.Runtime.CompilerServices;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorGetTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorGet(T value, int index)
+ {
+ int returnVal = Pass;
+
+ Vector<T> A = new Vector<T>(value);
+
+ // Test variable index.
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!CheckValue(A[i], value)) returnVal = Fail;
+ }
+
+ if (!CheckValue(A[index], value)) returnVal = Fail;
+
+ // Test constant index.
+ if (!CheckValue(A[0], value)) returnVal = Fail;
+ if (Vector<T>.Count >= 2)
+ {
+ if (!CheckValue(A[1], value))
+ {
+ Console.WriteLine("Failed for [1] for type " + typeof(T).ToString());
+ returnVal = Fail;
+ }
+ }
+ if (Vector<T>.Count >= 4)
+ {
+ if (!CheckValue(A[2], value))
+ {
+ Console.WriteLine("Failed for [2] for type " + typeof(T).ToString());
+ returnVal = Fail;
+ }
+ if (!CheckValue(A[3], value))
+ {
+ Console.WriteLine("Failed for [3] for type " + typeof(T).ToString());
+ returnVal = Fail;
+ }
+ }
+ if (Vector<T>.Count >= 8)
+ {
+ if (!CheckValue(A[4], value))
+ {
+ Console.WriteLine("Failed for [4] for type " + typeof(T).ToString());
+ returnVal = Fail;
+ }
+ if (!CheckValue(A[5], value))
+ {
+ Console.WriteLine("Failed for [5] for type " + typeof(T).ToString());
+ returnVal = Fail;
+ }
+ if (!CheckValue(A[6], value))
+ {
+ Console.WriteLine("Failed for [6] for type " + typeof(T).ToString());
+ returnVal = Fail;
+ }
+ if (!CheckValue(A[7], value))
+ {
+ Console.WriteLine("Failed for [7] for type " + typeof(T).ToString());
+ returnVal = Fail;
+ }
+ }
+ if (Vector<T>.Count >= 16)
+ {
+ if (!CheckValue(A[8], value)) returnVal = Fail;
+ if (!CheckValue(A[9], value)) returnVal = Fail;
+ if (!CheckValue(A[10], value)) returnVal = Fail;
+ if (!CheckValue(A[11], value)) returnVal = Fail;
+ if (!CheckValue(A[12], value)) returnVal = Fail;
+ if (!CheckValue(A[13], value)) returnVal = Fail;
+ if (!CheckValue(A[14], value)) returnVal = Fail;
+ if (!CheckValue(A[15], value)) returnVal = Fail;
+ }
+ if (Vector<T>.Count >= 32)
+ {
+ if (!CheckValue(A[16], value)) returnVal = Fail;
+ if (!CheckValue(A[17], value)) returnVal = Fail;
+ if (!CheckValue(A[18], value)) returnVal = Fail;
+ if (!CheckValue(A[19], value)) returnVal = Fail;
+ if (!CheckValue(A[20], value)) returnVal = Fail;
+ if (!CheckValue(A[21], value)) returnVal = Fail;
+ if (!CheckValue(A[22], value)) returnVal = Fail;
+ if (!CheckValue(A[23], value)) returnVal = Fail;
+ if (!CheckValue(A[24], value)) returnVal = Fail;
+ if (!CheckValue(A[25], value)) returnVal = Fail;
+ if (!CheckValue(A[26], value)) returnVal = Fail;
+ if (!CheckValue(A[27], value)) returnVal = Fail;
+ if (!CheckValue(A[28], value)) returnVal = Fail;
+ if (!CheckValue(A[29], value)) returnVal = Fail;
+ if (!CheckValue(A[30], value)) returnVal = Fail;
+ if (!CheckValue(A[31], value)) returnVal = Fail;
+ }
+
+ return returnVal;
+ }
+
+ [MethodImpl(MethodImplOptions.NoOptimization)]
+ public static int VectorGetIndexerOutOfRange(T value, int index)
+ {
+ int returnVal = Pass;
+ bool caught;
+
+ Vector<T> A = new Vector<T>(value);
+
+ T check;
+ caught = false;
+ try
+ {
+ switch (Vector<T>.Count)
+ {
+ case 2: check = A[2]; break;
+ case 4: check = A[4]; break;
+ case 8: check = A[8]; break;
+ case 16: check = A[16]; break;
+ case 32: check = A[32]; break;
+ }
+ }
+ catch (IndexOutOfRangeException)
+ {
+ caught = true;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught exception: " + e.GetType());
+ }
+ if (!caught)
+ {
+ Console.WriteLine("Failed to throw IndexOutOfRangeException for index == Count of " + Vector<T>.Count);
+ returnVal = Fail;
+ }
+ return returnVal;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+ if (VectorGetTest<Double>.VectorGet(101D, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<Double>.VectorGet(100D, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<Double>.VectorGetIndexerOutOfRange(100D, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<Single>.VectorGet(101F, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<Single>.VectorGet(100F, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<Single>.VectorGetIndexerOutOfRange(100F, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<int>.VectorGet(101, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<int>.VectorGet(100, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<int>.VectorGetIndexerOutOfRange(100, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<long>.VectorGet(101, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<long>.VectorGet(100, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<long>.VectorGetIndexerOutOfRange(100, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<ushort>.VectorGet(101, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<ushort>.VectorGet(100, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<ushort>.VectorGetIndexerOutOfRange(100, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<byte>.VectorGet(101, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<byte>.VectorGet(100, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<byte>.VectorGetIndexerOutOfRange(100, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<short>.VectorGet(101, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<short>.VectorGet(-100, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<short>.VectorGetIndexerOutOfRange(-100, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<sbyte>.VectorGet(101, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<sbyte>.VectorGet(-100, 1) == Fail) returnVal = Fail;
+ if (VectorGetTest<sbyte>.VectorGetIndexerOutOfRange(-100, 1) == Fail) returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorGet.csproj b/tests/src/JIT/SIMD/VectorGet.csproj
new file mode 100644
index 0000000000..ab5e5fe0a9
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorGet.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorGet.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorHWAccel.cs b/tests/src/JIT/SIMD/VectorHWAccel.cs
new file mode 100644
index 0000000000..20eb3a52a2
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorHWAccel.cs
@@ -0,0 +1,44 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorHWAccelTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorHWAccel(T a, T b, T c)
+ {
+ if (Vector.IsHardwareAccelerated)
+ {
+ Vector<T> A = new Vector<T>(a);
+ Vector<T> B = new Vector<T>(b);
+ Vector<T> C = A + B;
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!(CheckValue<T>(C[i], c)))
+ {
+ return Fail;
+ }
+ }
+ return Pass;
+ }
+ else
+ {
+ return Pass;
+ }
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+ if (VectorHWAccelTest<float>.VectorHWAccel(1, 2, (float)(1 + 2)) != Pass) returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorHWAccel.csproj b/tests/src/JIT/SIMD/VectorHWAccel.csproj
new file mode 100644
index 0000000000..f2d7114fcc
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorHWAccel.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorHWAccel.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorHWAccel2.cs b/tests/src/JIT/SIMD/VectorHWAccel2.cs
new file mode 100644
index 0000000000..f3fd503ba7
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorHWAccel2.cs
@@ -0,0 +1,41 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorHWAccelTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorHWAccel2(T a, T b, T c)
+ {
+ Vector<T> A = new Vector<T>(a);
+ Vector<T> B = new Vector<T>(b);
+ Vector<T> C = A + B;
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!(CheckValue<T>(C[i], c)))
+ {
+ return Fail;
+ }
+ }
+ return Pass;
+ }
+ }
+
+ private static int Main()
+ {
+ if (Vector.IsHardwareAccelerated)
+ {
+ // The test harness will check to ensure that this method was compiled, which it will
+ // not be if IsHardwareAccelerated returns false.
+ return VectorHWAccelTest<float>.VectorHWAccel2(1, 2, (float)(1 + 2));
+ }
+ return Pass;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorHWAccel2.csproj b/tests/src/JIT/SIMD/VectorHWAccel2.csproj
new file mode 100644
index 0000000000..790ecfc069
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorHWAccel2.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorHWAccel2.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorInit.cs b/tests/src/JIT/SIMD/VectorInit.cs
new file mode 100644
index 0000000000..6e57c9be2e
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorInit.cs
@@ -0,0 +1,47 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorInitTest
+ {
+ public static int VectorInit(float x)
+ {
+ int returnVal = Pass;
+
+ Vector2 v2 = new Vector2(x);
+ Vector3 v3 = new Vector3(v2.X);
+ Vector4 v4 = new Vector4(v3.Y);
+
+ float result2 = Vector2.Dot(v2, v2);
+ float result3 = Vector3.Dot(v3, v3);
+ float result4 = Vector4.Dot(v4, v4);
+
+ Console.WriteLine("result2 : " + result2);
+ Console.WriteLine("result3 : " + result3);
+ Console.WriteLine("result4 : " + result4);
+
+ if (result2 != 2f * x * x) return Fail;
+ if (result3 != 3f * x * x) return Fail;
+ if (result4 != 4f * x * x) return Fail;
+
+ return returnVal;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+
+ if (VectorInitTest.VectorInit(2f) == Fail) returnVal = Fail;
+ return returnVal;
+ }
+}
+
diff --git a/tests/src/JIT/SIMD/VectorInit.csproj b/tests/src/JIT/SIMD/VectorInit.csproj
new file mode 100644
index 0000000000..262a4b3256
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorInit.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorInit.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorInitN.cs b/tests/src/JIT/SIMD/VectorInitN.cs
new file mode 100644
index 0000000000..0018c5f91e
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorInitN.cs
@@ -0,0 +1,109 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+using System.Runtime.CompilerServices;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorInitNTest
+ {
+ private static float s_value = 1.0F;
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static float nextValue()
+ {
+ float returnValue = s_value;
+ s_value += 1.0F;
+ return returnValue;
+ }
+
+ public static int VectorInitN(float x, float y, float z, float w)
+ {
+ int returnVal = Pass;
+
+ Vector2 v2 = new Vector2(x, y);
+ if (v2.X != x)
+ {
+ Console.WriteLine("Vector2.X failed");
+ returnVal = Fail;
+ }
+ if (v2.Y != y)
+ {
+ Console.WriteLine("Vector2.Y failed");
+ returnVal = Fail;
+ }
+ v2 = new Vector2(nextValue(), nextValue());
+ if (v2.X > v2.Y)
+ {
+ Console.WriteLine("Vector2 evaluation order failed.");
+ }
+
+ Vector3 v3 = new Vector3(x, y, z);
+ if (v3.X != x)
+ {
+ Console.WriteLine("Vector3.X failed");
+ returnVal = Fail;
+ }
+ if (v3.Y != y)
+ {
+ Console.WriteLine("Vector3.Y failed");
+ returnVal = Fail;
+ }
+ if (v3.Z != z)
+ {
+ Console.WriteLine("Vector3.Z failed");
+ returnVal = Fail;
+ }
+ v3 = new Vector3(nextValue(), nextValue(), nextValue());
+ if ((v3.X > v3.Y) || (v3.Y > v3.Z))
+ {
+ Console.WriteLine("Vector3 evaluation order failed.");
+ }
+
+ Vector4 v4 = new Vector4(x, y, z, w);
+ if (v4.X != x)
+ {
+ Console.WriteLine("Vector4.X failed");
+ returnVal = Fail;
+ }
+ if (v4.Y != y)
+ {
+ Console.WriteLine("Vector4.Y failed");
+ returnVal = Fail;
+ }
+ if (v4.Z != z)
+ {
+ Console.WriteLine("Vector4.Z failed");
+ returnVal = Fail;
+ }
+ if (v4.W != w)
+ {
+ Console.WriteLine("Vector4.W failed");
+ returnVal = Fail;
+ }
+ v4 = new Vector4(nextValue(), nextValue(), nextValue(), nextValue());
+ if ((v4.X > v4.Y) || (v4.Y > v4.Z) || (v4.Z > v4.W))
+ {
+ Console.WriteLine("Vector4 evaluation order failed.");
+ }
+
+
+ return returnVal;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+
+ if (VectorInitNTest.VectorInitN(0.5f, -0.5f, 0f, 1.0f) == Fail) returnVal = Fail;
+ return returnVal;
+ }
+}
+
diff --git a/tests/src/JIT/SIMD/VectorInitN.csproj b/tests/src/JIT/SIMD/VectorInitN.csproj
new file mode 100644
index 0000000000..1afe58b845
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorInitN.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorInitN.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorIntEquals.cs b/tests/src/JIT/SIMD/VectorIntEquals.cs
new file mode 100644
index 0000000000..05ba2b98fe
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorIntEquals.cs
@@ -0,0 +1,33 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private static int VectorIntEquals()
+ {
+ const int Pass = 100;
+ const int Fail = -1;
+
+ Vector<int> A = new Vector<int>(3);
+ Vector<int> B = new Vector<int>(3);
+ Vector<int> C = new Vector<int>(5);
+
+
+ bool result = A.Equals(B);
+ if (!result) return Fail;
+
+ result = A.Equals(C);
+ if (result) return Fail;
+
+ return Pass;
+ }
+
+ private static int Main()
+ {
+ return VectorIntEquals();
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorIntEquals.csproj b/tests/src/JIT/SIMD/VectorIntEquals.csproj
new file mode 100644
index 0000000000..b409c703d8
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorIntEquals.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorIntEquals.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorMatrix.cs b/tests/src/JIT/SIMD/VectorMatrix.cs
new file mode 100644
index 0000000000..8edc32f3be
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorMatrix.cs
@@ -0,0 +1,222 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ // Matrix for test purposes only - no per-dim bounds checking, etc.
+ public struct Matrix<T>
+ where T : struct, IComparable<T>, IEquatable<T>
+ {
+ // data is a flattened matrix.
+ private T[] _data;
+ public int xCount, yCount;
+ private int _xTileCount;
+ private int _yTileCount;
+ private int _flattenedCount;
+ private static readonly int s_tileSize = Vector<T>.Count;
+
+ public
+ Matrix(int theXCount, int theYCount)
+ {
+ // Round up the dimensions so that we don't have to deal with remnants.
+ int vectorCount = Vector<T>.Count;
+ _xTileCount = (theXCount + vectorCount - 1) / vectorCount;
+ _yTileCount = (theYCount + vectorCount - 1) / vectorCount;
+ xCount = _xTileCount * vectorCount;
+ yCount = _yTileCount * vectorCount;
+ _flattenedCount = xCount * yCount;
+ _data = new T[_flattenedCount];
+ }
+
+ public T this[int indexX, int indexY]
+ {
+ get
+ {
+ return _data[(indexX * yCount) + indexY];
+ }
+ set
+ {
+ _data[(indexX * yCount) + indexY] = value;
+ }
+ }
+
+ public static void Transpose(Matrix<T> m, int xStart, int yStart, Vector<T>[] result)
+ {
+ int Count = result.Length;
+ T[][] tempResult = new T[Count][];
+ if (Count != Vector<T>.Count)
+ {
+ throw new ArgumentException();
+ }
+ for (int i = 0; i < Count; i++)
+ {
+ tempResult[i] = new T[Count];
+ }
+ for (int i = 0; i < Count; i++)
+ {
+ for (int j = 0; j < Count; j++)
+ {
+ tempResult[j][i] = m[xStart + i, yStart + j];
+ }
+ }
+ for (int i = 0; i < Count; i++)
+ {
+ result[i] = new Vector<T>(tempResult[i]);
+ }
+ }
+
+ public static Matrix<T> operator *(Matrix<T> left, Matrix<T> right)
+ {
+ int newXCount = left.xCount;
+ int newYCount = right.yCount;
+ int innerCount = left.yCount;
+ Matrix<T> result = new Matrix<T>(newXCount, newYCount);
+ Vector<T>[] temp = new Vector<T>[s_tileSize];
+ T[] temp2 = new T[s_tileSize];
+ T[] temp3 = new T[s_tileSize];
+ if (left.yCount != right.xCount)
+ {
+ throw new ArgumentException();
+ }
+ for (int i = 0; i < result.xCount; i += s_tileSize)
+ {
+ for (int j = 0; j < result.yCount; j += s_tileSize)
+ {
+ for (int k = 0; k < right.xCount; k += s_tileSize)
+ {
+ // Compute the result for the tile:
+ // Result[i,j] = Left[i,k] * Right[k,j]
+ // Would REALLY like to have a Transpose intrinsic
+ // that could use shuffles.
+ Transpose(right, k, j, temp);
+ Vector<T> dot = Vector<T>.Zero;
+ for (int m = 0; m < s_tileSize; m++)
+ {
+ Vector<T> leftTileRow = new Vector<T>(left._data, (i + m) * left.yCount + k);
+
+ for (int n = 0; n < s_tileSize; n++)
+ {
+ temp2[n] = Vector.Dot<T>(leftTileRow, temp[n]);
+ }
+ Vector<T> resultVector = new Vector<T>(result._data, (i + m) * result.yCount + j);
+
+ resultVector += new Vector<T>(temp2);
+ // Store the resultTile
+ resultVector.CopyTo(result._data, ((i + m) * result.yCount + j));
+ }
+ }
+ }
+ }
+ return result;
+ }
+ public void Print()
+ {
+ Console.WriteLine("[");
+ for (int i = 0; i < xCount; i++)
+ {
+ Console.Write(" [");
+ for (int j = 0; j < yCount; j++)
+ {
+ Console.Write(this[i, j]);
+ if (j < (yCount - 1)) Console.Write(",");
+ }
+ Console.WriteLine("]");
+ }
+ Console.WriteLine("]");
+ }
+ }
+
+ public static Matrix<T> GetRandomMatrix<T>(int xDim, int yDim, Random random)
+ where T : struct, IComparable<T>, IEquatable<T>
+ {
+ Matrix<T> result = new Matrix<T>(xDim, yDim);
+ for (int i = 0; i < xDim; i++)
+ {
+ for (int j = 0; j < yDim; j++)
+ {
+ int data = random.Next(100);
+ result[i, j] = GetValueFromInt<T>(data);
+ }
+ }
+ return result;
+ }
+
+ private static T compareMMPoint<T>(Matrix<T> left, Matrix<T> right, int i, int j)
+ where T : struct, IComparable<T>, IEquatable<T>
+ {
+ T sum = Vector<T>.Zero[0];
+ for (int k = 0; k < right.xCount; k++)
+ {
+ T l = left[i, k];
+ T r = right[k, j];
+ sum = Add<T>(sum, Multiply<T>(l, r));
+ }
+ return sum;
+ }
+
+ public static int VectorMatrix<T>(Matrix<T> left, Matrix<T> right)
+ where T : struct, IComparable<T>, IEquatable<T>
+ {
+ int returnVal = Pass;
+ Matrix<T> Result = left * right;
+ for (int i = 0; i < left.xCount; i++)
+ {
+ for (int j = 0; j < right.yCount; j++)
+ {
+ T compareResult = compareMMPoint<T>(left, right, i, j);
+ T testResult = Result[i, j];
+ if (!(CheckValue<T>(testResult, compareResult)))
+ {
+ Console.WriteLine(" Mismatch at [" + i + "," + j + "]: expected " + compareResult + " got " + testResult);
+ returnVal = Fail;
+ }
+ }
+ }
+ if (returnVal == Fail)
+ {
+ Console.WriteLine("FAILED COMPARE");
+ Console.WriteLine("Left:");
+ left.Print();
+ Console.WriteLine("Right:");
+ right.Print();
+ Console.WriteLine("Result:");
+ Result.Print();
+ }
+ return returnVal;
+ }
+
+ public static int Main()
+ {
+ int returnVal = Pass;
+
+ Random random = new Random(100);
+
+ // Float
+ Matrix<float> AFloat = GetRandomMatrix<float>(3, 4, random);
+ Matrix<float> BFloat = GetRandomMatrix<float>(4, 2, random);
+ if (VectorMatrix<float>(AFloat, BFloat) != Pass) returnVal = Fail;
+
+ AFloat = GetRandomMatrix<float>(33, 20, random);
+ BFloat = GetRandomMatrix<float>(20, 17, random);
+ if (VectorMatrix<float>(AFloat, BFloat) != Pass) returnVal = Fail;
+
+ // Double
+ Matrix<double> ADouble = GetRandomMatrix<double>(3, 4, random);
+ Matrix<double> BDouble = GetRandomMatrix<double>(4, 2, random);
+ if (VectorMatrix<double>(ADouble, BDouble) != Pass) returnVal = Fail;
+
+ ADouble = GetRandomMatrix<double>(33, 20, random);
+ BDouble = GetRandomMatrix<double>(20, 17, random);
+ if (VectorMatrix<double>(ADouble, BDouble) != Pass) returnVal = Fail;
+
+ return returnVal;
+ }
+}
+
diff --git a/tests/src/JIT/SIMD/VectorMatrix.csproj b/tests/src/JIT/SIMD/VectorMatrix.csproj
new file mode 100644
index 0000000000..b4e1b9cf07
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorMatrix.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorMatrix.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorMax.cs b/tests/src/JIT/SIMD/VectorMax.cs
new file mode 100644
index 0000000000..02aafc80ca
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorMax.cs
@@ -0,0 +1,91 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorMaxTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorMax(T left, T right, T result)
+ {
+ Vector<T> A = new Vector<T>(left);
+ Vector<T> B = new Vector<T>(right);
+
+ Vector<T> C = Vector.Max<T>(A, B);
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!(CheckValue<T>(C[i], result)))
+ {
+ return Fail;
+ }
+ }
+ return Pass;
+ }
+ }
+ private class Vector4Test
+ {
+ public static int VectorMax(float left, float right, float result)
+ {
+ Vector4 A = new Vector4(left);
+ Vector4 B = new Vector4(right);
+ Vector4 C = Vector4.Max(A, B);
+ if (!(CheckValue<float>(C.X, result))) return Fail;
+ if (!(CheckValue<float>(C.Y, result))) return Fail;
+ if (!(CheckValue<float>(C.Z, result))) return Fail;
+ if (!(CheckValue<float>(C.W, result))) return Fail;
+ return Pass;
+ }
+ }
+
+ private class Vector3Test
+ {
+ public static int VectorMax(float left, float right, float result)
+ {
+ Vector3 A = new Vector3(left);
+ Vector3 B = new Vector3(right);
+ Vector3 C = Vector3.Max(A, B);
+ if (!(CheckValue<float>(C.X, result))) return Fail;
+ if (!(CheckValue<float>(C.Y, result))) return Fail;
+ if (!(CheckValue<float>(C.Z, result))) return Fail;
+ return Pass;
+ }
+ }
+
+ private class Vector2Test
+ {
+ public static int VectorMax(float left, float right, float result)
+ {
+ Vector2 A = new Vector2(left);
+ Vector2 B = new Vector2(right);
+ Vector2 C = Vector2.Max(A, B);
+ if (!(CheckValue<float>(C.X, result))) return Fail;
+ if (!(CheckValue<float>(C.Y, result))) return Fail;
+ return Pass;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+ if (VectorMaxTest<float>.VectorMax(2f, 3f, 3f) != Pass) returnVal = Fail;
+ if (VectorMaxTest<double>.VectorMax(2d, 3d, 3d) != Pass) returnVal = Fail;
+ if (VectorMaxTest<int>.VectorMax(2, 3, 3) != Pass) returnVal = Fail;
+ if (VectorMaxTest<long>.VectorMax(2, 3, 3) != Pass) returnVal = Fail;
+ if (Vector4Test.VectorMax(2f, 3f, 3f) != Pass) returnVal = Fail;
+ if (Vector3Test.VectorMax(2f, 3f, 3f) != Pass) returnVal = Fail;
+ if (Vector2Test.VectorMax(2f, 3f, 3f) != Pass) returnVal = Fail;
+ if (VectorMaxTest<ushort>.VectorMax(2, 3, 3) != Pass) returnVal = Fail;
+ if (VectorMaxTest<byte>.VectorMax(2, 3, 3) != Pass) returnVal = Fail;
+ if (VectorMaxTest<short>.VectorMax(-2, -3, -2) != Pass) returnVal = Fail;
+ if (VectorMaxTest<sbyte>.VectorMax(-2, 3, 3) != Pass) returnVal = Fail;
+ if (VectorMaxTest<uint>.VectorMax(0x80000000u, 0x40000000u, 0x80000000u) != Pass) returnVal = Fail;
+ if (VectorMaxTest<ulong>.VectorMax(2ul, 3ul, 3ul) != Pass) returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorMax.csproj b/tests/src/JIT/SIMD/VectorMax.csproj
new file mode 100644
index 0000000000..f1fe290d93
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorMax.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorMax.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorMin.cs b/tests/src/JIT/SIMD/VectorMin.cs
new file mode 100644
index 0000000000..eea64399b8
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorMin.cs
@@ -0,0 +1,90 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorMinTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorMin(T left, T right, T result)
+ {
+ Vector<T> A = new Vector<T>(left);
+ Vector<T> B = new Vector<T>(right);
+
+ Vector<T> C = Vector.Min<T>(A, B);
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!(CheckValue<T>(C[i], result)))
+ {
+ return Fail;
+ }
+ }
+ return Pass;
+ }
+ }
+ private class Vector4Test
+ {
+ public static int VectorMin(float left, float right, float result)
+ {
+ Vector4 A = new Vector4(left);
+ Vector4 B = new Vector4(right);
+ Vector4 C = Vector4.Min(A, B);
+ if (!(CheckValue<float>(C.X, result))) return Fail;
+ if (!(CheckValue<float>(C.Y, result))) return Fail;
+ if (!(CheckValue<float>(C.Z, result))) return Fail;
+ return Pass;
+ }
+ }
+
+ private class Vector3Test
+ {
+ public static int VectorMin(float left, float right, float result)
+ {
+ Vector3 A = new Vector3(left);
+ Vector3 B = new Vector3(right);
+ Vector3 C = Vector3.Min(A, B);
+ if (!(CheckValue<float>(C.X, result))) return Fail;
+ if (!(CheckValue<float>(C.Y, result))) return Fail;
+ if (!(CheckValue<float>(C.Z, result))) return Fail;
+ return Pass;
+ }
+ }
+
+ private class Vector2Test
+ {
+ public static int VectorMin(float left, float right, float result)
+ {
+ Vector2 A = new Vector2(left);
+ Vector2 B = new Vector2(right);
+ Vector2 C = Vector2.Min(A, B);
+ if (!(CheckValue<float>(C.X, result))) return Fail;
+ if (!(CheckValue<float>(C.Y, result))) return Fail;
+ return Pass;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+ if (VectorMinTest<float>.VectorMin(2f, 3f, 2f) != Pass) returnVal = Fail;
+ if (VectorMinTest<double>.VectorMin(2d, 3d, 2d) != Pass) returnVal = Fail;
+ if (VectorMinTest<int>.VectorMin(2, 3, 2) != Pass) returnVal = Fail;
+ if (VectorMinTest<long>.VectorMin(2, 3, 2) != Pass) returnVal = Fail;
+ if (Vector4Test.VectorMin(2f, 3f, 2f) != Pass) returnVal = Fail;
+ if (Vector3Test.VectorMin(2f, 3f, 2f) != Pass) returnVal = Fail;
+ if (Vector2Test.VectorMin(2f, 3f, 2f) != Pass) returnVal = Fail;
+ if (VectorMinTest<ushort>.VectorMin(2, 3, 2) != Pass) returnVal = Fail;
+ if (VectorMinTest<byte>.VectorMin(2, 3, 2) != Pass) returnVal = Fail;
+ if (VectorMinTest<short>.VectorMin(-2, -3, -3) != Pass) returnVal = Fail;
+ if (VectorMinTest<sbyte>.VectorMin(-2, 3, -2) != Pass) returnVal = Fail;
+ if (VectorMinTest<uint>.VectorMin(0x80000000u, 0x40000000u, 0x40000000u) != Pass) returnVal = Fail;
+ if (VectorMinTest<ulong>.VectorMin(2ul, 3ul, 2ul) != Pass) returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorMin.csproj b/tests/src/JIT/SIMD/VectorMin.csproj
new file mode 100644
index 0000000000..31d0bd144d
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorMin.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorMin.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorMul.cs b/tests/src/JIT/SIMD/VectorMul.cs
new file mode 100644
index 0000000000..b50595a1a6
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorMul.cs
@@ -0,0 +1,123 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorMulTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorMul(T left, T right, T leftTimesRight, T leftTimesRightSquared, T rightTimesRight)
+ {
+ Vector<T> A = new Vector<T>(left);
+ Vector<T> B = new Vector<T>(right);
+
+ Vector<T> C = A * B;
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!(CheckValue<T>(C[i], leftTimesRight)))
+ {
+ Console.WriteLine("FAILED Loop1: C[" + i + "] = " + C[i] + "; should be " + leftTimesRight);
+ return Fail;
+ }
+ }
+
+ C = C * C;
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!(CheckValue<T>(C[i], leftTimesRightSquared)))
+ {
+ Console.WriteLine("FAILED Loop2: C[" + i + "] = " + C[i] + "; should be " + leftTimesRight);
+ return Fail;
+ }
+ }
+
+ B = B * B;
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!(CheckValue<T>(B[i], rightTimesRight)))
+ {
+ Console.WriteLine("FAILED Loop3: B[" + i + "] = " + C[i] + "; should be " + leftTimesRight);
+ return Fail;
+ }
+ }
+
+ return Pass;
+ }
+ }
+ private class Vector4Test
+ {
+ public static int VectorMul(float left, float right, float result)
+ {
+ Vector4 A = new Vector4(left);
+ Vector4 B = new Vector4(right);
+ Vector4 C = A * B;
+ if (!(CheckValue<float>(C.X, result))) return Fail;
+ if (!(CheckValue<float>(C.Y, result))) return Fail;
+ if (!(CheckValue<float>(C.Z, result))) return Fail;
+ if (!(CheckValue<float>(C.W, result))) return Fail;
+ return Pass;
+ }
+ }
+
+ private class Vector3Test
+ {
+ public static int VectorMul(float left, float right, float result)
+ {
+ Vector3 A = new Vector3(left);
+ Vector3 B = new Vector3(right);
+ Vector3 C = A * B;
+ if (!(CheckValue<float>(C.X, result))) return Fail;
+ if (!(CheckValue<float>(C.Y, result))) return Fail;
+ if (!(CheckValue<float>(C.Z, result))) return Fail;
+ return Pass;
+ }
+ }
+
+ private class Vector2Test
+ {
+ public static int VectorMul(float left, float right, float result)
+ {
+ Vector2 A = new Vector2(left);
+ Vector2 B = new Vector2(right);
+ Vector2 C = A * B;
+ if (!(CheckValue<float>(C.X, result))) return Fail;
+ if (!(CheckValue<float>(C.Y, result))) return Fail;
+ return Pass;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+ if (VectorMulTest<float>.VectorMul(2, 3, (float)(2 * 3), (float)(2 * 3) * (2 * 3), (float)(3 * 3)) != Pass)
+ returnVal = Fail;
+ if (VectorMulTest<double>.VectorMul(2, 3, (double)(2 * 3), (double)(2 * 3) * (2 * 3), (double)(3 * 3)) != Pass)
+ returnVal = Fail;
+ if (VectorMulTest<int>.VectorMul(2, 3, (2 * 3), (2 * 3) * (2 * 3), (3 * 3)) != Pass)
+ returnVal = Fail;
+ if (VectorMulTest<long>.VectorMul(2, 3, (long)(2 * 3), (long)(2 * 3) * (2 * 3), (long)(3 * 3)) != Pass)
+ returnVal = Fail;
+ if (Vector4Test.VectorMul(2, 3, (float)(2 * 3)) != Pass) returnVal = Fail;
+ if (Vector3Test.VectorMul(2, 3, (float)(2 * 3)) != Pass) returnVal = Fail;
+ if (Vector2Test.VectorMul(2, 3, (float)(2 * 3)) != Pass) returnVal = Fail;
+ if (VectorMulTest<ushort>.VectorMul(2, 3, (ushort)(2 * 3), (ushort)(2 * 3) * (2 * 3), (ushort)(3 * 3)) != Pass)
+ returnVal = Fail;
+ if (VectorMulTest<byte>.VectorMul(2, 3, (byte)(2 * 3), (byte)(2 * 3) * (2 * 3), (byte)(3 * 3)) != Pass)
+ returnVal = Fail;
+ if (VectorMulTest<short>.VectorMul(2, 3, (short)(2 * 3), (short)(2 * 3) * (2 * 3), (short)(3 * 3)) != Pass)
+ returnVal = Fail;
+ if (VectorMulTest<sbyte>.VectorMul(2, 3, (sbyte)(2 * 3), (sbyte)(2 * 3) * (2 * 3), (sbyte)(3 * 3)) != Pass)
+ returnVal = Fail;
+ if (VectorMulTest<uint>.VectorMul(2u, 3u, 2u * 3u, (2u * 3u) * (2u * 3u), (3u * 3u)) != Pass)
+ returnVal = Fail;
+ if (VectorMulTest<ulong>.VectorMul(2ul, 3ul, 2ul * 3ul, (2ul * 3ul) * (2ul * 3ul), (3ul * 3ul)) != Pass)
+ returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorMul.csproj b/tests/src/JIT/SIMD/VectorMul.csproj
new file mode 100644
index 0000000000..02228aa487
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorMul.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorMul.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorRelOp.cs b/tests/src/JIT/SIMD/VectorRelOp.cs
new file mode 100644
index 0000000000..d2568a1d96
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorRelOp.cs
@@ -0,0 +1,159 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorRelopTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorRelOp(T larger, T smaller)
+ {
+ const int Pass = 100;
+ const int Fail = -1;
+ int returnVal = Pass;
+
+ Vector<T> A = new Vector<T>(larger);
+ Vector<T> B = new Vector<T>(smaller);
+ Vector<T> C = new Vector<T>(larger);
+ Vector<T> D;
+
+ // less than
+ Vector<T> condition = Vector.LessThan<T>(A, B);
+ D = Vector.ConditionalSelect(condition, A, B);
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!D[i].Equals(B[i]))
+ {
+ Console.WriteLine("Less than condition failed for type " + typeof(T).Name + " at index " + i);
+ returnVal = Fail;
+ }
+ }
+ condition = Vector.LessThan<T>(B, A);
+ D = Vector.ConditionalSelect(condition, A, B);
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!D[i].Equals(A[i]))
+ {
+ Console.WriteLine("Less than condition failed for type " + typeof(T).Name + " at index " + i);
+ returnVal = Fail;
+ }
+ }
+
+ // greater than
+ condition = Vector.GreaterThan<T>(A, B);
+ D = Vector.ConditionalSelect(condition, A, B);
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!D[i].Equals(A[i]))
+ {
+ Console.WriteLine("Greater than condition failed for type " + typeof(T).Name + " at index " + i);
+ returnVal = Fail;
+ }
+ }
+
+ condition = Vector.GreaterThan<T>(B, A);
+ D = Vector.ConditionalSelect(condition, A, B);
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!D[i].Equals(B[i]))
+ {
+ Console.WriteLine("Greater than condition failed for type " + typeof(T).Name + " at index " + i);
+ returnVal = Fail;
+ }
+ }
+
+ // less than or equal
+ condition = Vector.LessThanOrEqual<T>(A, C);
+ D = Vector.ConditionalSelect(condition, A, B);
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!D[i].Equals(A[i]))
+ {
+ Console.WriteLine("Less than or equal condition failed for type " + typeof(T).Name + " at index " + i);
+ returnVal = Fail;
+ }
+ }
+
+ condition = Vector.LessThanOrEqual<T>(A, B);
+ D = Vector.ConditionalSelect(condition, A, B);
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!D[i].Equals(B[i]))
+ {
+ Console.WriteLine("Less than or equal condition failed for type " + typeof(T).Name + " at index " + i);
+ returnVal = Fail;
+ }
+ }
+
+ // greater than or equal
+ condition = Vector.GreaterThanOrEqual<T>(A, C);
+ D = Vector.ConditionalSelect(condition, A, B);
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!D[i].Equals(A[i]))
+ {
+ Console.WriteLine("Greater than or equal condition failed for type " + typeof(T).Name + " at index " + i);
+ returnVal = Fail;
+ }
+ }
+
+ condition = Vector.GreaterThanOrEqual<T>(B, C);
+ D = Vector.ConditionalSelect(condition, A, B);
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!D[i].Equals(B[i]))
+ {
+ Console.WriteLine("Greater than or equal condition failed for type " + typeof(T).Name + " at index " + i);
+ returnVal = Fail;
+ }
+ }
+
+ // equal
+ condition = Vector.Equals<T>(A, C);
+ D = Vector.ConditionalSelect(condition, A, B);
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!D[i].Equals(A[i]))
+ {
+ Console.WriteLine("Equal condition failed for type " + typeof(T).Name + " at index " + i);
+ returnVal = Fail;
+ }
+ }
+
+ condition = Vector.Equals<T>(B, C);
+ D = Vector.ConditionalSelect(condition, A, B);
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!D[i].Equals(B[i]))
+ {
+ Console.WriteLine("Equal condition failed for type " + typeof(T).Name + " at index " + i);
+ returnVal = Fail;
+ }
+ }
+
+ return returnVal;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+ if (VectorRelopTest<float>.VectorRelOp(3, 2) != Pass) returnVal = Fail;
+ if (VectorRelopTest<double>.VectorRelOp(3, 2) != Pass) returnVal = Fail;
+ if (VectorRelopTest<int>.VectorRelOp(3, 2) != Pass) returnVal = Fail;
+ if (VectorRelopTest<long>.VectorRelOp(3, 2) != Pass) returnVal = Fail;
+ if (VectorRelopTest<ushort>.VectorRelOp(3, 2) != Pass) returnVal = Fail;
+ if (VectorRelopTest<byte>.VectorRelOp(3, 2) != Pass) returnVal = Fail;
+ if (VectorRelopTest<short>.VectorRelOp(-2, -3) != Pass) returnVal = Fail;
+ if (VectorRelopTest<sbyte>.VectorRelOp(-2, -3) != Pass) returnVal = Fail;
+ if (VectorRelopTest<uint>.VectorRelOp(3u, 2u) != Pass) returnVal = Fail;
+ if (VectorRelopTest<ulong>.VectorRelOp(3ul, 2ul) != Pass) returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorRelOp.csproj b/tests/src/JIT/SIMD/VectorRelOp.csproj
new file mode 100644
index 0000000000..dfa27170d3
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorRelOp.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorRelOp.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorReturn.cs b/tests/src/JIT/SIMD/VectorReturn.cs
new file mode 100644
index 0000000000..60e4f09e1a
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorReturn.cs
@@ -0,0 +1,74 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+using System.Runtime.CompilerServices;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+ private static Vector2[] s_A;
+ private static Vector2 s_p0;
+ private static Vector2 s_p1;
+ private static Vector2 s_p2;
+ private static Vector2 s_p3;
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static void init()
+ {
+ s_A = new Vector2[10];
+ Random random = new Random(100);
+ for (int i = 0; i < 10; i++)
+ {
+ s_A[i] = new Vector2(random.Next(100));
+ }
+ s_p0 = new Vector2(random.Next(100));
+ s_p1 = new Vector2(random.Next(100));
+ s_p2 = new Vector2(random.Next(100));
+ s_p3 = new Vector2(random.Next(100));
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Vector2 F1(float t)
+ {
+ float ti = 1 - t;
+ float t0 = ti * ti * ti;
+ float t1 = 3 * ti * ti * t;
+ float t2 = 3 * ti * t * t;
+ float t3 = t * t * t;
+ return (t0 * s_p0) + (t1 * s_p1) + (t2 * s_p2) + (t3 * s_p3);
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static Vector2 F2(float u)
+ {
+ if (u < 0)
+ return s_A[0];
+ if (u >= 1)
+ return s_A[1];
+ if (u < 0.1)
+ return s_A[2];
+ if (u > 0.9)
+ return s_A[3];
+ return F1(u);
+ }
+
+ public static int Main()
+ {
+ init();
+ Vector2 result = F2(0.5F);
+ Vector2 expectedResult = F1(0.5F);
+ Console.WriteLine("Result is " + result.ToString());
+ if (!CheckValue<float>(result.X, expectedResult.X) || !CheckValue<float>(result.Y, expectedResult.Y))
+ {
+ Console.WriteLine("Expected result is " + expectedResult.ToString());
+ Console.WriteLine("FAILED");
+ return Fail;
+ }
+ Console.WriteLine("PASSED");
+ return Pass;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorReturn.csproj b/tests/src/JIT/SIMD/VectorReturn.csproj
new file mode 100644
index 0000000000..332449e503
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorReturn.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorReturn.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorSet.cs b/tests/src/JIT/SIMD/VectorSet.cs
new file mode 100644
index 0000000000..8512d8881d
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorSet.cs
@@ -0,0 +1,80 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorSetTest
+ {
+ public static int VectorSet(float value)
+ {
+ int returnVal = Pass;
+
+ Vector2 A = new Vector2(0.0f, 0.0f);
+
+ A.X = value;
+ if (!CheckValue(A.X, value)) returnVal = Fail;
+ if (!CheckValue(A.Y, 0.0f)) returnVal = Fail;
+
+ A.Y = value;
+ if (!CheckValue(A.X, value)) returnVal = Fail;
+ if (!CheckValue(A.Y, value)) returnVal = Fail;
+
+ Vector3 B = new Vector3(0.0f, 0.0f, 0.0f);
+ B.X = value;
+ if (!CheckValue(B.X, value)) returnVal = Fail;
+ if (!CheckValue(B.Y, 0.0f)) returnVal = Fail;
+ if (!CheckValue(B.Z, 0.0f)) returnVal = Fail;
+
+ B.Y = value;
+ if (!CheckValue(B.X, value)) returnVal = Fail;
+ if (!CheckValue(B.Y, value)) returnVal = Fail;
+ if (!CheckValue(B.Z, 0.0f)) returnVal = Fail;
+
+ B.Z = value;
+ if (!CheckValue(B.X, value)) returnVal = Fail;
+ if (!CheckValue(B.Y, value)) returnVal = Fail;
+ if (!CheckValue(B.Z, value)) returnVal = Fail;
+
+ Vector4 C = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ C.X = value;
+ if (!CheckValue(C.X, value)) returnVal = Fail;
+ if (!CheckValue(C.Y, 0.0f)) returnVal = Fail;
+ if (!CheckValue(C.Z, 0.0f)) returnVal = Fail;
+ if (!CheckValue(C.W, 0.0f)) returnVal = Fail;
+
+ C.Y = value;
+ if (!CheckValue(C.X, value)) returnVal = Fail;
+ if (!CheckValue(C.Y, value)) returnVal = Fail;
+ if (!CheckValue(C.Z, 0.0f)) returnVal = Fail;
+ if (!CheckValue(C.W, 0.0f)) returnVal = Fail;
+
+ C.Z = value;
+ if (!CheckValue(C.X, value)) returnVal = Fail;
+ if (!CheckValue(C.Y, value)) returnVal = Fail;
+ if (!CheckValue(C.Z, value)) returnVal = Fail;
+ if (!CheckValue(C.W, 0.0f)) returnVal = Fail;
+
+ C.W = value;
+ if (!CheckValue(C.X, value)) returnVal = Fail;
+ if (!CheckValue(C.Y, value)) returnVal = Fail;
+ if (!CheckValue(C.Z, value)) returnVal = Fail;
+ if (!CheckValue(C.W, value)) returnVal = Fail;
+
+ return returnVal;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+ if (VectorSetTest.VectorSet(3.14f) == Fail) returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorSet.csproj b/tests/src/JIT/SIMD/VectorSet.csproj
new file mode 100644
index 0000000000..fbb299c3e6
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorSet.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorSet.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorSqrt.cs b/tests/src/JIT/SIMD/VectorSqrt.cs
new file mode 100644
index 0000000000..294cfeb486
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorSqrt.cs
@@ -0,0 +1,52 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorSqrtTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorSqrt(T square, T root, T allowableError)
+ {
+ Vector<T> A = new Vector<T>(square);
+ Vector<T> B = Vector.SquareRoot(A);
+
+ if (Vector.LessThanOrEqualAll<T>((Vector.Abs(B) - new Vector<T>(root)), new Vector<T>(allowableError)))
+ {
+ return Pass;
+ }
+ else
+ {
+ Console.WriteLine("Failed " + typeof(T).Name);
+ VectorPrint(" input: ", A);
+ VectorPrint(" result: ", B);
+ return Fail;
+ }
+ }
+ }
+
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+ if (VectorSqrtTest<float>.VectorSqrt(25f, 5f, 1E-06f) != Pass)
+ {
+ returnVal = Fail;
+ }
+ if (VectorSqrtTest<double>.VectorSqrt(25f, 5f, 1E-14) != Pass)
+ {
+ returnVal = Fail;
+ }
+ if (VectorSqrtTest<float>.VectorSqrt(25f, 5f, 0) != Pass)
+ {
+ returnVal = Fail;
+ }
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorSqrt.csproj b/tests/src/JIT/SIMD/VectorSqrt.csproj
new file mode 100644
index 0000000000..a6f9f56e2a
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorSqrt.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorSqrt.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorSub.cs b/tests/src/JIT/SIMD/VectorSub.cs
new file mode 100644
index 0000000000..f620036c2e
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorSub.cs
@@ -0,0 +1,86 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorSubTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorSub(T a, T b, T c)
+ {
+ Vector<T> A = new Vector<T>(a);
+ Vector<T> B = new Vector<T>(b);
+ Vector<T> C = A - B;
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!(CheckValue<T>(C[i], c)))
+ {
+ return Fail;
+ }
+ }
+ return Pass;
+ }
+ }
+ private class Vector4Test
+ {
+ public static int VectorSub()
+ {
+ Vector4 A = new Vector4(3);
+ Vector4 B = new Vector4(2);
+ Vector4 C = A - B;
+ if (!(CheckValue<float>(C.X, 1f))) return Fail;
+ if (!(CheckValue<float>(C.Y, 1f))) return Fail;
+ if (!(CheckValue<float>(C.Z, 1f))) return Fail;
+ if (!(CheckValue<float>(C.W, 1f))) return Fail;
+ return Pass;
+ }
+ }
+ private class Vector3Test
+ {
+ public static int VectorSub()
+ {
+ Vector3 A = new Vector3(3);
+ Vector3 B = new Vector3(2);
+ Vector3 C = A - B;
+ if (!(CheckValue<float>(C.X, 1f))) return Fail;
+ if (!(CheckValue<float>(C.Y, 1f))) return Fail;
+ if (!(CheckValue<float>(C.Z, 1f))) return Fail;
+ return Pass;
+ }
+ }
+ private class Vector2Test
+ {
+ public static int VectorSub()
+ {
+ Vector2 A = new Vector2(4, 3);
+ Vector2 B = new Vector2(3, 2);
+ Vector2 C = A - B;
+ if (!(CheckValue<float>(C.X, 1f))) return Fail;
+ if (!(CheckValue<float>(C.Y, 1f))) return Fail;
+ return Pass;
+ }
+ }
+ private static int Main()
+ {
+ int returnVal = Pass;
+ if (VectorSubTest<float>.VectorSub(3, 2, (float)(3 - 2)) != Pass) returnVal = Fail;
+ if (VectorSubTest<double>.VectorSub(3, 2, (float)(3 - 2)) != Pass) returnVal = Fail;
+ if (VectorSubTest<int>.VectorSub(3, 2, (int)(3 - 2)) != Pass) returnVal = Fail;
+ if (VectorSubTest<long>.VectorSub(3, 2, (long)(3 - 2)) != Pass) returnVal = Fail;
+ if (Vector3Test.VectorSub() != Pass) returnVal = Fail;
+ if (Vector2Test.VectorSub() != Pass) returnVal = Fail;
+ if (VectorSubTest<ushort>.VectorSub(3, 2, (ushort)(3 - 2)) != Pass) returnVal = Fail;
+ if (VectorSubTest<byte>.VectorSub(3, 2, (byte)(3 - 2)) != Pass) returnVal = Fail;
+ if (VectorSubTest<short>.VectorSub(3, -2, (short)(3 + 2)) != Pass) returnVal = Fail;
+ if (VectorSubTest<sbyte>.VectorSub(3, -2, (sbyte)(3 + 2)) != Pass) returnVal = Fail;
+ if (VectorSubTest<uint>.VectorSub(0x42000000u, 0x41000000u, 0x42000000u - 0x41000000u) != Pass) returnVal = Fail;
+ if (VectorSubTest<ulong>.VectorSub(0x42000000ul, 0x41000000ul, 0x42000000ul - 0x41000000ul) != Pass) returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorSub.csproj b/tests/src/JIT/SIMD/VectorSub.csproj
new file mode 100644
index 0000000000..604bfafed4
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorSub.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorSub.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorUnused.cs b/tests/src/JIT/SIMD/VectorUnused.cs
new file mode 100644
index 0000000000..08e2033471
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorUnused.cs
@@ -0,0 +1,83 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+// The Rationalizer was not correctly handling a case of an unused SIMD expression
+// involving a localVar or temporary value, where the SIMD expression is returning a non-SIMD
+// value, and the expression is sufficiently complex (e.g. a call to vector * scalar which is
+// inlined but not an intrinsic).
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ private const int Pass = 100;
+ private const int Fail = -1;
+
+ private class VectorUnusedTest<T> where T : struct, IComparable<T>, IEquatable<T>
+ {
+ public static int VectorUnused(T t1, T t2)
+ {
+ Vector<T> v1 = new Vector<T>(t1);
+ v1.Equals(Vector<T>.One * t2);
+ return Pass;
+ }
+ }
+
+ private class Vector4Test
+ {
+ public static int VectorUnused()
+ {
+ Vector4 v1 = new Vector4(3f);
+ Vector4.Dot(default(Vector4) * 2f, Vector4.One);
+ Vector4.Dot(v1, Vector4.One * 2f);
+ v1.Equals(Vector4.One * 3f);
+ return Pass;
+ }
+ }
+
+ private class Vector3Test
+ {
+ public static int VectorUnused()
+ {
+ Vector3 v1 = new Vector3(3f);
+ Vector3.Dot(default(Vector3) * 2f, Vector3.One);
+ Vector3.Dot(v1, Vector3.One * 2f);
+ v1.Equals(Vector3.One * 3f);
+ return Pass;
+ }
+ }
+
+ private class Vector2Test
+ {
+ public static int VectorUnused()
+ {
+ Vector2 v1 = new Vector2(3f);
+ Vector2.Dot(default(Vector2) * 2f, Vector2.One);
+ Vector2.Dot(v1, Vector2.One * 2f);
+ v1.Equals(Vector2.One * 3f);
+ return Pass;
+ }
+ }
+
+ private static int Main()
+ {
+ int returnVal = Pass;
+
+ if (VectorUnusedTest<float>.VectorUnused(3f, 2f) != Pass) returnVal = Fail;
+ if (VectorUnusedTest<double>.VectorUnused(3, 2) != Pass) returnVal = Fail;
+ if (VectorUnusedTest<int>.VectorUnused(3, 2) != Pass) returnVal = Fail;
+ if (VectorUnusedTest<long>.VectorUnused(3, 2) != Pass) returnVal = Fail;
+ if (VectorUnusedTest<ushort>.VectorUnused(3, 2) != Pass) returnVal = Fail;
+ if (VectorUnusedTest<byte>.VectorUnused(3, 2) != Pass) returnVal = Fail;
+ if (VectorUnusedTest<short>.VectorUnused(3, 2) != Pass) returnVal = Fail;
+ if (VectorUnusedTest<sbyte>.VectorUnused(3, 2) != Pass) returnVal = Fail;
+ if (VectorUnusedTest<uint>.VectorUnused(3, 2) != Pass) returnVal = Fail;
+ if (VectorUnusedTest<ulong>.VectorUnused(3, 2) != Pass) returnVal = Fail;
+ if (Vector4Test.VectorUnused() != Pass) returnVal = Fail;
+ if (Vector3Test.VectorUnused() != Pass) returnVal = Fail;
+ if (Vector2Test.VectorUnused() != Pass) returnVal = Fail;
+ return returnVal;
+ }
+}
diff --git a/tests/src/JIT/SIMD/VectorUnused.csproj b/tests/src/JIT/SIMD/VectorUnused.csproj
new file mode 100644
index 0000000000..a5b12c5bae
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorUnused.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="VectorUnused.cs" />
+ <Compile Include="VectorUtil.cs" />
+ </ItemGroup>
+ <!-- <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>-->
+ <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/SIMD/VectorUtil.cs b/tests/src/JIT/SIMD/VectorUtil.cs
new file mode 100644
index 0000000000..80c9fd238a
--- /dev/null
+++ b/tests/src/JIT/SIMD/VectorUtil.cs
@@ -0,0 +1,214 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+ public static bool CheckValue<T>(T value, T expectedValue)
+ {
+ bool returnVal;
+ if (typeof(T) == typeof(float))
+ {
+ returnVal = Math.Abs(((float)(object)value) - ((float)(object)expectedValue)) <= Single.Epsilon;
+ }
+ if (typeof(T) == typeof(double))
+ {
+ returnVal = Math.Abs(((double)(object)value) - ((double)(object)expectedValue)) <= Double.Epsilon;
+ }
+ else
+ {
+ returnVal = value.Equals(expectedValue);
+ }
+ if (returnVal == false)
+ {
+ Console.WriteLine("CheckValue failed for " + expectedValue + " of type " + typeof(T).ToString());
+ }
+ return returnVal;
+ }
+
+ private static bool CheckVector<T>(Vector<T> V, T value) where T : struct, IComparable<T>, IEquatable<T>
+ {
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ if (!(CheckValue<T>(V[i], value)))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static T GetValueFromInt<T>(int value)
+ {
+ if (typeof(T) == typeof(float))
+ {
+ float floatValue = (float)value;
+ return (T)(object)floatValue;
+ }
+ if (typeof(T) == typeof(double))
+ {
+ double doubleValue = (double)value;
+ return (T)(object)doubleValue;
+ }
+ if (typeof(T) == typeof(int))
+ {
+ return (T)(object)value;
+ }
+ if (typeof(T) == typeof(uint))
+ {
+ uint uintValue = (uint)value;
+ return (T)(object)uintValue;
+ }
+ if (typeof(T) == typeof(long))
+ {
+ long longValue = (long)value;
+ return (T)(object)longValue;
+ }
+ if (typeof(T) == typeof(ulong))
+ {
+ ulong longValue = (ulong)value;
+ return (T)(object)longValue;
+ }
+ if (typeof(T) == typeof(ushort))
+ {
+ return (T)(object)(ushort)value;
+ }
+ if (typeof(T) == typeof(byte))
+ {
+ return (T)(object)(byte)value;
+ }
+ if (typeof(T) == typeof(short))
+ {
+ return (T)(object)(short)value;
+ }
+ if (typeof(T) == typeof(sbyte))
+ {
+ return (T)(object)(sbyte)value;
+ }
+ else
+ {
+ throw new ArgumentException();
+ }
+ }
+
+ private static void VectorPrint<T>(string mesg, Vector<T> v) where T : struct, IComparable<T>, IEquatable<T>
+ {
+ Console.Write(mesg + "[");
+ for (int i = 0; i < Vector<T>.Count; i++)
+ {
+ Console.Write(" " + v[i]);
+ if (i < (Vector<T>.Count - 1)) Console.Write(",");
+ }
+ Console.WriteLine(" ]");
+ }
+
+ private static T Add<T>(T left, T right) where T : struct, IComparable<T>, IEquatable<T>
+ {
+ if (typeof(T) == typeof(float))
+ {
+ return (T)(object)(((float)(object)left) + ((float)(object)right));
+ }
+ if (typeof(T) == typeof(double))
+ {
+ return (T)(object)(((double)(object)left) + ((double)(object)right));
+ }
+ if (typeof(T) == typeof(int))
+ {
+ return (T)(object)(((int)(object)left) + ((int)(object)right));
+ }
+ if (typeof(T) == typeof(uint))
+ {
+ return (T)(object)(((uint)(object)left) + ((uint)(object)right));
+ }
+ if (typeof(T) == typeof(ushort))
+ {
+ return (T)(object)(((ushort)(object)left) + ((ushort)(object)right));
+ }
+ if (typeof(T) == typeof(byte))
+ {
+ return (T)(object)(((byte)(object)left) + ((byte)(object)right));
+ }
+ if (typeof(T) == typeof(short))
+ {
+ return (T)(object)(((short)(object)left) + ((short)(object)right));
+ }
+ if (typeof(T) == typeof(sbyte))
+ {
+ return (T)(object)(((sbyte)(object)left) + ((sbyte)(object)right));
+ }
+ if (typeof(T) == typeof(long))
+ {
+ return (T)(object)(((long)(object)left) + ((long)(object)right));
+ }
+ if (typeof(T) == typeof(ulong))
+ {
+ return (T)(object)(((ulong)(object)left) + ((ulong)(object)right));
+ }
+ else
+ {
+ throw new ArgumentException();
+ }
+ }
+ private static T Multiply<T>(T left, T right) where T : struct, IComparable<T>, IEquatable<T>
+ {
+ if (typeof(T) == typeof(float))
+ {
+ return (T)(object)(((float)(object)left) * ((float)(object)right));
+ }
+ if (typeof(T) == typeof(double))
+ {
+ return (T)(object)(((double)(object)left) * ((double)(object)right));
+ }
+ if (typeof(T) == typeof(int))
+ {
+ return (T)(object)(((int)(object)left) * ((int)(object)right));
+ }
+ if (typeof(T) == typeof(uint))
+ {
+ return (T)(object)(((uint)(object)left) * ((uint)(object)right));
+ }
+ if (typeof(T) == typeof(ushort))
+ {
+ return (T)(object)(((ushort)(object)left) * ((ushort)(object)right));
+ }
+ if (typeof(T) == typeof(byte))
+ {
+ return (T)(object)(((byte)(object)left) * ((byte)(object)right));
+ }
+ if (typeof(T) == typeof(short))
+ {
+ return (T)(object)(((short)(object)left) * ((short)(object)right));
+ }
+ if (typeof(T) == typeof(sbyte))
+ {
+ return (T)(object)(((sbyte)(object)left) * ((sbyte)(object)right));
+ }
+ if (typeof(T) == typeof(long))
+ {
+ return (T)(object)(((long)(object)left) * ((long)(object)right));
+ }
+ if (typeof(T) == typeof(ulong))
+ {
+ return (T)(object)(((ulong)(object)left) * ((ulong)(object)right));
+ }
+ else
+ {
+ throw new ArgumentException();
+ }
+ }
+
+ public static T[] GetRandomArray<T>(int size, Random random)
+ where T : struct, IComparable<T>, IEquatable<T>
+ {
+ T[] result = new T[size];
+ for (int i = 0; i < size; i++)
+ {
+ int data = random.Next(100);
+ result[i] = GetValueFromInt<T>(data);
+ }
+ return result;
+ }
+}