Skip to content

Commit

Permalink
JIT: Fix containment of extract intrinsics as STOREIND sources (dotne…
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbotsch authored Sep 26, 2023
1 parent b417004 commit 0311aa8
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/coreclr/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6568,7 +6568,8 @@ void Lowering::ContainCheckStoreIndir(GenTreeStoreInd* node)
size_t numArgs = hwintrinsic->GetOperandCount();
GenTree* lastOp = hwintrinsic->Op(numArgs);

isContainable = HWIntrinsicInfo::isImmOp(intrinsicId, lastOp) && lastOp->IsCnsIntOrI();
isContainable = HWIntrinsicInfo::isImmOp(intrinsicId, lastOp) && lastOp->IsCnsIntOrI() &&
(genTypeSize(simdBaseType) == genTypeSize(node));

if (isContainable && (intrinsicId == NI_SSE2_Extract))
{
Expand Down
63 changes: 63 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_92590/Runtime_92590.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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 Xunit;

public class Runtime_92590
{
[Fact]
public static void TestEntryPoint()
{
Span<byte> bytes = stackalloc byte[4];
bytes.Fill(0xff);
TestByteByte(ref bytes[0], 0, Vector256.Create((byte)1));

Assert.True(bytes.SequenceEqual(stackalloc byte[] { 0x2, 0xff, 0xff, 0xff }));

bytes.Fill(0xff);
TestByteInt(ref bytes[0], 0, Vector256.Create(1));

Assert.True(bytes.SequenceEqual(stackalloc byte[] { 0x2, 0xff, 0xff, 0xff }));

int i = int.MaxValue;
TestIntByte(ref i, 0, Vector256.Create((byte)1));

Assert.Equal(2, i);

i = int.MaxValue;
TestIntInt(ref i, 0, Vector256.Create(1));

Assert.Equal(2, i);
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static void TestByteByte(ref byte b, int x, Vector256<byte> vin)
{
Vector256<byte> v = vin + vin;
Unsafe.Add(ref b, x) = v[3];
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static void TestByteInt(ref byte b, int x, Vector256<int> vin)
{
Vector256<int> v = vin + vin;
Unsafe.Add(ref b, x) = (byte)v[3];
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static void TestIntByte(ref int b, int x, Vector256<byte> vin)
{
Vector256<byte> v = vin + vin;
Unsafe.Add(ref b, x) = v[3];
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static void TestIntInt(ref int b, int x, Vector256<int> vin)
{
Vector256<int> v = vin + vin;
Unsafe.Add(ref b, x) = v[3];
}
}
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 0311aa8

Please sign in to comment.