Skip to content

Treat TZCNT/POPCNT/LZCNT as never negative #64909

Closed

Description

@EgorBo

A good first issue for newcomers or those who want to contribute to JIT (found in #64899 (comment), also, I used this pattern in IndexOf):

public int M1(uint x) => BitOperations.TrailingZeroCount(x) / 2;

public int M2(uint x) => (int)((uint)BitOperations.TrailingZeroCount(x) / 2);

M2 emits better codegen, see sharplab

the fix is easy, IntegralRange::ForNode function should recognize GT_INTRINSIC/GT_HWINTRINSIC nodes and return non-negative range for TZCNT/POPCNT/LZCNT. Then the division will automatically be optimized.

Activity

  1. ghost added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Feb 7, 2022
  2. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Feb 7, 2022
  3. added
    good first issueIssue should be easy to implement, good for first-time contributors
    help wanted[up-for-grabs] Good issue for external contributors
    on Feb 7, 2022
  4. added this to the Future milestone on Feb 7, 2022
  5. removed
    untriagedNew issue has not been triaged by the area owner
    on Feb 7, 2022
  6. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Feb 8, 2022
  7. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Feb 21, 2022
  8. ghost locked as resolved and limited conversation to collaborators on Mar 23, 2022
  9. modified the milestones: Future, 7.0.0 on Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIgood first issueIssue should be easy to implement, good for first-time contributorshelp wanted[up-for-grabs] Good issue for external contributorstenet-performancePerformance related issue

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions