Skip to content

Commit

Permalink
Do not consider single-reg bitcasts multi-reg nodes (#72020)
Browse files Browse the repository at this point in the history
* Fix an ARM codegen bug

* Do not consider single-reg bitcasts multi-reg nodes

* Add a test
  • Loading branch information
SingleAccretion authored Jul 18, 2022
1 parent f025132 commit 4cbe6f9
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 12 deletions.
15 changes: 5 additions & 10 deletions src/coreclr/jit/codegenarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ void CodeGen::genCodeForStoreLclFld(GenTreeLclFld* tree)

GenTree* data = tree->gtOp1;
regNumber dataReg = REG_NA;
genConsumeReg(data);
genConsumeRegs(data);

if (data->isContained())
{
Expand Down Expand Up @@ -1073,18 +1073,13 @@ void CodeGen::genCodeForStoreLclVar(GenTreeLclVar* tree)
{
GenTree* data = tree->gtOp1;
GenTree* actualData = data->gtSkipReloadOrCopy();
unsigned regCount = 1;
// var = call, where call returns a multi-reg return value
// case is handled separately.

// Stores from a multi-reg source are handled separately.
if (actualData->IsMultiRegNode())
{
regCount = actualData->GetMultiRegCount(compiler);
if (regCount > 1)
{
genMultiRegStoreToLocal(tree);
}
genMultiRegStoreToLocal(tree);
}
if (regCount == 1)
else
{
unsigned varNum = tree->GetLclNum();
LclVarDsc* varDsc = compiler->lvaGetDesc(varNum);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ bool GenTree::IsMultiRegNode() const
#if !defined(TARGET_64BIT)
if (OperIsMultiRegOp())
{
return true;
return AsMultiRegOp()->GetRegCount() > 1;
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lsrabuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3492,7 +3492,7 @@ int LinearScan::BuildStoreLoc(GenTreeLclVarCommon* storeLoc)

// Second, use source registers.

if (op1->IsMultiRegNode() && (op1->GetMultiRegCount(compiler) > 1))
if (op1->IsMultiRegNode())
{
// This is the case where the source produces multiple registers.
// This must be a store lclvar.
Expand Down
29 changes: 29 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_71831/Runtime_71831.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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.Runtime.CompilerServices;

unsafe class Runtime_71831
{
private static int Main()
{
return Problem(100) ? 101 : 100;
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static bool Problem(int i)
{
StructWithFloats s = default;

s.FloatOne = BitConverter.Int32BitsToSingle(i);

return s.FloatOne != *(float*)&i;
}

struct StructWithFloats
{
public float FloatOne;
public float FloatTwo;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Optimize>True</Optimize>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CLRTestBatchPreCommands><![CDATA[
$(CLRTestBatchPreCommands)
set DOTNET_JitNoStructPromotion=1
]]></CLRTestBatchPreCommands>
<BashCLRTestPreCommands><![CDATA[
$(BashCLRTestPreCommands)
export DOTNET_JitNoStructPromotion=1
]]></BashCLRTestPreCommands>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>

0 comments on commit 4cbe6f9

Please sign in to comment.