Skip to content

Commit

Permalink
[release/7.0] Use the regType for extracting the RegisterType (#74670)
Browse files Browse the repository at this point in the history
* Use the regType for extracting the RegisterType

* Add test case

Co-authored-by: Kunal Pathak <Kunal.Pathak@microsoft.com>
  • Loading branch information
github-actions[bot] and kunalspathak committed Aug 28, 2022
1 parent 105d76c commit edb7234
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/coreclr/jit/lsrabuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3524,11 +3524,11 @@ int LinearScan::BuildStoreLoc(GenTreeLclVarCommon* storeLoc)
else if (op1->isContained() && op1->OperIs(GT_BITCAST))
{
GenTree* bitCastSrc = op1->gtGetOp1();
RegisterType registerType = bitCastSrc->TypeGet();
RegisterType registerType = regType(bitCastSrc->TypeGet());
singleUseRef = BuildUse(bitCastSrc, allRegs(registerType));

Interval* srcInterval = singleUseRef->getInterval();
assert(srcInterval->registerType == registerType);
assert(regType(srcInterval->registerType) == registerType);
srcCount = 1;
}
#ifndef TARGET_64BIT
Expand Down
29 changes: 29 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_74373/Runtime_73821.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;
using System.Runtime.InteropServices;

public class _74373
{
public static int Main(string[] args)
{
Problem(10);
return 100;
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static unsafe float Problem(long x)
{
var y = BitConverter.Int32BitsToSingle((int)x);
Use(&x);
JitUse(0);
return y;
}

public static unsafe void Use(long* arg) { }

[MethodImpl(MethodImplOptions.NoInlining)]
public static void JitUse<T>(T arg) { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Optimize>True</Optimize>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>

0 comments on commit edb7234

Please sign in to comment.