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

Use zero register in csel when possible #78330

Merged
merged 2 commits into from
Nov 16, 2022

Conversation

SwapnilGaikwad
Copy link
Contributor

For

static void foo(int a, int b) {
    if(a == 5) {
        b = 0;
    }
    consume<int>(a, b);
}

Without this patch we get

...
2A1F03E2          mov     w2, wzr     <=== avoidable mov
7100141F          cmp     w0, #5
1A810041          csel    w1, w2, w1, eq
D29EA202          movz    x2, #0xF510
F2A85BC2          movk    x2, #0x42DE LSL #16
F2DFFFE2          movk    x2, #0xFFFF LSL #32
F9400042          ldr     x2, [x2]
D63F0040          blr     x2
...

After:

...
7100141F          cmp     w0, #5
1A8103E1          csel    w1, wzr, w1, eq
D29EA202          movz    x2, #0xF510
F2AF0D62          movk    x2, #0x786B LSL #16
F2DFFFE2          movk    x2, #0xFFFF LSL #32
F9400042          ldr     x2, [x2]
D63F0040          blr     x2
...

@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 14, 2022
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Nov 14, 2022
@ghost
Copy link

ghost commented Nov 14, 2022

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

Issue Details

For

static void foo(int a, int b) {
    if(a == 5) {
        b = 0;
    }
    consume<int>(a, b);
}

Without this patch we get

...
2A1F03E2          mov     w2, wzr     <=== avoidable mov
7100141F          cmp     w0, #5
1A810041          csel    w1, w2, w1, eq
D29EA202          movz    x2, #0xF510
F2A85BC2          movk    x2, #0x42DE LSL #16
F2DFFFE2          movk    x2, #0xFFFF LSL #32
F9400042          ldr     x2, [x2]
D63F0040          blr     x2
...

After:

...
7100141F          cmp     w0, #5
1A8103E1          csel    w1, wzr, w1, eq
D29EA202          movz    x2, #0xF510
F2AF0D62          movk    x2, #0x786B LSL #16
F2DFFFE2          movk    x2, #0xFFFF LSL #32
F9400042          ldr     x2, [x2]
D63F0040          blr     x2
...
Author: SwapnilGaikwad
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch jakobbotsch merged commit 715fde2 into dotnet:main Nov 16, 2022
@SwapnilGaikwad SwapnilGaikwad deleted the github-use-zr-csel branch November 16, 2022 14:21
@ghost ghost locked as resolved and limited conversation to collaborators Dec 16, 2022
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 community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants