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. added
    tenet-performance
    on Feb 7, 2022
  2. ghost added
    area-CodeGen-coreclr
    on Feb 7, 2022
  3. ghost added
    untriaged
    on Feb 7, 2022
  4. added
    good first issue
    help wanted
    on Feb 7, 2022
  5. added this to the Future milestone on Feb 7, 2022
  6. removed
    untriaged
    on Feb 7, 2022
  7. ghost added
    in-pr
    on Feb 8, 2022
  8. ghost removed
    in-pr
    on Feb 21, 2022
  9. ghost locked as resolved and limited conversation to collaborators on Mar 23, 2022
  10. 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-coreclrgood first issuehelp wantedtenet-performance

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions