Skip to content

Commit 4cbe6f9

Browse files
Do not consider single-reg bitcasts multi-reg nodes (#72020)
* Fix an ARM codegen bug * Do not consider single-reg bitcasts multi-reg nodes * Add a test
1 parent f025132 commit 4cbe6f9

File tree

5 files changed

+54
-12
lines changed

5 files changed

+54
-12
lines changed

src/coreclr/jit/codegenarm.cpp

+5-10
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ void CodeGen::genCodeForStoreLclFld(GenTreeLclFld* tree)
10141014

10151015
GenTree* data = tree->gtOp1;
10161016
regNumber dataReg = REG_NA;
1017-
genConsumeReg(data);
1017+
genConsumeRegs(data);
10181018

10191019
if (data->isContained())
10201020
{
@@ -1073,18 +1073,13 @@ void CodeGen::genCodeForStoreLclVar(GenTreeLclVar* tree)
10731073
{
10741074
GenTree* data = tree->gtOp1;
10751075
GenTree* actualData = data->gtSkipReloadOrCopy();
1076-
unsigned regCount = 1;
1077-
// var = call, where call returns a multi-reg return value
1078-
// case is handled separately.
1076+
1077+
// Stores from a multi-reg source are handled separately.
10791078
if (actualData->IsMultiRegNode())
10801079
{
1081-
regCount = actualData->GetMultiRegCount(compiler);
1082-
if (regCount > 1)
1083-
{
1084-
genMultiRegStoreToLocal(tree);
1085-
}
1080+
genMultiRegStoreToLocal(tree);
10861081
}
1087-
if (regCount == 1)
1082+
else
10881083
{
10891084
unsigned varNum = tree->GetLclNum();
10901085
LclVarDsc* varDsc = compiler->lvaGetDesc(varNum);

src/coreclr/jit/gentree.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ bool GenTree::IsMultiRegNode() const
812812
#if !defined(TARGET_64BIT)
813813
if (OperIsMultiRegOp())
814814
{
815-
return true;
815+
return AsMultiRegOp()->GetRegCount() > 1;
816816
}
817817
#endif
818818

src/coreclr/jit/lsrabuild.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3492,7 +3492,7 @@ int LinearScan::BuildStoreLoc(GenTreeLclVarCommon* storeLoc)
34923492

34933493
// Second, use source registers.
34943494

3495-
if (op1->IsMultiRegNode() && (op1->GetMultiRegCount(compiler) > 1))
3495+
if (op1->IsMultiRegNode())
34963496
{
34973497
// This is the case where the source produces multiple registers.
34983498
// This must be a store lclvar.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
4+
using System;
5+
using System.Runtime.CompilerServices;
6+
7+
unsafe class Runtime_71831
8+
{
9+
private static int Main()
10+
{
11+
return Problem(100) ? 101 : 100;
12+
}
13+
14+
[MethodImpl(MethodImplOptions.NoInlining)]
15+
private static bool Problem(int i)
16+
{
17+
StructWithFloats s = default;
18+
19+
s.FloatOne = BitConverter.Int32BitsToSingle(i);
20+
21+
return s.FloatOne != *(float*)&i;
22+
}
23+
24+
struct StructWithFloats
25+
{
26+
public float FloatOne;
27+
public float FloatTwo;
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<Optimize>True</Optimize>
5+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
6+
<CLRTestBatchPreCommands><![CDATA[
7+
$(CLRTestBatchPreCommands)
8+
set DOTNET_JitNoStructPromotion=1
9+
]]></CLRTestBatchPreCommands>
10+
<BashCLRTestPreCommands><![CDATA[
11+
$(BashCLRTestPreCommands)
12+
export DOTNET_JitNoStructPromotion=1
13+
]]></BashCLRTestPreCommands>
14+
</PropertyGroup>
15+
<ItemGroup>
16+
<Compile Include="$(MSBuildProjectName).cs" />
17+
</ItemGroup>
18+
</Project>

0 commit comments

Comments
 (0)