Thanks to visit codestin.com
Credit goes to github.com

Skip to content

JIT: Wrong result with do-while loops #115109

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

Open
jakobbotsch opened this issue Apr 28, 2025 · 3 comments
Open

JIT: Wrong result with do-while loops #115109

jakobbotsch opened this issue Apr 28, 2025 · 3 comments
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI blocking-clean-ci-optional Blocking optional rolling runs
Milestone

Comments

@jakobbotsch
Copy link
Member

// Generated by Fuzzlyn v2.8 on 2025-04-27 22:46:08
// Run on X86 Windows
// Seed: 2255917678885586044-vectort,vector128,vector256,x86aes,x86avx,x86avx2,x86avx512bw,x86avx512bwvl,x86avx512cd,x86avx512cdvl,x86avx512dq,x86avx512dqvl,x86avx512f,x86avx512fvl,x86bmi1,x86bmi2,x86fma,x86lzcnt,x86pclmulqdq,x86popcnt,x86sse,x86sse2,x86sse3,x86sse41,x86sse42,x86ssse3,x86x86base
// Reduced from 118.3 KiB to 1.0 KiB in 00:17:25
// Debug: Outputs <0, 0, 0, 0, 0, 0, 0, 0>
// Release: Outputs <1, 0, 0, 0, 0, 0, 0, 0>
using System;
using System.Numerics;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;

public class Program
{
    public static IRuntime s_rt;
    public static int s_5 = 1;
    public static Vector<int>[] s_10 = new Vector<int>[]
    {
        Vector128.CreateScalar(0).AsVector()
    };
    public static byte s_21;
    public static void Main()
    {
        s_rt = new Runtime();
        bool vr5 = 0 <= M10();
        s_rt.WriteLine(s_10[0]);
    }

    public static byte M10()
    {
        byte lvar2 = default(byte);
        do
        {
            s_5 = 0;
            int lvar4 = 0;
            do
            {
                s_10[0] = Vector128.CreateScalar(s_5).AsVector();
            }
            while (lvar4 < 0);
        }
        while (lvar2 > 1);
        return s_21;
    }
}

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

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

cc @dotnet/jit-contrib

@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 Apr 28, 2025
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Apr 28, 2025
Copy link
Contributor

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

@BruceForstall BruceForstall self-assigned this May 1, 2025
@BruceForstall BruceForstall added this to the 10.0.0 milestone May 1, 2025
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label May 1, 2025
@BruceForstall BruceForstall added untriaged New issue has not been triaged by the area owner blocking-clean-ci-optional Blocking optional rolling runs labels May 1, 2025
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label May 1, 2025
@BruceForstall
Copy link
Member

It looks like the Hoist loop code phase is hoisting a read of s_5 in the CreateScalar call above the def of that variable in the outer loop.

@jakobbotsch
Copy link
Member Author

jakobbotsch commented May 3, 2025

Sounds similar in spirit to #75442 (and other older issues mentioned in that one). The memory dependence stuff in VN is supposed to prevent this, so looks like some handling around that is wrong here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI blocking-clean-ci-optional Blocking optional rolling runs
Projects
None yet
Development

No branches or pull requests

2 participants