Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion failed '!varTypeIsUnsigned(type) || varTypeIsSmall(type)' during 'Generate code' #91174

Closed
kunalspathak opened this issue Aug 27, 2023 · 1 comment · Fixed by #91272
Assignees
Labels
arch-x64 area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI os-windows
Milestone

Comments

@kunalspathak
Copy link
Member

// Found by Antigen


using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using System.Numerics;
public class TestClass
{
    public struct S1
    {
        public struct S1_D1_F2
        {
        }
    }
    public struct S2
    {
    }
    static int s_int_10 = 2;
    static long s_long_11 = -1;
    static Vector128<uint> s_v128_uint_33 = Vector128<uint>.AllBitsSet;
    static Vector256<byte> s_v256_byte_38 = Vector256<byte>.Zero;
    static Vector256<ushort> s_v256_ushort_41 = Vector256.Create((ushort)1);
    static Vector256<ulong> s_v256_ulong_45 = Vector256.CreateScalar((ulong)2);
    static S1 s_s1_52 = new S1();
    bool bool_54 = true;
    int int_60 = 5;
    Vector128<uint> v128_uint_83 = Vector128.Create((uint)5);
    Vector256<ushort> v256_ushort_91 = Vector256.CreateScalar((ushort)0);
    Vector256<ulong> v256_ulong_95 = Vector256.Create((ulong)5, 1, 2147483648, 5);
    S1.S1_D1_F2 s1_s1_d1_f2_101 = new S1.S1_D1_F2();
    S1 s1_102 = new S1();
    S2 s2_103 = new S2();
    static int s_loopInvariant = 1;
    public S1.S1_D1_F2 Method1(out S1 p_s1_104, out Vector128<uint> p_v128_uint_105, S1 p_s1_106, ushort p_ushort_107, ref S2 p_s2_108, decimal p_decimal_109)
    {
        unchecked
        {
            int int_116 = 5;
            S1.S1_D1_F2 s1_s1_d1_f2_124 = new S1.S1_D1_F2();
            p_v128_uint_105 = v128_uint_83 * (s_v128_uint_33 *= 15*4);
            if (bool_54 = bool_54 || (bool_54 = 15<=4))
            {
            }
            else
            {
                for (; s_int_10 < 15+4; s_int_10++)
                {
                    for (;;)
                    {
                        for (; int_116 < (int_60 += 15^4); int_116++)
                        {
                            int __loopvar156 = 15-4;
                            for (; int_60 < Avx2.MoveMask(s_v256_byte_38); s_long_11 ^= 15+4)
                            {
                                if (__loopvar156 > s_loopInvariant)
                                    break;
                                if (Vector256.ToScalar(Vector256.AsUInt64(s_v256_ushort_41 += v256_ushort_91)) < Vector256.ToScalar(s_v256_ulong_45 = v256_ulong_95 *= 15|4))
                                {
                                }
                                else
                                {
                                    int_116 <<= 15<<4;
                                }
                            }
                        }
                    }
                }
            }
            return s1_s1_d1_f2_124;
        }
    }
    public void Method0()
    {
        unchecked
        {
            s1_s1_d1_f2_101 = Method1(out s1_102, out s_v128_uint_33, s_s1_52, 15&4, ref s2_103, 15/4);
            return;
        }
    }
    public static void Main(string[] args)
    {
        new TestClass().Method0();
    }
}
/*

Environment:


Assert failure(PID 17672 [0x00004508], Thread: 48876 [0xbeec]): Assertion failed '!varTypeIsUnsigned(type) || varTypeIsSmall(type)' in 'TestClass:Method1(byref,byref,TestClass+S1,ushort,byref,System.Decimal):TestClass+S1+S1_D1_F2:this' during 'Generate code' (IL size 248; hash 0xadb68bc7; Instrumented Tier0)
    File: D:\git\runtime\src\coreclr\jit\codegenxarch.cpp Line: 6895
    Image: D:\git\runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\CoreRun.exe
*/
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 27, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 27, 2023
@ghost
Copy link

ghost commented Aug 27, 2023

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

Issue Details
// Found by Antigen


using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using System.Numerics;
public class TestClass
{
    public struct S1
    {
        public struct S1_D1_F2
        {
        }
    }
    public struct S2
    {
    }
    static int s_int_10 = 2;
    static long s_long_11 = -1;
    static Vector128<uint> s_v128_uint_33 = Vector128<uint>.AllBitsSet;
    static Vector256<byte> s_v256_byte_38 = Vector256<byte>.Zero;
    static Vector256<ushort> s_v256_ushort_41 = Vector256.Create((ushort)1);
    static Vector256<ulong> s_v256_ulong_45 = Vector256.CreateScalar((ulong)2);
    static S1 s_s1_52 = new S1();
    bool bool_54 = true;
    int int_60 = 5;
    Vector128<uint> v128_uint_83 = Vector128.Create((uint)5);
    Vector256<ushort> v256_ushort_91 = Vector256.CreateScalar((ushort)0);
    Vector256<ulong> v256_ulong_95 = Vector256.Create((ulong)5, 1, 2147483648, 5);
    S1.S1_D1_F2 s1_s1_d1_f2_101 = new S1.S1_D1_F2();
    S1 s1_102 = new S1();
    S2 s2_103 = new S2();
    static int s_loopInvariant = 1;
    public S1.S1_D1_F2 Method1(out S1 p_s1_104, out Vector128<uint> p_v128_uint_105, S1 p_s1_106, ushort p_ushort_107, ref S2 p_s2_108, decimal p_decimal_109)
    {
        unchecked
        {
            int int_116 = 5;
            S1.S1_D1_F2 s1_s1_d1_f2_124 = new S1.S1_D1_F2();
            p_v128_uint_105 = v128_uint_83 * (s_v128_uint_33 *= 15*4);
            if (bool_54 = bool_54 || (bool_54 = 15<=4))
            {
            }
            else
            {
                for (; s_int_10 < 15+4; s_int_10++)
                {
                    for (;;)
                    {
                        for (; int_116 < (int_60 += 15^4); int_116++)
                        {
                            int __loopvar156 = 15-4;
                            for (; int_60 < Avx2.MoveMask(s_v256_byte_38); s_long_11 ^= 15+4)
                            {
                                if (__loopvar156 > s_loopInvariant)
                                    break;
                                if (Vector256.ToScalar(Vector256.AsUInt64(s_v256_ushort_41 += v256_ushort_91)) < Vector256.ToScalar(s_v256_ulong_45 = v256_ulong_95 *= 15|4))
                                {
                                }
                                else
                                {
                                    int_116 <<= 15<<4;
                                }
                            }
                        }
                    }
                }
            }
            return s1_s1_d1_f2_124;
        }
    }
    public void Method0()
    {
        unchecked
        {
            s1_s1_d1_f2_101 = Method1(out s1_102, out s_v128_uint_33, s_s1_52, 15&4, ref s2_103, 15/4);
            return;
        }
    }
    public static void Main(string[] args)
    {
        new TestClass().Method0();
    }
}
/*

Environment:


Assert failure(PID 17672 [0x00004508], Thread: 48876 [0xbeec]): Assertion failed '!varTypeIsUnsigned(type) || varTypeIsSmall(type)' in 'TestClass:Method1(byref,byref,TestClass+S1,ushort,byref,System.Decimal):TestClass+S1+S1_D1_F2:this' during 'Generate code' (IL size 248; hash 0xadb68bc7; Instrumented Tier0)
    File: D:\git\runtime\src\coreclr\jit\codegenxarch.cpp Line: 6895
    Image: D:\git\runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\CoreRun.exe
*/
Author: kunalspathak
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@JulieLeeMSFT JulieLeeMSFT added this to the 8.0.0 milestone Aug 28, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Aug 28, 2023
jakobbotsch added a commit to jakobbotsch/runtime that referenced this issue Aug 29, 2023
These could create TYP_ULONG/TYP_UINT indirs/LCL_FLD nodes, which are
illegal.

Fix dotnet#91174
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Aug 29, 2023
jakobbotsch added a commit that referenced this issue Aug 30, 2023
These could create TYP_ULONG/TYP_UINT indirs/LCL_FLD nodes, which are
illegal.

Fix #91174
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 30, 2023
github-actions bot pushed a commit that referenced this issue Sep 11, 2023
These could create TYP_ULONG/TYP_UINT indirs/LCL_FLD nodes, which are
illegal.

Fix #91174
carlossanlop pushed a commit that referenced this issue Sep 12, 2023
…ring (#91874)

* JIT: Fix illegal IR created by GetElement/ToScalar lowering

These could create TYP_ULONG/TYP_UINT indirs/LCL_FLD nodes, which are
illegal.

Fix #91174

* Add test

* Fix license header in new test

---------

Co-authored-by: Jakob Botsch Nielsen <jakob.botsch.nielsen@gmail.com>
@ghost ghost locked as resolved and limited conversation to collaborators Sep 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-x64 area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI os-windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants