diff options
author | Fei Peng <feipeng.compiler@gmail.com> | 2019-02-19 07:50:15 -0800 |
---|---|---|
committer | Tanner Gooding <tagoo@outlook.com> | 2019-02-19 07:50:15 -0800 |
commit | d466bdbd47ab7a861046b99340e16e037098fb2a (patch) | |
tree | 34651038b676047c224f80879c000194645b4884 /tests/src | |
parent | dd5a4952942fbdda01ad779d648d21e5a91a87a6 (diff) | |
download | coreclr-d466bdbd47ab7a861046b99340e16e037098fb2a.tar.gz coreclr-d466bdbd47ab7a861046b99340e16e037098fb2a.tar.bz2 coreclr-d466bdbd47ab7a861046b99340e16e037098fb2a.zip |
Optimize Vector128/256<T>.Get/WithElement (#22353)
Diffstat (limited to 'tests/src')
3 files changed, 276 insertions, 0 deletions
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17957/GitHub_17957.cs b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17957/GitHub_17957.cs new file mode 100644 index 0000000000..1e65f75a68 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17957/GitHub_17957.cs @@ -0,0 +1,208 @@ +using System; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace GitHub_17957 +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static int Main(string[] args) + { + return (Test128() && Test256()) ? Pass : Fail; + } + + public static bool Test128() + { + Vector128<short> vs = Vector128<short>.Zero; + vs = vs.WithElement(0, -1); + if (vs.GetElement(0) != -1) + { + return false; + } + + vs = vs.WithElement(3, -1); + if (vs.GetElement(3) != -1) + { + return false; + } + + vs = vs.WithElement(7, -1); + if (vs.GetElement(7) != -1) + { + return false; + } + + + Vector128<ushort> vus = Vector128<ushort>.Zero; + vus = vus.WithElement(0, ushort.MaxValue); + if (vus.GetElement(0) != ushort.MaxValue) + { + return false; + } + + vus = vus.WithElement(3, ushort.MaxValue); + if (vus.GetElement(3) != ushort.MaxValue) + { + return false; + } + + vus = vus.WithElement(7, ushort.MaxValue); + if (vus.GetElement(7) != ushort.MaxValue) + { + return false; + } + + + Vector128<sbyte> vsb = Vector128<sbyte>.Zero; + vsb = vsb.WithElement(0, -1); + if (vsb.GetElement(0) != -1) + { + return false; + } + + vsb = vsb.WithElement(7, -1); + if (vsb.GetElement(7) != -1) + { + return false; + } + + vsb = vsb.WithElement(15, -1); + if (vsb.GetElement(15) != -1) + { + return false; + } + + Vector128<byte> vb = Vector128<byte>.Zero; + vb = vb.WithElement(0, byte.MaxValue); + if (vb.GetElement(0) != byte.MaxValue) + { + return false; + } + + vb = vb.WithElement(7, byte.MaxValue); + if (vb.GetElement(7) != byte.MaxValue) + { + return false; + } + + vb = vb.WithElement(15, byte.MaxValue); + if (vb.GetElement(15) != byte.MaxValue) + { + return false; + } + + Vector128<float> vf = Vector128<float>.Zero; + vf = vf.WithElement(0, -1.0f); + if (vf.GetElement(0) != -1.0f) + { + return false; + } + + vf = vf.WithElement(1, -1f); + if (vf.GetElement(1) != -1.0f) + { + return false; + } + + vf = vf.WithElement(2, -1f); + if (vf.GetElement(2) != -1.0f) + { + return false; + } + + vf = vf.WithElement(3, -1.0f); + if (vf.GetElement(3) != -1.0f) + { + return false; + } + + return true; + } + + public static bool Test256() + { + Vector256<short> vs = Vector256<short>.Zero; + vs = vs.WithElement(0, -1); + if (vs.GetElement(0) != -1) + { + return false; + } + + vs = vs.WithElement(3, -1); + if (vs.GetElement(3) != -1) + { + return false; + } + + vs = vs.WithElement(9, -1); + if (vs.GetElement(9) != -1) + { + return false; + } + + + Vector256<ushort> vus = Vector256<ushort>.Zero; + vus = vus.WithElement(0, ushort.MaxValue); + if (vus.GetElement(0) != ushort.MaxValue) + { + return false; + } + + vus = vus.WithElement(3, ushort.MaxValue); + if (vus.GetElement(3) != ushort.MaxValue) + { + return false; + } + + vus = vus.WithElement(8, ushort.MaxValue); + if (vus.GetElement(8) != ushort.MaxValue) + { + return false; + } + + + Vector256<sbyte> vsb = Vector256<sbyte>.Zero; + vsb = vsb.WithElement(0, -1); + if (vsb.GetElement(0) != -1) + { + return false; + } + + vsb = vsb.WithElement(7, -1); + if (vsb.GetElement(7) != -1) + { + return false; + } + + vsb = vsb.WithElement(16, -1); + if (vsb.GetElement(16) != -1) + { + return false; + } + + Vector256<byte> vb = Vector256<byte>.Zero; + vb = vb.WithElement(0, byte.MaxValue); + if (vb.GetElement(0) != byte.MaxValue) + { + return false; + } + + vb = vb.WithElement(7, byte.MaxValue); + if (vb.GetElement(7) != byte.MaxValue) + { + return false; + } + + vb = vb.WithElement(17, byte.MaxValue); + if (vb.GetElement(17) != byte.MaxValue) + { + return false; + } + + return true; + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17957/GitHub_17957_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17957/GitHub_17957_r.csproj new file mode 100644 index 0000000000..ae0490aea3 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17957/GitHub_17957_r.csproj @@ -0,0 +1,34 @@ +<?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> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + <DebugType>Embedded</DebugType> + <Optimize></Optimize> + </PropertyGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <Compile Include="GitHub_17957.cs" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup> +</Project> diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17957/GitHub_17957_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17957/GitHub_17957_ro.csproj new file mode 100644 index 0000000000..3995aa777d --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17957/GitHub_17957_ro.csproj @@ -0,0 +1,34 @@ +<?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> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + <DebugType>Embedded</DebugType> + <Optimize>True</Optimize> + </PropertyGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <Compile Include="GitHub_17957.cs" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup> +</Project> |