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 'node->IsUnusedValue() && "found an unmarked unused value"' during 'Lowering nodeinfo' #91173

Closed
kunalspathak opened this issue Aug 27, 2023 · 2 comments · Fixed by #91213
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
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 S4
    {
        public struct S4_D1_F2
        {
        }
        public struct S4_D1_F4
        {
        }
    }
    public struct S5
    {
    }
    static int s_int_21 = 2;
    static S4.S4_D1_F2 s_s4_s4_d1_f2_68 = new S4.S4_D1_F2();
    int int_79 = 4;
    Vector256<float> v256_float_115 = Vector256.Create(4f);
    S4.S4_D1_F2 s4_s4_d1_f2_126 = new S4.S4_D1_F2();
    S4.S4_D1_F4 s4_s4_d1_f4_128 = new S4.S4_D1_F4();
    static int s_loopInvariant = 5;
    public S4.S4_D1_F2 Method1(long p_long_131, S5 p_s5_132, S4.S4_D1_F4 p_s4_s4_d1_f4_133)
    {
        unchecked
        {
            switch (15&4)
            {
                case 4:
                {
                    for (;;)
                    {
                        switch (int_79 - (s_int_21 >>= 15*4))
                        {
                            case 2:
                            {
                                while (15>4|| 15<=4)
                                {
                                    while (Vector256.ToScalar(v256_float_115) != 15%4&& 15!=4)
{}                                                                    }
                                break;
                            }
                            case -2147483647:
                            {
                                try
                                {
                                    int __loopvar7 = s_loopInvariant;
                                }
                                catch (System.ArithmeticException)
                                {
                                    while ((15|4)<= 15+4)
                                    {
                                    }
                                }
                                break;
                            }
                            case -5:
                            {
                                break;
                            }
                            default:
                            {
                                break;
                            }
                        }
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return s_s4_s4_d1_f2_68;
        }
    }
    public void Method0()
    {
        unchecked
        {
            long long_205 = 5;
            S5 s5_228 = new S5();
            s4_s4_d1_f2_126 = Method1(long_205, s5_228, s4_s4_d1_f4_128);
            return;
        }
    }
    public static void Main(string[] args)
    {
        new TestClass().Method0();
    }
}
/*

Environment:

set COMPlus_JitNoCSE2=1
set COMPlus_JitDoAssertionProp=0

Assert failure(PID 4736 [0x00001280], Thread: 35412 [0x8a54]): Assertion failed 'node->IsUnusedValue() && "found an unmarked unused value"' in 'TestClass:Method1(long,TestClass+S5,TestClass+S4+S4_D1_F4):TestClass+S4+S4_D1_F2:this' during 'Lowering nodeinfo' (IL size 71; hash 0x280a50f7; Tier0-FullOpts)
    File: D:\git\runtime\src\coreclr\jit\lir.cpp Line: 1691
    Image: D:\git\runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\CoreRun.exe
*/
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 27, 2023
@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
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 S4
    {
        public struct S4_D1_F2
        {
        }
        public struct S4_D1_F4
        {
        }
    }
    public struct S5
    {
    }
    static int s_int_21 = 2;
    static S4.S4_D1_F2 s_s4_s4_d1_f2_68 = new S4.S4_D1_F2();
    int int_79 = 4;
    Vector256<float> v256_float_115 = Vector256.Create(4f);
    S4.S4_D1_F2 s4_s4_d1_f2_126 = new S4.S4_D1_F2();
    S4.S4_D1_F4 s4_s4_d1_f4_128 = new S4.S4_D1_F4();
    static int s_loopInvariant = 5;
    public S4.S4_D1_F2 Method1(long p_long_131, S5 p_s5_132, S4.S4_D1_F4 p_s4_s4_d1_f4_133)
    {
        unchecked
        {
            switch (15&4)
            {
                case 4:
                {
                    for (;;)
                    {
                        switch (int_79 - (s_int_21 >>= 15*4))
                        {
                            case 2:
                            {
                                while (15>4|| 15<=4)
                                {
                                    while (Vector256.ToScalar(v256_float_115) != 15%4&& 15!=4)
{}                                                                    }
                                break;
                            }
                            case -2147483647:
                            {
                                try
                                {
                                    int __loopvar7 = s_loopInvariant;
                                }
                                catch (System.ArithmeticException)
                                {
                                    while ((15|4)<= 15+4)
                                    {
                                    }
                                }
                                break;
                            }
                            case -5:
                            {
                                break;
                            }
                            default:
                            {
                                break;
                            }
                        }
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return s_s4_s4_d1_f2_68;
        }
    }
    public void Method0()
    {
        unchecked
        {
            long long_205 = 5;
            S5 s5_228 = new S5();
            s4_s4_d1_f2_126 = Method1(long_205, s5_228, s4_s4_d1_f4_128);
            return;
        }
    }
    public static void Main(string[] args)
    {
        new TestClass().Method0();
    }
}
/*

Environment:

set COMPlus_JitNoCSE2=1
set COMPlus_JitDoAssertionProp=0

Assert failure(PID 4736 [0x00001280], Thread: 35412 [0x8a54]): Assertion failed 'node->IsUnusedValue() && "found an unmarked unused value"' in 'TestClass:Method1(long,TestClass+S5,TestClass+S4+S4_D1_F4):TestClass+S4+S4_D1_F2:this' during 'Lowering nodeinfo' (IL size 71; hash 0x280a50f7; Tier0-FullOpts)
    File: D:\git\runtime\src\coreclr\jit\lir.cpp Line: 1691
    Image: D:\git\runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\CoreRun.exe
*/
Author: kunalspathak
Assignees: -
Labels:

area-CodeGen-coreclr, untriaged

Milestone: -

@jakobbotsch jakobbotsch self-assigned this Aug 28, 2023
@jakobbotsch jakobbotsch 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
Copy link
Member

I'll take a look at this one.

jakobbotsch added a commit to jakobbotsch/runtime that referenced this issue Aug 28, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Aug 28, 2023
jakobbotsch added a commit that referenced this issue Aug 29, 2023
In the test case we disable CSE but then hoisting hoists out a HWINTRINSIC node
that ends up not CSE'd. This results in a top level unused HWINTRINSIC node that
lowering didn't handle in a transformation. There's a bunch of transformations
that do not handle this correctly, so fix it in all of them.

I couldn't find a test case that does not require disabling CSE (and I didn't
include the existing one since it never finishes with the bug fixed), but I
wouldn't bet on that one doesn't exist, so I think we should backport this
anyway.

Fix #91173
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 29, 2023
carlossanlop pushed a commit that referenced this issue Aug 29, 2023
…es (#91266)

* JIT: Fix LowerHWIntrinsicToScalar with unused values

Fix #91173

* Fix more cases

---------

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

Successfully merging a pull request may close this issue.

2 participants