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: (x u>> cns) -> [0..(x's max value >> cns)] #109900

Merged
merged 5 commits into from
Nov 20, 2024

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Nov 17, 2024

Optimizes bounds check for #109899

@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 Nov 17, 2024
@EgorBo
Copy link
Member Author

EgorBo commented Nov 18, 2024

PTAL @AndyAyersMS @dotnet/jit-contrib a change to optimize bounds check for "arr[X >> CNS]" pattern in order to remove unsafe code from the repo

return Range(Limit(Limit::keConstant, 0));
}

// Calculate max possible value of op1, e.g. UINT_MAX for TYP_INT/TYP_UINT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was wondering if we could use IntegralRange here but that seems a bit clunky.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially, I wanted to call RangeCheck::ComputeRange on op1 to get even more precise range, but it had no diffs

@EgorBo EgorBo merged commit 50cbcb3 into dotnet:main Nov 20, 2024
143 checks passed
@EgorBo EgorBo deleted the drop-bounds-check-rsz branch November 20, 2024 13:20
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants