Skip to content

Use zero register in csel when possible#78330

Merged
jakobbotsch merged 2 commits into
dotnet:mainfrom
SwapnilGaikwad:github-use-zr-csel
Nov 16, 2022
Merged

Use zero register in csel when possible#78330
jakobbotsch merged 2 commits into
dotnet:mainfrom
SwapnilGaikwad:github-use-zr-csel

Conversation

@SwapnilGaikwad

Copy link
Copy Markdown
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
...

@ghost ghost added 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 labels Nov 14, 2022
@ghost

ghost commented Nov 14, 2022

Copy link
Copy Markdown

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