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

[Arm64] Use smull/umull for computing 64-bit result of multiplication of two 32-bit ints/uint #47490

Closed
echesakov opened this issue Jan 26, 2021 · 1 comment · Fixed by #57926
Assignees
Labels
arch-arm64 area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI optimization Priority:3 Work that is nice to have
Milestone

Comments

@echesakov
Copy link
Contributor

Right now the body of the following method

public static long BigMul(int a, int b)
{
    return ((long)a) * b;
}

is compiled by the JIT as two sign extensions sxtw followed by mul instruction:

G_M36318_IG01:              ;; offset=0000H
        A9BF7BFD          stp     fp, lr, [sp,#-16]!
        910003FD          mov     fp, sp
						;; bbWeight=1    PerfScore 1.50
G_M36318_IG02:              ;; offset=0008H
        93407C00          sxtw    x0, w0
        93407C21          sxtw    x1, w1
        9B017C00          mul     x0, x0, x1
						;; bbWeight=1    PerfScore 3.00
G_M36318_IG03:              ;; offset=0014H
        A8C17BFD          ldp     fp, lr, [sp],#16
        D65F03C0          ret     lr

As @TamarChristinaArm pointed out in #47362 that could be simplified down to

smull x0, w0, w1

The same applies to unsigned version of the method

public static ulong BigMul(uint a, uint b)
{
    return ((ulong)a) * b;
}

that should be compiled to

umull x0, w0, w1
@echesakov echesakov added arch-arm64 area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Jan 26, 2021
@echesakov echesakov added this to the 6.0.0 milestone Jan 26, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Jan 26, 2021
@echesakov echesakov added optimization and removed untriaged New issue has not been triaged by the area owner labels Jan 26, 2021
@JulieLeeMSFT JulieLeeMSFT added the needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration label Mar 23, 2021
@echesakov
Copy link
Contributor Author

#44849 seems to be related to this one

@echesakov echesakov added Priority:3 Work that is nice to have and removed needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration labels Mar 31, 2021
@echesakov echesakov modified the milestones: 6.0.0, Future Mar 31, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Aug 23, 2021
@JulieLeeMSFT JulieLeeMSFT modified the milestones: Future, 7.0.0 Aug 23, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Oct 5, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-arm64 area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI optimization Priority:3 Work that is nice to have
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants