Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lowering usage of an unset LSRA field. #54731

Merged
merged 5 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3098,22 +3098,17 @@ void Lowering::LowerStoreLocCommon(GenTreeLclVarCommon* lclStore)
}
}

if ((varTypeUsesFloatReg(lclStore) != varTypeUsesFloatReg(src)) && !lclStore->IsPhiDefn() &&
(src->TypeGet() != TYP_STRUCT))
{
if (m_lsra->isRegCandidate(varDsc))
{
GenTree* bitcast = comp->gtNewBitCastNode(lclStore->TypeGet(), src);
lclStore->gtOp1 = bitcast;
src = lclStore->gtGetOp1();
BlockRange().InsertBefore(lclStore, bitcast);
ContainCheckBitCast(bitcast);
}
else
{
// This is an actual store, we'll just retype it.
lclStore->gtType = src->TypeGet();
}
// TODO-CQ: the condition could be improved for the struct types, for example,
// /--* CALL simd8 hackishModuleName.hackishMethodName
// * STORE_LCL_VAR struct<HVA64_01[Byte], 8> V03 tmp1
// does not need a bitcast because the struct enreg type is SIMD8.
if ((varTypeUsesFloatReg(lclStore) != varTypeUsesFloatReg(src)) && !src->TypeIs(TYP_STRUCT))
{
GenTree* bitcast = comp->gtNewBitCastNode(lclStore->TypeGet(), src);
lclStore->gtOp1 = bitcast;
src = lclStore->gtGetOp1();
BlockRange().InsertBefore(lclStore, bitcast);
ContainCheckBitCast(bitcast);
}

if (srcIsMultiReg || lclStore->IsMultiRegLclVar())
Expand Down Expand Up @@ -6571,8 +6566,10 @@ void Lowering::ContainCheckBitCast(GenTree* node)
{
op1->SetContained();
}
LclVarDsc* varDsc = &comp->lvaTable[op1->AsLclVar()->GetLclNum()];
if (!m_lsra->isRegCandidate(varDsc))
const LclVarDsc* varDsc = comp->lvaGetDesc(op1->AsLclVar());
// TODO-Cleanup: we want to check if the local is already known not
// to be on reg, for example, because local enreg is disabled.
if (varDsc->lvDoNotEnregister)
{
op1->SetContained();
}
Expand Down
32 changes: 32 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_54466/Runtime_54466.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Numerics;
using System.Runtime.CompilerServices;

namespace Runtime_54466
{
public class Test
{
static int Main()
{
return t(1, 1, 1, 1, Vector2.One, Vector2.One, Vector2.One, Vector2.One);
}


[MethodImplAttribute(MethodImplOptions.NoInlining)]
static int t(int a1, int a2, int a3, int a4, Vector2 x1, Vector2 x2, Vector2 x3, Vector2 x4)
{
if (x1 != Vector2.One)
{
Console.WriteLine("FAIL");
return 101;
}
return 100;
}
}

}


Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>