Skip to content

Conversation

@TIHan
Copy link
Contributor

@TIHan TIHan commented Jan 10, 2023

A minor change, it is similar to the work here -> #79630

The example:

        static uint Y(uint i)
        {
            return i & uint.MaxValue;
        }

The emitted and reg, -1 can be skipped if we know that the reg 's upper 32-bits are zero'ed and that the operation is 32-bits.
image

Overall, there are not that many improvements, but improvements nonetheless.

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jan 10, 2023
@ghost ghost assigned TIHan Jan 10, 2023
@ghost
Copy link

ghost commented Jan 10, 2023

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

Issue Details

A minor change, based off of #79630

The example:

        static uint Y(uint i)
        {
            return i & uint.MaxValue;
        }

Can be optimized to a cast:
image

Author: TIHan
Assignees: TIHan
Labels:

area-CodeGen-coreclr

Milestone: -

@TIHan TIHan marked this pull request as draft January 11, 2023 20:52
@TIHan TIHan changed the title [JIT] - ARM64/X64 - Optimize 'x & -1' to a cast [JIT] - X64 - Peephole optimization to possibly skip emitting and reg, -1 Jan 25, 2023
@TIHan TIHan marked this pull request as ready for review January 25, 2023 22:49
@TIHan
Copy link
Contributor Author

TIHan commented Jan 25, 2023

@dotnet/jit-contrib this is ready, pending CI, - @BruceForstall PTAL

@BruceForstall
Copy link
Contributor

Diffs

@TIHan TIHan merged commit 007df05 into dotnet:main Jan 27, 2023
@TIHan TIHan deleted the and-negative-one-opt branch January 27, 2023 03:43
@ghost ghost locked as resolved and limited conversation to collaborators Feb 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

2 participants