dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.15k stars 4.71k forks source link

JIT: Assertion failed '!op2->isUsedFromReg() || (op2->GetRegNum() != targetReg) || (op1Reg == targetReg)' during 'Generate code' #108601

Open amanasifkhalid opened 1 week ago

amanasifkhalid commented 1 week ago
// Generated by Fuzzlyn v2.4 on 2024-10-05 15:32:20
// Run on X86 Windows
// Seed: 509538382640121964-vectort,vector128,vector256,x86aes,x86avx,x86avx2,x86avx512bw,x86avx512bwvl,x86avx512cd,x86avx512cdvl,x86avx512dq,x86avx512dqvl,x86avx512f,x86avx512fvl,x86bmi1,x86bmi2,x86fma,x86lzcnt,x86pclmulqdq,x86popcnt,x86sse,x86sse2,x86sse3,x86sse41,x86sse42,x86ssse3,x86x86base
// Reduced from 15.0 KiB to 0.7 KiB in 00:01:47
// Hits JIT assert in Release:
// Assertion failed '!op2->isUsedFromReg() || (op2->GetRegNum() != targetReg) || (op1Reg == targetReg)' in 'Program:Main(Fuzzlyn.ExecutionServer.IRuntime)' during 'Generate code' (IL size 99; hash 0xade6b36b; FullOpts)
// 
//     File: D:\a\_work\1\s\src\coreclr\jit\hwintrinsiccodegenxarch.cpp Line: 2243
// 
using System;
using System.Numerics;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;

public class Program
{
    public static IRuntime s_rt;
    public static float s_2;
    public static void Main()
    {
        byte[][] vr3 = new byte[][]
        {
            new byte[]
            {
                0
            }
        };
        vr3[0][0]++;
        var vr4 = vr3[0][0];
        s_2 = Sse42.Crc32(vr4, vr3[0][0]);
        bool vr5 = vr3[0][0] != 0;
        s_rt.WriteLine(vr3[0][0]);
        s_rt.WriteLine(vr5);
    }
}

public interface IRuntime
{
    void WriteLine<T>(T value);
}

public class Runtime : IRuntime
{
    public void WriteLine<T>(T value) => System.Console.WriteLine(value);
}

cc @dotnet/jit-contrib

dotnet-policy-service[bot] commented 1 week ago

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch See info in area-owners.md if you want to be subscribed.

JulieLeeMSFT commented 1 week ago

@jakobbotsch PTAL.

jakobbotsch commented 1 week ago

This assert is harmless in release; the situation happens only when both operands are the same local and a copy was added on top of one of them, in which case the overwriting the assert is guarding against is ok. The logic for the more common RMW nodes (like GT_SUB) has similar provisions in its assert. Going to move this to .NET 10.