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

Chained comparison of two integers against a constant is not coalesced #101347

Open
neon-sunset opened this issue Apr 21, 2024 · 1 comment · May be fixed by #102103
Open

Chained comparison of two integers against a constant is not coalesced #101347

neon-sunset opened this issue Apr 21, 2024 · 1 comment · May be fixed by #102103
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 tenet-performance Performance related issue
Milestone

Comments

@neon-sunset
Copy link
Contributor

neon-sunset commented Apr 21, 2024

Description

Given the snippet

static bool Test(int a, int b) => a is 0x80 && b is 0x80;

.NET emits

       cmp      ecx, 128
       jne      SHORT G_M000_IG05
       xor      eax, eax
       cmp      edx, 128
       sete     al
       ret      
G_M000_IG05:                ;; offset=0x0014
       xor      eax, eax
       ret      

While Clang emits

        xor     edi, 128
        xor     esi, 128
        or      esi, edi
        sete    al
        ret

It would be nice if JIT/ILC could emit branchless comparison for such patterns.

Configuration

.NET 8.0.3

Regression?

No

@neon-sunset neon-sunset added the tenet-performance Performance related issue label Apr 21, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Apr 21, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Apr 21, 2024
@neon-sunset neon-sunset changed the title Comparison of two integers against the same constant is not coalesced Chained comparison of two integers against a constant is not coalesced Apr 21, 2024
@vcsjones vcsjones added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Apr 21, 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 21, 2024
@EgorBo EgorBo modified the milestones: 9.0.0, Future Apr 21, 2024
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 tenet-performance Performance related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants