diff options
3 files changed, 98 insertions, 2 deletions
diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp index 3846b2ea7e..d3234036e3 100644 --- a/src/jit/gentree.cpp +++ b/src/jit/gentree.cpp @@ -18252,7 +18252,7 @@ bool GenTreeHWIntrinsic::OperIsMemoryLoad() GenTreeArgList* argList = gtOp.gtOp1->AsArgList(); if ((gtHWIntrinsicId == NI_AVX_InsertVector128 || gtHWIntrinsicId == NI_AVX2_InsertVector128) && - (argList->Current()->TypeGet() == TYP_I_IMPL)) // Is the type of the first arg TYP_I_IMPL? + (argList->Rest()->Current()->TypeGet() == TYP_I_IMPL)) // Is the type of the second arg TYP_I_IMPL? { // This is Avx/Avx2.InsertVector128 return true; @@ -18319,7 +18319,7 @@ bool GenTreeHWIntrinsic::OperIsMemoryLoadOrStore() GenTreeArgList* argList = gtOp.gtOp1->AsArgList(); if ((gtHWIntrinsicId == NI_AVX_InsertVector128 || gtHWIntrinsicId == NI_AVX2_InsertVector128) && - (argList->Current()->TypeGet() == TYP_I_IMPL)) // Is the type of the first arg TYP_I_IMPL? + (argList->Rest()->Current()->TypeGet() == TYP_I_IMPL)) // Is the type of the second arg TYP_I_IMPL? { // This is Avx/Avx2.InsertVector128 return true; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.cs b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.cs new file mode 100644 index 0000000000..bed639c202 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.cs @@ -0,0 +1,62 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace GitHub_17435 +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + + if (Sse2.IsSupported) + { + (uint a, uint b) = Program.Repro(); + if ((a !=3) || (b != 6)) + { + Console.WriteLine($"FAILED {a}, {b}"); + return Fail; + } + else + { + Console.WriteLine("Passed"); + return Pass; + } + } + else + { + Console.WriteLine("SSE2 not supported"); + return Pass; + } + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public unsafe static (uint, uint) Repro() + { + uint* a = stackalloc uint[4]; + a[0] = 1; + a[1] = 1; + a[2] = 1; + a[3] = 1; + + // Here we force populate the registers + var b = a[0]; + var h = a[3]; + var c = a[1]; + + // We operate the values in xmm0 + Vector128<uint> v = Sse2.LoadVector128(a); + v = Sse2.Add(v, v); + // We send to the memory the modified values + Sse2.Store(a, v); + + // We return both sums (from registers and from memory) + return (b + h + c, a[0]+a[1]+a[3]); + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.csproj new file mode 100644 index 0000000000..70fdafb626 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.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>None</DebugType> + <Optimize>True</Optimize> + </PropertyGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <Compile Include="GitHub_17435.cs" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup> +</Project> |