Skip to content

JIT: Assertion failed '!(checkUnusedValues && def->IsUnusedValue()) && "operands should never be marked as unused values"' during 'Lowering nodeinfo' #106480

Closed
@amanasifkhalid

Description

@amanasifkhalid

On windows x64:

// Found by Antigen
// Reduced from 339 KB to 5.65 KB.


using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;
using System.Numerics;
public class TestClass
{
    public struct S2
    {
    }
    static char s_char_4 = 'F';
    static int s_int_8 = -5;
    static sbyte s_sbyte_10 = 0;
    static Vector512<sbyte> s_v512_sbyte_38 = Vector512.Create(-2, -5, 1, 0, -1, 1, 0, 6, 0, 0, 0, 1, -2, 0, 5, 6, -2, -8, -1, -1, 0, 2, 26, -1, 5, 2, 0, -1, -1, 1, -7, -5, -2, 0, 0, 5, 0, -1, 0, -1, 0, 26, -5, -5, -7, -5, -5, 26, -1, -5, 2, 26, 1, 0, -7, -1, -5, -5, -1, -5, 0, -2, -1, -5);
    static S2 s_s2_61 = new S2();
    char char_64 = '9';
    Vector512<sbyte> v512_sbyte_98 = Vector512.Create((sbyte)2);
    static int s_loopInvariant = 9;
    private static List<string> toPrint = new List<string>();
    public sbyte Method1(S2 p_s2_122, ref S2 p_s2_123)
    {
        unchecked
        {
            byte byte_125 = 5;
            switch (s_int_8 <<= 15^4)
            {
                case -5:
                {
                    int __loopvar16 = s_loopInvariant;
                    for (; s_int_8 < 15+4; __loopvar16 -= 3, char_64 = char_64 = s_char_4 = char_64 = s_char_4)
                    {
                        for (;;)
                        {
                            switch (char_64)
                            {
                                case '8':
                                {
                                    break;
                                }
                                case 'L':
                                {
                                    break;
                                }
                                case 'K':
                                {
                                    break;
                                }
                                case 'C':
                                {
                                    break;
                                }
                                case 'O':
                                {
                                    break;
                                }
                                case 'Q':
                                {
                                    break;
                                }
                                case 'D':
                                {
                                    switch (15/4)
                                    {
                                        case -5:
                                        {
                                            break;
                                        }
                                        case -1:
                                        {
                                            break;
                                        }
                                        case 0:
                                        {
                                            break;
                                        }
                                        case 1:
                                        {
                                            break;
                                        }
                                        case 5:
                                        {
                                            break;
                                        }
                                        case -2:
                                        {
                                            break;
                                        }
                                        case -2147483648:
                                        {
                                            break;
                                        }
                                        default:
                                        {
                                            for (;;)
                                            {
                                                try
                                                {
                                                    v512_sbyte_98 += s_v512_sbyte_38 ^ s_v512_sbyte_38 + s_v512_sbyte_38& Avx512F.TernaryLogic(s_v512_sbyte_38, v512_sbyte_98, Vector512<sbyte>.Zero, byte_125);
                                                }
                                                finally
{}
                                            }
                                            break;
                                        }
                                    }
                                    break;
                                }
                                default:
                                {
                                    break;
                                }
                            }
                        }
                    }
                    break;
                }
                case -1:
                {
                    break;
                }
                case 0:
                {
                    break;
                }
                case 2:
                {
                    break;
                }
                case 1:
                {
                    break;
                }
                default:
                {
                    break;
                }
            }
            return 15|4;
        }
    }
    public void Method0()
    {
        unchecked
        {
            s_sbyte_10 = Method1(s_s2_61, ref s_s2_61);
            return;
        }
    }
    public static void Main(string[] args)
    {
    }
    public static int Antigen()
    {
        new TestClass().Method0();
        return string.Join(Environment.NewLine, toPrint).GetHashCode();
    }
}
/*
Environment:

set DOTNET_JitForceControlFlowGuard=1
set DOTNET_JitRandomOnStackReplacement=10
set DOTNET_ReadyToRun=1
set DOTNET_TC_OnStackReplacement=1
set DOTNET_TC_PartialCompilation=1
set DOTNET_TC_QuickJitForLoops=1
set DOTNET_TieredCompilation=0
set DOTNET_JitStress=0
set DOTNET_JitThrowOnAssertionFailure=1
set DOTNET_LegacyExceptionHandling=1

Debug: 1629887734

Release: 0
JIT assert failed:
Assertion failed '!(checkUnusedValues && def->IsUnusedValue()) && "operands should never be marked as unused values"' in 'TestClass:Method1(TestClass+S2,byref):byte:this' during 'Lowering nodeinfo' (IL size 228; hash 0xd9d268b0; FullOpts)

    File: D:\a\_work\1\s\src\coreclr\jit\lir.cpp Line: 1649


*/

Also hit on Windows x86. cc @dotnet/jit-contrib

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions