Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 3800df9

Browse files
authored
Port PR #258 to 3.1 (#27984)
* Port PR #258 to 3.1 * Fix test proj file
1 parent 75d2c46 commit 3800df9

File tree

3 files changed

+81
-6
lines changed

3 files changed

+81
-6
lines changed

src/jit/gentree.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15741,16 +15741,21 @@ unsigned GenTree::IsLclVarUpdateTree(GenTree** pOtherTree, genTreeOps* pOper)
1574115741
if (OperIs(GT_ASG))
1574215742
{
1574315743
GenTree* lhs = gtOp.gtOp1;
15744-
if (lhs->OperGet() == GT_LCL_VAR)
15744+
GenTree* rhs = AsOp()->gtOp2;
15745+
if ((lhs->OperGet() == GT_LCL_VAR) && rhs->OperIsBinary())
1574515746
{
1574615747
unsigned lhsLclNum = lhs->AsLclVarCommon()->gtLclNum;
15747-
GenTree* rhs = gtOp.gtOp2;
15748-
if (rhs->OperIsBinary() && (rhs->gtOp.gtOp1->gtOper == GT_LCL_VAR) &&
15749-
(rhs->gtOp.gtOp1->AsLclVarCommon()->gtLclNum == lhsLclNum))
15748+
GenTree* rhsOp1 = rhs->AsOp()->gtOp1;
15749+
GenTree* rhsOp2 = rhs->AsOp()->gtOp2;
15750+
15751+
// Some operators, such as HWINTRINSIC, are currently declared as binary but
15752+
// may not have two operands. We must check that both operands actually exist.
15753+
if ((rhsOp1 != nullptr) && (rhsOp2 != nullptr) && (rhsOp1->OperGet() == GT_LCL_VAR) &&
15754+
(rhsOp1->AsLclVarCommon()->GetLclNum() == lhsLclNum))
1575015755
{
1575115756
lclNum = lhsLclNum;
15752-
*pOtherTree = rhs->gtOp.gtOp2;
15753-
*pOper = rhs->gtOper;
15757+
*pOtherTree = rhsOp2;
15758+
*pOper = rhs->OperGet();
1575415759
}
1575515760
}
1575615761
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{CBD0D777-3583-49CC-8538-DD84447F6522}</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
11+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
12+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
13+
<CLRTestKind>BuildAndRun</CLRTestKind>
14+
<CLRTestPriority>1</CLRTestPriority>
15+
<DebugType>None</DebugType>
16+
<Optimize>True</Optimize>
17+
</PropertyGroup>
18+
<!-- Default configurations to help VS understand the configurations -->
19+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
21+
<ItemGroup>
22+
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
23+
<Visible>False</Visible>
24+
</CodeAnalysisDependentAssemblyPaths>
25+
</ItemGroup>
26+
<ItemGroup>
27+
<!-- Add Compile Object Here -->
28+
<Compile Include="test27937.cs" />
29+
</ItemGroup>
30+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
31+
</Project>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
using System.Runtime.Intrinsics;
5+
6+
class Test27937
7+
{
8+
static unsafe void calc(float* fa, float* fb)
9+
{
10+
float* pb = fb;
11+
float* eb = pb + 16;
12+
13+
do
14+
{
15+
float* pa = fa;
16+
float* ea = pa + 16;
17+
var va = Vector128<float>.Zero;
18+
19+
do
20+
{
21+
*pa = va.ToScalar();
22+
23+
pa += Vector128<float>.Count;
24+
pb += Vector128<float>.Count;
25+
} while (pa < ea);
26+
27+
} while (pb < eb);
28+
}
29+
30+
static unsafe int Main()
31+
{
32+
float* a = stackalloc float[16];
33+
float* b = stackalloc float[16];
34+
35+
calc(a, b);
36+
37+
return 100;
38+
}
39+
}

0 commit comments

Comments
 (0)