Skip to content
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
23 changes: 20 additions & 3 deletions src/coreclr/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7875,7 +7875,8 @@ void Lowering::ContainCheckStoreIndir(GenTreeStoreInd* node)
// However, we want to prefer containing the store over allowing the
// input to be regOptional, so track and clear containment if required.

clearContainedNode = hwintrinsic->Op(1);
GenTree* op1 = hwintrinsic->Op(1);
clearContainedNode = op1;
isContainable = !clearContainedNode->isContained();

if (isContainable && varTypeIsIntegral(simdBaseType))
Expand All @@ -7887,13 +7888,29 @@ void Lowering::ContainCheckStoreIndir(GenTreeStoreInd* node)
if (isContainable && varTypeIsSmall(simdBaseType))
{
CorInfoType baseJitType = varTypeIsByte(node) ? CORINFO_TYPE_UBYTE : CORINFO_TYPE_USHORT;
intrinsicId = varTypeIsByte(node) ? NI_SSE41_Extract : NI_SSE2_Extract;

if (intrinsicId == NI_Vector512_ToScalar)
{
op1 = comp->gtNewSimdHWIntrinsicNode(TYP_SIMD16, op1, NI_Vector512_GetLower128,
baseJitType, 64);
BlockRange().InsertBefore(hwintrinsic, op1);
LowerNode(op1);
}
else if (intrinsicId == NI_Vector256_ToScalar)
{
op1 = comp->gtNewSimdGetLowerNode(TYP_SIMD16, op1, baseJitType, 32);
BlockRange().InsertBefore(hwintrinsic, op1);
LowerNode(op1);
}

intrinsicId = varTypeIsByte(node) ? NI_SSE41_Extract : NI_SSE2_Extract;

GenTree* zero = comp->gtNewZeroConNode(TYP_INT);
BlockRange().InsertBefore(hwintrinsic, zero);

hwintrinsic->SetSimdBaseJitType(baseJitType);
hwintrinsic->ResetHWIntrinsicId(intrinsicId, hwintrinsic->Op(1), zero);
hwintrinsic->SetSimdSize(16);
hwintrinsic->ResetHWIntrinsicId(intrinsicId, op1, zero);
zero->SetContained();
}
}
Expand Down
38 changes: 38 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_115493/Runtime_115493.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Numerics;
using System.Runtime.CompilerServices;
using Xunit;

public class Runtime_115493
{
[Fact]
public static void Problem()
{
int checksum = 44444;
int exitCode = 100;

[MethodImpl(MethodImplOptions.NoInlining)]
int ProcessValue(object val)
{
return val switch
{
int i => i,
short s => s,
_ => 0
};
}

var a = new Vector<short>(25);
a = Vector.SquareRoot(a);
checksum = unchecked(checksum + ProcessValue(a[0]));
if (a[0] != 5)
{
exitCode = 0;
}

Assert.Equal(44449, checksum);
Assert.Equal(100, exitCode);
}
}
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>
Loading