summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarol Eidt <carol.eidt@microsoft.com>2019-01-10 13:39:26 -0800
committerGitHub <noreply@github.com>2019-01-10 13:39:26 -0800
commit9fa4f2226c687317981f30eb1f49b82371c80bd6 (patch)
tree65c2b916b38f578051bc5bdc0a1ebe8f52a2daff /tests
parentc37ac0eaa8d26ecf06b86b825e713316897ff470 (diff)
parent80566c08ddc93fa6af2e673f0a72eb070346ed4f (diff)
downloadcoreclr-9fa4f2226c687317981f30eb1f49b82371c80bd6.tar.gz
coreclr-9fa4f2226c687317981f30eb1f49b82371c80bd6.tar.bz2
coreclr-9fa4f2226c687317981f30eb1f49b82371c80bd6.zip
Merge pull request #21864 from fiigii/fixscalarmem
Fix CRC32 instruction encoding on containment form
Diffstat (limited to 'tests')
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_21666/GitHub_21666.cs271
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_21666/GitHub_21666_r.csproj34
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_21666/GitHub_21666_ro.csproj34
3 files changed, 339 insertions, 0 deletions
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_21666/GitHub_21666.cs b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_21666/GitHub_21666.cs
new file mode 100644
index 0000000000..fa436ae7e0
--- /dev/null
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_21666/GitHub_21666.cs
@@ -0,0 +1,271 @@
+using System;
+using System.Runtime.Intrinsics.X86;
+using System.Runtime.Intrinsics;
+
+namespace GitHub_21666
+{
+ // CRC32 is a special instruction that has 4-byte opcode but does not use SSE38 or SSE3A encoding,
+ // so the compiler backend needs to specially check its code size.
+ // Test LZCNT as well to ensure that future changes do not impact 3-byte opcode instructions.
+ class GitHub_21666
+ {
+ const int Pass = 100;
+ const int Fail = 0;
+
+ static byte byteSF = 1;
+ static ushort ushortSF = 1;
+ static uint uintSF = 1;
+ static ulong ulongSF = 1;
+
+ readonly static byte[] byteArray = new byte[10];
+ readonly static ushort[] ushortArray = new ushort[10];
+ readonly static uint[] uintArray = new uint[10];
+ readonly static ulong[] ulongArray = new ulong[10];
+
+ static int Main(string[] args)
+ {
+ bool sucess = true;
+ byteSF = 0;
+ ushortSF = 0;
+ uintSF = 0;
+ ulongSF = 0;
+ sucess = sucess && TestByteContainment();
+ sucess = sucess && TestUInt16Containment();
+ sucess = sucess && TestUInt32Containment();
+ sucess = sucess && TestUInt64Containment();
+
+ return sucess ? Pass : Fail;
+ }
+
+ static unsafe bool TestByteContainment()
+ {
+ byte value = (byte)0;
+ byte* ptr = &value;
+ if (Sse42.IsSupported)
+ {
+ if (Sse42.Crc32(0xffffffffU, (byte)0) != 0xad82acaeU)
+ {
+ Console.WriteLine("TestByteContainment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, value) != 0xad82acaeU)
+ {
+ Console.WriteLine("TestByteContainment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, *ptr) != 0xad82acaeU)
+ {
+ Console.WriteLine("TestByteContainment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, byteArray[1]) != 0xad82acaeU)
+ {
+ Console.WriteLine("TestByteContainment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, byteArray[*ptr + 1]) != 0xad82acaeU)
+ {
+ Console.WriteLine("TestByteContainment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, byteSF) != 0xad82acaeU)
+ {
+ Console.WriteLine("TestByteContainment failed on Crc32");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ static unsafe bool TestUInt16Containment()
+ {
+ ushort value = (ushort)0;
+ ushort* ptr = &value;
+ if (Sse42.IsSupported)
+ {
+ if (Sse42.Crc32(0xffffffffU, (ushort)0) != 0xe9e882dU)
+ {
+ Console.WriteLine("TestUInt16Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, value) != 0xe9e882dU)
+ {
+ Console.WriteLine("TestUInt16Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, *ptr) != 0xe9e882dU)
+ {
+ Console.WriteLine("TestUInt16Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, ushortArray[1]) != 0xe9e882dU)
+ {
+ Console.WriteLine("TestUInt16Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, ushortArray[*ptr + 1]) != 0xe9e882dU)
+ {
+ Console.WriteLine("TestUInt16Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, ushortSF) != 0xe9e882dU)
+ {
+ Console.WriteLine("TestUInt16Containment failed on Crc32");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ static unsafe bool TestUInt32Containment()
+ {
+ uint value = (uint)0;
+ uint* ptr = &value;
+ if (Lzcnt.IsSupported)
+ {
+ if (Lzcnt.LeadingZeroCount(*ptr) != 32)
+ {
+ Console.WriteLine("TestUInt32Containment failed on LeadingZeroCount");
+ return false;
+ }
+
+ if (Lzcnt.LeadingZeroCount(uintArray[2]) != 32)
+ {
+ Console.WriteLine("TestUInt32Containment failed on LeadingZeroCount");
+ return false;
+ }
+
+ if (Lzcnt.LeadingZeroCount(uintArray[*ptr + 2]) != 32)
+ {
+ Console.WriteLine("TestUInt32Containment failed on LeadingZeroCount");
+ return false;
+ }
+
+ }
+
+ uint* ptr1 = &value;
+ if (Sse42.IsSupported)
+ {
+ if (Sse42.Crc32(0xffffffffU, (uint)0) != 0xb798b438U)
+ {
+ Console.WriteLine("TestUInt32Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, value) != 0xb798b438U)
+ {
+ Console.WriteLine("TestUInt32Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, *ptr1) != 0xb798b438U)
+ {
+ Console.WriteLine("TestUInt32Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, uintArray[1]) != 0xb798b438U)
+ {
+ Console.WriteLine("TestUInt32Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, uintArray[*ptr + 1]) != 0xb798b438U)
+ {
+ Console.WriteLine("TestUInt32Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.Crc32(0xffffffffU, uintSF) != 0xb798b438U)
+ {
+ Console.WriteLine("TestUInt32Containment failed on Crc32");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ static unsafe bool TestUInt64Containment()
+ {
+ ulong value = (ulong)0;
+ ulong* ptr = &value;
+ if (Lzcnt.X64.IsSupported)
+ {
+ if (Lzcnt.X64.LeadingZeroCount(*ptr) != 64)
+ {
+ Console.WriteLine("TestUInt64Containment failed on LeadingZeroCount");
+ return false;
+ }
+
+ if (Lzcnt.X64.LeadingZeroCount(ulongArray[2]) != 64)
+ {
+ Console.WriteLine("TestUInt64Containment failed on LeadingZeroCount");
+ return false;
+ }
+
+ if (Lzcnt.X64.LeadingZeroCount(ulongArray[*ptr + 2]) != 64)
+ {
+ Console.WriteLine("TestUInt64Containment failed on LeadingZeroCount");
+ return false;
+ }
+
+ }
+
+ ulong* ptr1 = &value;
+
+ if (Sse42.X64.IsSupported)
+ {
+ if (Sse42.X64.Crc32(0xffffffffffffffffUL, 0) != 0x0000000073d74d75UL)
+ {
+ Console.WriteLine("TestUInt64Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.X64.Crc32(0xffffffffffffffffUL, value) != 0x0000000073d74d75UL)
+ {
+ Console.WriteLine("TestUInt64Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.X64.Crc32(0xffffffffffffffffUL, *ptr1) != 0x0000000073d74d75UL)
+ {
+ Console.WriteLine("TestUInt64Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.X64.Crc32(0xffffffffffffffffUL, ulongArray[1]) != 0x0000000073d74d75UL)
+ {
+ Console.WriteLine("TestUInt64Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.X64.Crc32(0xffffffffffffffffUL, ulongArray[*ptr + 1]) != 0x0000000073d74d75UL)
+ {
+ Console.WriteLine("TestUInt64Containment failed on Crc32");
+ return false;
+ }
+
+ if (Sse42.X64.Crc32(0xffffffffffffffffUL, ulongSF) != 0x0000000073d74d75UL)
+ {
+ Console.WriteLine("TestUInt64Containment failed on Crc32");
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_21666/GitHub_21666_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_21666/GitHub_21666_r.csproj
new file mode 100644
index 0000000000..23540a7600
--- /dev/null
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_21666/GitHub_21666_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_21666.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_21666/GitHub_21666_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_21666/GitHub_21666_ro.csproj
new file mode 100644
index 0000000000..4d46fc1bb8
--- /dev/null
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_21666/GitHub_21666_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_21666.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>