Skip to content

Commit

Permalink
Merge in 'release/8.0-rc2' changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnet-bot committed Sep 22, 2023
2 parents ad37817 + 873b3cc commit c42a95a
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 10 deletions.
19 changes: 15 additions & 4 deletions src/coreclr/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8202,18 +8202,20 @@ bool Lowering::IsContainableHWIntrinsicOp(GenTreeHWIntrinsic* parentNode, GenTre
case NI_AVX2_BroadcastScalarToVector256:
case NI_AVX512F_BroadcastScalarToVector512:
{
var_types baseType = hwintrinsic->GetSimdBaseType();
if (varTypeIsSmall(baseType))
var_types parentBaseType = parentNode->GetSimdBaseType();
var_types childBaseType = hwintrinsic->GetSimdBaseType();

if (varTypeIsSmall(parentBaseType) || (genTypeSize(parentBaseType) != genTypeSize(childBaseType)))
{
// early return if the base type is not embedded broadcast compatible.
// early return if either base type is not embedded broadcast compatible.
return false;
}

// make the broadcast node containable when embedded broadcast can be enabled.
if (intrinsicId == NI_SSE3_MoveAndDuplicate)
{
// NI_SSE3_MoveAndDuplicate is for Vector128<double> only.
assert(baseType == TYP_DOUBLE);
assert(childBaseType == TYP_DOUBLE);
}

if (comp->compOpportunisticallyDependsOn(InstructionSet_AVX512F_VL) &&
Expand Down Expand Up @@ -8246,6 +8248,15 @@ bool Lowering::IsContainableHWIntrinsicOp(GenTreeHWIntrinsic* parentNode, GenTre
case NI_AVX_BroadcastScalarToVector128:
case NI_AVX_BroadcastScalarToVector256:
{
var_types parentBaseType = parentNode->GetSimdBaseType();
var_types childBaseType = hwintrinsic->GetSimdBaseType();

if (varTypeIsSmall(parentBaseType) || (genTypeSize(parentBaseType) != genTypeSize(childBaseType)))
{
// early return if either base type is not embedded broadcast compatible.
return false;
}

return parentNode->OperIsEmbBroadcastCompatible();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,15 @@ private void SetStopDispatchTask()
{
Debug.Assert(Monitor.IsEntered(m_dispatchControlLock));

if (m_dispatchTask != null)
if (m_dispatchTaskCancellationSource?.IsCancellationRequested ?? true)
{
Debug.Assert(m_dispatchTaskCancellationSource != null);
m_dispatchTaskCancellationSource?.Cancel();
EventPipeInternal.SignalSession(m_sessionID);
return;
}

Debug.Assert(m_sessionID != 0);
m_dispatchTaskCancellationSource.Cancel();
EventPipeInternal.SignalSession(m_sessionID);
m_sessionID = 0;
}

private unsafe void DispatchEventsToEventListeners(ulong sessionID, DateTime syncTimeUtc, long syncTimeQPC, long timeQPCFrequency, Task? previousDispatchTask, CancellationToken token)
Expand Down Expand Up @@ -187,8 +190,12 @@ private unsafe void DispatchEventsToEventListeners(ulong sessionID, DateTime syn
}
}

// Disable the old session. This can happen asynchronously since we aren't using the old session anymore
EventPipeInternal.Disable(sessionID);
lock (m_dispatchControlLock)
{
// Disable the old session. This can happen asynchronously since we aren't using the old session
// anymore. We take the lock to make sure we don't call SignalSession on an invalid session ID.
EventPipeInternal.Disable(sessionID);
}
}

/// <summary>
Expand Down
47 changes: 47 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_92357/Runtime_92357.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// 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.Intrinsics;
using System.Runtime.Intrinsics.X86;
using Xunit;

public static class Runtime_92357
{
[Fact]
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static void Problem()
{
if (!Avx2.IsSupported)
{
return;
}

int y1 = 5;

Vector256<short> actual1 = Test1(Vector256.Create((short)1), ref y1);
Vector256<short> expected1 = Vector256.Create(10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0);

Assert.Equal(expected1, actual1);

long y2 = 5;

Vector256<int> actual2 = Test2(Vector256.Create((int)1), ref y2);
Vector256<int> expected2 = Vector256.Create(10, 0, 10, 0, 10, 0, 10, 0);

Assert.Equal(expected2, actual2);
}

[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
public static Vector256<short> Test1(Vector256<short> x, ref int y)
{
return Avx2.MultiplyLow(x + x, Vector256.Create(y).AsInt16());
}

[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
public static Vector256<int> Test2(Vector256<int> x, ref long y)
{
return Avx2.MultiplyLow(x + x, Vector256.Create(y).AsInt32());
}
}
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>

0 comments on commit c42a95a

Please sign in to comment.