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

Unable to find expression in a statement during CSE #57470

Closed
kunalspathak opened this issue Aug 16, 2021 · 6 comments · Fixed by #57478
Closed

Unable to find expression in a statement during CSE #57470

kunalspathak opened this issue Aug 16, 2021 · 6 comments · Fixed by #57478
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

kunalspathak commented Aug 16, 2021

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//
// This file is auto-generated.
// Seed: -1
//
using System;
using System.Runtime.CompilerServices;
public class TestClass8505
{
    static int s_int32_6 = -5;
    static sbyte s_sbyte_8 = 2;
    static int s_loopInvariant = 3;
    public sbyte LeafMethod8()
    {
        unchecked
        {
            return s_sbyte_8 <<= s_int32_6 >>= s_int32_6 ^ (-2 - (s_int32_6 &= -5)) / (-1 * s_int32_6 * (2 ^ -2)) + 77;
        }
    }
    public void Method0()
    {
        unchecked
        {
            try
            {
            }
            finally
            {
                {
                    int __loopvar1 = s_loopInvariant, __loopSecondaryVar1_0 = 15 - 4;
                    do
                    {
                    }
                    while (15 % 4 > LeafMethod8() / 15 + 4);
                }
                {
                }
            }
            return;
        }
    }
    public static void Main(string[] args)
    {
        TestClass8505 objTestClass8505 = new TestClass8505();
        objTestClass8505.Method0();
    }
}
/*
--------- Test ---------  

Environment:

COMPlus_TieredCompilation=0


gtFindLink failed: stm=STMT00004, exp=[000050]
stm =STMT00004 (IL   ???...0x034)
N022 ( 39, 20)              [000033] -A-XG---R---              *  ASG       int    <l:$11a, c:$119>
N021 (  1,  1)              [000032] D------N----              +--*  LCL_VAR   int    V05 tmp4         d:2 <l:$118, c:$117>
N020 ( 39, 20)              [000031] -A-XG---R---              \--*  RSH       int    <l:$11a, c:$119>
N019 (  1,  1)              [000015] ------------                 +--*  LCL_VAR   int    V03 tmp2         u:2 (last use) <l:$100, c:$142>
N018 ( 34, 18)              [000030] -A-XG-------                 \--*  AND       int    <l:$116, c:$115>
N016 ( 32, 16)              [000028] -A-XG-------                    +--*  XOR       int    <l:$112, c:$111>
N014 ( 30, 14)              [000027] -A-XG-------                    |  +--*  ADD       int    <l:$10e, c:$10d>
N012 ( 28, 12)              [000025] -A-XG-------                    |  |  +--*  DIV       int    <l:$10a, c:$109>
N008 (  5,  6)              [000019] -A----------                    |  |  |  +--*  ADD       int    <l:$104, c:$103>
N006 (  3,  4)              [000067] -A----------                    |  |  |  |  +--*  COMMA     int    <l:$147, c:$146>
N004 (  2,  3)              [000065] -A------R---                    |  |  |  |  |  +--*  ASG       int    $VN.Void
N003 (  1,  1)              [000064] D------N----                    |  |  |  |  |  |  +--*  LCL_VAR   int    V09 cse2         d:1 <l:$147, c:$146>
N002 (  2,  2)              [000049] ------------                    |  |  |  |  |  |  \--*  NEG       int    <l:$147, c:$146>
N001 (  1,  1)              [000009] ------------                    |  |  |  |  |  |     \--*  LCL_VAR   int    V02 tmp1         u:2 (last use) <l:$102, c:$101>
N005 (  1,  1)              [000066] ------------                    |  |  |  |  |  \--*  LCL_VAR   int    V09 cse2         u:1 <l:$147, c:$146>
N007 (  1,  1)              [000003] ------------                    |  |  |  |  \--*  CNS_INT   int    -2 $43
N011 (  3,  3)              [000024] ----G-------                    |  |  |  \--*  LSH       int    <l:$106, c:$105>
N009 (  1,  1)              [000057] ------------                    |  |  |     +--*  LCL_VAR   int    V07 cse0         u:1 <l:$102, c:$101>
N010 (  1,  1)              [000023] ------------                    |  |  |     \--*  CNS_INT   int    2 $44
N013 (  1,  1)              [000026] ------------                    |  |  \--*  CNS_INT   int    77 $46
N015 (  1,  1)              [000018] ------------                    |  \--*  LCL_VAR   int    V04 tmp3         u:2 (last use) <l:$100, c:$144>
N017 (  1,  1)              [000029] ------------                    \--*  CNS_INT   int    31 $47

exp =N007 (  4,  5)              [000050] ----G-------              *  NEG       int    <l:$147, c:$149>
N009 (  1,  1)              [000057] ------------              \--*  LCL_VAR   int    V07 cse0         u:1 <l:$102, c:$101>


Assert failure(PID 46504 [0x0000b5a8], Thread: 48888 [0xbef8]): Assertion failed 'link' in 'TestClass8505:LeafMethod8():byte:this' during 'Optimize Valnum CSEs' (IL size 69)

    File: D:\git\runtime\src\coreclr\jit\optcse.cpp Line: 3290
    Image: D:\git\runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\CoreRun.exe


*/
@dotnet-issue-labeler dotnet-issue-labeler bot added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI untriaged New issue has not been triaged by the area owner labels Aug 16, 2021
@ghost
Copy link

ghost commented Aug 16, 2021

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

Issue Details
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//
// This file is auto-generated.
// Seed: -1
//
using System;
using System.Runtime.CompilerServices;
public class TestClass8505
{
    static int s_int32_6 = -5;
    static sbyte s_sbyte_8 = 2;
    static int s_loopInvariant = 3;
    public sbyte LeafMethod8()
    {
        unchecked
        {
            return s_sbyte_8 <<= s_int32_6 >>= s_int32_6 ^ (-2 - (s_int32_6 &= -5)) / (-1 * s_int32_6 * (2 ^ -2)) + 77;
        }
    }
    public void Method0()
    {
        unchecked
        {
            try
            {
            }
            finally
            {
                {
                    int __loopvar1 = s_loopInvariant, __loopSecondaryVar1_0 = 15 - 4;
                    do
                    {
                    }
                    while (15 % 4 > LeafMethod8() / 15 + 4);
                }
                {
                }
            }
            return;
        }
    }
    public static void Main(string[] args)
    {
        TestClass8505 objTestClass8505 = new TestClass8505();
        objTestClass8505.Method0();
    }
}
/*
Got output diff:
--------- Baseline ---------  

Environment:



--------- Test ---------  

Environment:

COMPlus_TieredCompilation=0


gtFindLink failed: stm=STMT00004, exp=[000050]
stm =STMT00004 (IL   ???...0x034)
N022 ( 39, 20)              [000033] -A-XG---R---              *  ASG       int    <l:$11a, c:$119>
N021 (  1,  1)              [000032] D------N----              +--*  LCL_VAR   int    V05 tmp4         d:2 <l:$118, c:$117>
N020 ( 39, 20)              [000031] -A-XG---R---              \--*  RSH       int    <l:$11a, c:$119>
N019 (  1,  1)              [000015] ------------                 +--*  LCL_VAR   int    V03 tmp2         u:2 (last use) <l:$100, c:$142>
N018 ( 34, 18)              [000030] -A-XG-------                 \--*  AND       int    <l:$116, c:$115>
N016 ( 32, 16)              [000028] -A-XG-------                    +--*  XOR       int    <l:$112, c:$111>
N014 ( 30, 14)              [000027] -A-XG-------                    |  +--*  ADD       int    <l:$10e, c:$10d>
N012 ( 28, 12)              [000025] -A-XG-------                    |  |  +--*  DIV       int    <l:$10a, c:$109>
N008 (  5,  6)              [000019] -A----------                    |  |  |  +--*  ADD       int    <l:$104, c:$103>
N006 (  3,  4)              [000067] -A----------                    |  |  |  |  +--*  COMMA     int    <l:$147, c:$146>
N004 (  2,  3)              [000065] -A------R---                    |  |  |  |  |  +--*  ASG       int    $VN.Void
N003 (  1,  1)              [000064] D------N----                    |  |  |  |  |  |  +--*  LCL_VAR   int    V09 cse2         d:1 <l:$147, c:$146>
N002 (  2,  2)              [000049] ------------                    |  |  |  |  |  |  \--*  NEG       int    <l:$147, c:$146>
N001 (  1,  1)              [000009] ------------                    |  |  |  |  |  |     \--*  LCL_VAR   int    V02 tmp1         u:2 (last use) <l:$102, c:$101>
N005 (  1,  1)              [000066] ------------                    |  |  |  |  |  \--*  LCL_VAR   int    V09 cse2         u:1 <l:$147, c:$146>
N007 (  1,  1)              [000003] ------------                    |  |  |  |  \--*  CNS_INT   int    -2 $43
N011 (  3,  3)              [000024] ----G-------                    |  |  |  \--*  LSH       int    <l:$106, c:$105>
N009 (  1,  1)              [000057] ------------                    |  |  |     +--*  LCL_VAR   int    V07 cse0         u:1 <l:$102, c:$101>
N010 (  1,  1)              [000023] ------------                    |  |  |     \--*  CNS_INT   int    2 $44
N013 (  1,  1)              [000026] ------------                    |  |  \--*  CNS_INT   int    77 $46
N015 (  1,  1)              [000018] ------------                    |  \--*  LCL_VAR   int    V04 tmp3         u:2 (last use) <l:$100, c:$144>
N017 (  1,  1)              [000029] ------------                    \--*  CNS_INT   int    31 $47

exp =N007 (  4,  5)              [000050] ----G-------              *  NEG       int    <l:$147, c:$149>
N009 (  1,  1)              [000057] ------------              \--*  LCL_VAR   int    V07 cse0         u:1 <l:$102, c:$101>


Assert failure(PID 46504 [0x0000b5a8], Thread: 48888 [0xbef8]): Assertion failed 'link' in 'TestClass8505:LeafMethod8():byte:this' during 'Optimize Valnum CSEs' (IL size 69)

    File: D:\git\runtime\src\coreclr\jit\optcse.cpp Line: 3290
    Image: D:\git\runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\CoreRun.exe


*/
Author: kunalspathak
Assignees: -
Labels:

area-CodeGen-coreclr, untriaged

Milestone: -

@kunalspathak
Copy link
Member Author

I was looking at the JITDump and it was little odd that we are trying to CSE the use of [00050] with def of [00049] although they are not same.

STMT00004 (IL   ???...0x034)
N020 ( 42, 23)              [000033] -A-XG---R---              *  ASG       int    <l:$11a, c:$119>
N019 (  1,  1)              [000032] D------N----              +--*  LCL_VAR   int    V05 tmp4         d:2 <l:$118, c:$117>
N018 ( 42, 23)              [000031] ---XG-------              \--*  RSH       int    <l:$11a, c:$119>
N001 (  1,  1)              [000015] ------------                 +--*  LCL_VAR   int    V03 tmp2         u:2 (last use) <l:$100, c:$142>
N017 ( 37, 21)              [000030] ---XG-------                 \--*  AND       int    <l:$116, c:$115>
N015 ( 35, 19)              [000028] ---XG-------                    +--*  XOR       int    <l:$112, c:$111>
N013 ( 33, 17)              [000027] ---XG-------                    |  +--*  ADD       int    <l:$10e, c:$10d>
N011 ( 31, 15)              [000025] ---XG-------                    |  |  +--*  DIV       int    <l:$10a, c:$109>
N005 (  4,  4)              [000019] ------------                    |  |  |  +--*  ADD       int    <l:$104, c:$103>
N003 (  2,  2) CSE #03 (def)[000049] ------------                    |  |  |  |  +--*  NEG       int    <l:$147, c:$146>
N002 (  1,  1)              [000009] ------------                    |  |  |  |  |  \--*  LCL_VAR   int    V02 tmp1         u:2 (last use) <l:$102, c:$101>
N004 (  1,  1)              [000003] ------------                    |  |  |  |  \--*  CNS_INT   int    -2 $43
N010 (  7,  8)              [000024] ----G-------                    |  |  |  \--*  LSH       int    <l:$106, c:$105>
N008 (  5,  6)              [000051] ----G-------                    |  |  |     +--*  NEG       int    <l:$14b, c:$14a>
N007 (  4,  5) CSE #03 (use)[000050] ----G-------                    |  |  |     |  \--*  NEG       int    <l:$147, c:$149>
N006 (  3,  4) CSE #02 (use)[000021] ----G-------                    |  |  |     |     \--*  CLS_VAR   int    Hnd=0x1e35a488 Fseq[s_int32_6] <l:$102, c:$148>
N009 (  1,  1)              [000023] ------------                    |  |  |     \--*  CNS_INT   int    2 $44
N012 (  1,  1)              [000026] ------------                    |  |  \--*  CNS_INT   int    77 $46
N014 (  1,  1)              [000018] ------------                    |  \--*  LCL_VAR   int    V04 tmp3         u:2 (last use) <l:$100, c:$144>
N016 (  1,  1)              [000029] ------------                    \--*  CNS_INT   int    31 $47

@kunalspathak
Copy link
Member Author

@dotnet/jit-contrib

@JulieLeeMSFT JulieLeeMSFT added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed untriaged New issue has not been triaged by the area owner labels Aug 16, 2021
@JulieLeeMSFT JulieLeeMSFT added this to the 6.0.0 milestone Aug 16, 2021
@JulieLeeMSFT
Copy link
Member

CC @briansull @jakobbotsch

@ghost ghost added in-pr There is an active PR which will close this issue when it is merged and removed in-pr There is an active PR which will close this issue when it is merged labels Aug 16, 2021
@EgorBo
Copy link
Member

EgorBo commented Aug 16, 2021

Fixed in #57478, @jakobbotsch sorry if I stepped on your foot (since you was assigned)

@jakobbotsch
Copy link
Member

No problem @EgorBo!

@jakobbotsch jakobbotsch assigned EgorBo and unassigned jakobbotsch Aug 16, 2021
@JulieLeeMSFT JulieLeeMSFT removed the needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration label Aug 16, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 17, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Sep 16, 2021
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.

4 participants