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

JIT: Bad codegen on x86 #94996

Closed
jakobbotsch opened this issue Nov 20, 2023 · 2 comments
Closed

JIT: Bad codegen on x86 #94996

jakobbotsch opened this issue Nov 20, 2023 · 2 comments
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone

Comments

@jakobbotsch
Copy link
Member

// Generated by Fuzzlyn v1.6 on 2023-11-19 16:39:12
// Run on X86 Windows
// Seed: 8102521250723522311
// Reduced from 379.8 KiB to 2.0 KiB in 00:15:51
// Debug: Outputs 65536
// Release: Outputs 0
using System.Runtime.CompilerServices;

public interface I2
{
    ushort M47(ulong arg0);
}

public struct S0
{
    public ushort F0;
    public short F1;
    public uint F2;
    public sbyte F3;
    public S0(short f1): this()
    {
        F1 = f1;
    }
}

public struct S1 : I2
{
    public uint F0;
    public S0 F1;
    public byte F2;
    public bool F3;
    public ushort F4;
    public bool F5;
    public S0 F6;
    public S1(S0 f1): this()
    {
        F1 = f1;
    }

    public ushort M47(ulong arg0)
    {
        I2[] var5 = new I2[]{new S1(new S0(1))};
        var vr5 = new S1(new S0(0));
        var vr6 = this.F1.F2;
        var vr7 = this.F6.F0;
        var vr9 = Program.s_4;
        var vr10 = this.F1;
        var vr11 = var5[0];
        var vr12 = Program.s_34[0];
        bool vr1 = Program.M49(vr5, vr6, vr7, vr9, vr10, vr11, vr12);
        var vr13 = this;
        return (ushort)Program.M48(vr13);
    }
}

public class C0
{
    public S1 F2;
}

public class Program
{
    public static IRuntime s_rt;
    public static S1 s_4 = new S1(new S0(1));
    public static C0[] s_16 = new C0[]{new C0()};
    public static int[] s_34 = new int[]{0};
    public static void Main()
    {
        s_rt = new Runtime();
        var vr17 = new I2[]{new S1(new S0(0))};
        short vr24 = s_16[0].F2.F1.F1;
        var vr21 = (ulong)vr24;
        ushort vr22 = vr17[0].M47(vr21);
    }

    public static bool M49(S1 arg0, uint arg1, ushort arg2, S1 arg3, S0 arg4, I2 arg5, int arg6)
    {
        arg0 = arg3;
        arg0.F1 = Unsafe.ReadUnaligned<S0>(ref Unsafe.As<uint, byte>(ref arg3.F0));
        s_rt.WriteLine(arg0.F1.F2);
        return arg0.F5;
    }

    public static ref short M48(S1 argThis)
    {
        return ref s_16[0].F2.F1.F1;
    }
}

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

public class Runtime : IRuntime
{
    public void WriteLine<T>(T value) => System.Console.WriteLine(value);
}
@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 Nov 20, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Nov 20, 2023
@ghost
Copy link

ghost commented Nov 20, 2023

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

Issue Details
// Generated by Fuzzlyn v1.6 on 2023-11-19 16:39:12
// Run on X86 Windows
// Seed: 8102521250723522311
// Reduced from 379.8 KiB to 2.0 KiB in 00:15:51
// Debug: Outputs 65536
// Release: Outputs 0
using System.Runtime.CompilerServices;

public interface I2
{
    ushort M47(ulong arg0);
}

public struct S0
{
    public ushort F0;
    public short F1;
    public uint F2;
    public sbyte F3;
    public S0(short f1): this()
    {
        F1 = f1;
    }
}

public struct S1 : I2
{
    public uint F0;
    public S0 F1;
    public byte F2;
    public bool F3;
    public ushort F4;
    public bool F5;
    public S0 F6;
    public S1(S0 f1): this()
    {
        F1 = f1;
    }

    public ushort M47(ulong arg0)
    {
        I2[] var5 = new I2[]{new S1(new S0(1))};
        var vr5 = new S1(new S0(0));
        var vr6 = this.F1.F2;
        var vr7 = this.F6.F0;
        var vr9 = Program.s_4;
        var vr10 = this.F1;
        var vr11 = var5[0];
        var vr12 = Program.s_34[0];
        bool vr1 = Program.M49(vr5, vr6, vr7, vr9, vr10, vr11, vr12);
        var vr13 = this;
        return (ushort)Program.M48(vr13);
    }
}

public class C0
{
    public S1 F2;
}

public class Program
{
    public static IRuntime s_rt;
    public static S1 s_4 = new S1(new S0(1));
    public static C0[] s_16 = new C0[]{new C0()};
    public static int[] s_34 = new int[]{0};
    public static void Main()
    {
        s_rt = new Runtime();
        var vr17 = new I2[]{new S1(new S0(0))};
        short vr24 = s_16[0].F2.F1.F1;
        var vr21 = (ulong)vr24;
        ushort vr22 = vr17[0].M47(vr21);
    }

    public static bool M49(S1 arg0, uint arg1, ushort arg2, S1 arg3, S0 arg4, I2 arg5, int arg6)
    {
        arg0 = arg3;
        arg0.F1 = Unsafe.ReadUnaligned<S0>(ref Unsafe.As<uint, byte>(ref arg3.F0));
        s_rt.WriteLine(arg0.F1.F2);
        return arg0.F5;
    }

    public static ref short M48(S1 argThis)
    {
        return ref s_16[0].F2.F1.F1;
    }
}

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

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

area-CodeGen-coreclr

Milestone: -

@jakobbotsch jakobbotsch removed the untriaged New issue has not been triaged by the area owner label Nov 20, 2023
@jakobbotsch jakobbotsch added this to the 9.0.0 milestone Nov 20, 2023
@jakobbotsch
Copy link
Member Author

Does not repro with DOTNET_JitDoCopyProp=0. Copy prop turns

***** BB01
STMT00000 ( 0x000[E-] ... 0x001 )
N002 ( 19, 13) [000001] DA---------                           STORE_LCL_VAR struct<S1, 36> V00 arg0         d:2 $VN.Void
N001 (  9,  6) [000000] -----------                         └──▌  LCL_VAR   struct<S1, 36> V03 arg3         u:1 $81

***** BB01
STMT00001 ( 0x003[E-] ... 0x016 )
N002 ( 19, 17) [000007] UA---------                           STORE_LCL_FLD struct<S0, 12> V00 arg0         ud:2->3[+4] $VN.Void
N001 (  9,  8) [000005] -----------                         └──▌  LCL_FLD   struct<S0, 12> V03 arg3         u:1[+0] (last use) $140

into

***** BB01
STMT00000 ( 0x000[E-] ... 0x001 )
N002 ( 19, 13) [000001] DA---------                           STORE_LCL_VAR struct<S1, 36> V00 arg0         d:2 $VN.Void
N001 (  9,  6) [000000] -----------                         └──▌  LCL_VAR   struct<S1, 36> V03 arg3         u:1 $81

***** BB01
STMT00001 ( 0x003[E-] ... 0x016 )
N002 ( 19, 17) [000007] UA---------                           STORE_LCL_FLD struct<S0, 12> V00 arg0         ud:2->3[+4] $VN.Void
N001 (  9,  8) [000005] -----------                         └──▌  LCL_FLD   struct<S0, 12> V00 arg0         u:2[+0] (last use) $140

and codegen does not deal with partially overlapping copies. This is essentially a duplicate of #7539.

@jakobbotsch jakobbotsch closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 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

No branches or pull requests

1 participant