Skip to content

Commit

Permalink
[release/9.0] Track that kmov instructions may write to GPR register (#…
Browse files Browse the repository at this point in the history
…107476)

* kmov*_gpr writes to gpr

* add test

* Add using

---------

Co-authored-by: Kunal Pathak <Kunal.Pathak@microsoft.com>
Co-authored-by: Jeff Schwartz <jeffschw@microsoft.com>
  • Loading branch information
3 people authored Sep 11, 2024
1 parent cd064dd commit b2d53cc
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2789,7 +2789,14 @@ bool emitter::emitInsCanOnlyWriteSSE2OrAVXReg(instrDesc* id)
// These SSE instructions write to a general purpose integer register.
return false;
}

case INS_kmovb_gpr:
case INS_kmovw_gpr:
case INS_kmovd_gpr:
case INS_kmovq_gpr:
{
// These kmov writes to a general purpose integer register
return !isGeneralRegister(id->idReg1());
}
default:
{
return true;
Expand Down
35 changes: 35 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_106545/Runtime_106545.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

/*
Found by Fuzzlyn
Assertion failed '(emitThisGCrefRegs & regMask) == 0' in 'TestClass:Method4(short,System.Runtime.Intrinsics.Vector512`1[long],byref,short,byref,byref,TestClass+S1,byref):byte:this' during 'Emit code' (IL size 47; hash 0x0a275b75; FullOpts)
File: D:\a\_work\1\s\src\coreclr\jit\emitxarch.cpp Line: 1498
*/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using Xunit;

public class Runtime_106545
{
Vector512<byte> v512_byte_97 = Vector512.CreateScalar((byte)1);

public ulong Method0()
{
v512_byte_97 = Vector512<byte>.AllBitsSet;
return (0 - Vector512.ExtractMostSignificantBits(v512_byte_97));
}

[Fact]
public static void TestEntryPoint()
{
if (Avx2.IsSupported)
{
new Runtime_106545().Method0();
}
}
}
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 b2d53cc

Please sign in to comment.