Skip to content

Unnecessary sign-extension with bitwise AND #119962

Closed

Description

@xtqqczze
static nint M1(int value) {
    return value & 1;
}
static nint M2(int value) {
    return (nint)((uint)value & 1);
}
// coreclr trunk-20250921+80fb00f580f5b2353ff3a8aa78c5b5fd3f275a34

C:M1(int):nint (FullOpts):
       and      edi, 1
       movsxd   rax, edi
       ret      

C:M2(int):nint (FullOpts):
       and      edi, 1
       mov      eax, edi
       ret      

godbolt.org

Activity

  1. added
    untriaged
    on Sep 22, 2025
  2. added
    area-CodeGen-coreclr
    on Sep 22, 2025
  3. dotnet-policy-service commented on Sep 22, 2025

    @dotnet-policy-service
    Contributor

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

  4. tannergooding commented on Sep 22, 2025

    @tannergooding
    Member

    this looks like the same as another recent issue logged, which is likely just that x & cns doesn't create an appropriate range assertion such that we can track it as never negative or being within a finite bounds.

    CC. @EgorBo

  5. added this to the Future milestone on Sep 25, 2025
  6. added
    help wanted
    and removed
    untriaged
    on Sep 25, 2025
  7. JulieLeeMSFT commented on Sep 25, 2025

    @JulieLeeMSFT
    Member

    cc @dotnet/jit-contrib.

  8. adamperlin commented on Oct 21, 2025

    @adamperlin
    Contributor

    I can investigate this one!

  9. modified the milestones: Future, 10.0.0, 11.0.0 on Oct 21, 2025
  10. xtqqczze commented on Nov 10, 2025

    @xtqqczze
    ContributorAuthor

    @adamperlin This was completed by #120980?

  11. adamperlin commented on Nov 11, 2025

    @adamperlin
    Contributor

    Yes! I think we can close this now!

  12. locked and limited conversation to collaborators on Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrhelp wanted

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions