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: Optimize "x & cns == cns" pattern #101000

Open
EgorBo opened this issue Apr 13, 2024 · 2 comments
Open

JIT: Optimize "x & cns == cns" pattern #101000

EgorBo opened this issue Apr 13, 2024 · 2 comments
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI help wanted [up-for-grabs] Good issue for external contributors
Milestone

Comments

@EgorBo
Copy link
Member

EgorBo commented Apr 13, 2024

Noticed in #100999:

void Foo(int x)
{
    if ((x & 0xC000000) == 0xC000000)
        Console.WriteLine();
}

Codegen on arm64:

            and     w0, w1, #0xC000000
            mov     w1, #0xC000000
            cmp     w0, w1
            bne     G_M37282_IG05

Expected codegen:

            mov     w1, #0xC000000
            bics    wzr, w8, w1
            bne     G_M37282_IG05

x64 is suboptimal for it as well, current codegen:

       and      edx, 0xC000000
       cmp      edx, 0xC000000
       jne      SHORT G_M37282_IG04

^ should be not + test.

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

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

@EgorBo EgorBo added help wanted [up-for-grabs] Good issue for external contributors and removed untriaged New issue has not been triaged by the area owner labels Apr 13, 2024
@EgorBo EgorBo added this to the Future milestone Apr 13, 2024
@quantumhu
Copy link

Hi, I'd like to attempt this issue if no one else is, thanks!

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 help wanted [up-for-grabs] Good issue for external contributors
Projects
None yet
Development

No branches or pull requests

2 participants