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

[release/8.0] JIT: add missing xarch RMW case #92293

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5485,6 +5485,13 @@ void emitter::emitInsRMW(instruction ins, emitAttr attr, GenTreeStoreInd* storeI
{
assert(!src->isContained()); // there must be one non-contained src

if (addr->isContained() && addr->OperIs(GT_LCL_ADDR))
{
GenTreeLclVarCommon* lclVar = addr->AsLclVarCommon();
emitIns_S_R(ins, attr, src->GetRegNum(), lclVar->GetLclNum(), lclVar->GetLclOffs());
return;
}

// ind, reg
id = emitNewInstrAmd(attr, offset);
emitHandleMemOp(storeInd, id, emitInsModeFormat(ins, IF_ARD_RRD), ins);
Expand Down
40 changes: 40 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_92218/Runtime_92218.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 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.Threading;
using Xunit;

public struct MutableStruct
{
private long _internalValue;

public long InternalValue
{
get => Volatile.Read(ref _internalValue);
private set => Volatile.Write(ref _internalValue, value);
}

public void Add(long value) => AddInternal(value);
private void AddInternal(long value) => InternalValue += value;
public MutableStruct(long value) => InternalValue = value;
}

public static class Runtime_92218
{
[Fact]
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static void Problem()
{
var test = new MutableStruct(420);
var from = new MutableStruct(42);

var wrapper = -new TimeSpan(3);

while (test.InternalValue >= from.InternalValue)
{
test.Add(wrapper.Ticks);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>