Skip to content

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

Closed
@echesakov

Description

@echesakov

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

Metadata

Metadata

Assignees

Labels

Priority:3Work that is nice to havearch-arm64area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIoptimization

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions