Add a test case for PR #9496
authorCarol Eidt <carol.eidt@microsoft.com>
Sat, 11 Feb 2017 01:05:34 +0000 (17:05 -0800)
committerCarol Eidt <carol.eidt@microsoft.com>
Sat, 11 Feb 2017 01:05:34 +0000 (17:05 -0800)
tests/src/JIT/SIMD/Vector3GetHash.cs [new file with mode: 0644]
tests/src/JIT/SIMD/Vector3GetHash_r.csproj [new file with mode: 0644]
tests/src/JIT/SIMD/Vector3GetHash_ro.csproj [new file with mode: 0644]

diff --git a/tests/src/JIT/SIMD/Vector3GetHash.cs b/tests/src/JIT/SIMD/Vector3GetHash.cs
new file mode 100644 (file)
index 0000000..21742e0
--- /dev/null
@@ -0,0 +1,80 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// This was copied from corefx\src\System.Numerics.Vectors\tests\Vector3Tests.cs.
+// It exposed a bug in morph, in which a SIMD field was being morphed in
+// a MACK_Ind context, even though it was under a GT_IND(G_ADDR()).
+// This was corefx issue #15713, and was "fixed" with coreclr PR # 9496,
+// and a new issue, #9518, has been filed to track the underlying unexpected
+// MACK_Ind context, which causes us to mark the Vector3 local as do-not-enregister.
+
+using System;
+using System.Numerics;
+
+internal partial class VectorTest
+{
+    private const int Pass = 100;
+    private const int Fail = -1;
+
+    public class Assert
+    {
+        public static void Equal(float f1, float f2)
+        {
+            if (f1 != f2)
+            {
+                throw new Exception("Assert.Equal failed");
+            }
+        }
+        public static void NotEqual(float f1, float f2)
+        {
+            if (f1 == f2)
+            {
+                throw new Exception("Assert.NotEqual failed");
+            }
+        }
+    }
+    public struct SimpleVector3
+    {
+        public static void Vector3GetHashCodeTest()
+        {
+            Vector3 v1 = new Vector3(2.0f, 3.0f, 3.3f);
+            Vector3 v2 = new Vector3(2.0f, 3.0f, 3.3f);
+            Vector3 v3 = new Vector3(2.0f, 3.0f, 3.3f);
+            Vector3 v5 = new Vector3(3.0f, 2.0f, 3.3f);
+            Assert.Equal(v1.GetHashCode(), v1.GetHashCode());
+            Assert.Equal(v1.GetHashCode(), v2.GetHashCode());
+            Assert.NotEqual(v1.GetHashCode(), v5.GetHashCode());
+            Assert.Equal(v1.GetHashCode(), v3.GetHashCode());
+            Vector3 v4 = new Vector3(0.0f, 0.0f, 0.0f);
+            Vector3 v6 = new Vector3(1.0f, 0.0f, 0.0f);
+            Vector3 v7 = new Vector3(0.0f, 1.0f, 0.0f);
+            Vector3 v8 = new Vector3(1.0f, 1.0f, 1.0f);
+            Vector3 v9 = new Vector3(1.0f, 1.0f, 0.0f);
+            Assert.NotEqual(v4.GetHashCode(), v6.GetHashCode());
+            Assert.NotEqual(v4.GetHashCode(), v7.GetHashCode());
+            Assert.NotEqual(v4.GetHashCode(), v8.GetHashCode());
+            Assert.NotEqual(v7.GetHashCode(), v6.GetHashCode());
+            Assert.NotEqual(v8.GetHashCode(), v6.GetHashCode());
+            Assert.NotEqual(v8.GetHashCode(), v9.GetHashCode());
+            Assert.NotEqual(v7.GetHashCode(), v9.GetHashCode());
+        }
+
+        public static int Main( string[] args )
+        {
+            int returnVal = Pass;
+
+            try
+            {
+                Vector3GetHashCodeTest();
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine("FAILED: " + e.Message);
+                returnVal = Fail;
+            }
+            return returnVal;
+        }
+    }
+}
+
diff --git a/tests/src/JIT/SIMD/Vector3GetHash_r.csproj b/tests/src/JIT/SIMD/Vector3GetHash_r.csproj
new file mode 100644 (file)
index 0000000..183dccf
--- /dev/null
@@ -0,0 +1,46 @@
+<?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' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize></Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Vector3GetHash.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>
diff --git a/tests/src/JIT/SIMD/Vector3GetHash_ro.csproj b/tests/src/JIT/SIMD/Vector3GetHash_ro.csproj
new file mode 100644 (file)
index 0000000..3228f62
--- /dev/null
@@ -0,0 +1,46 @@
+<?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' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Vector3GetHash.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>