dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.23k stars 4.45k forks source link

ARM64: suboptimal codegen for Vector64.Create(1) #101661

Open EgorBo opened 2 weeks ago

EgorBo commented 2 weeks ago
Vector64<int> Test() => Vector64.Create(1);

Proposed codegen diff:

; Method Prog:Test():System.Runtime.Intrinsics.Vector64`1[int]:this (FullOpts)
G_M63775_IG01:
            stp     fp, lr, [sp, #-0x10]!
            mov     fp, sp
G_M63775_IG02:
-           ldr     d0, [@RWD00]
+           movi    v0.2s, #1
G_M63775_IG03:
            ldp     fp, lr, [sp], #0x10
            ret     lr
-RWD00      dq  0000000100000001h
; Total bytes of code: 20

PS: actually, not just Vector64.Create(1), but any imm-able constant for movi

dotnet-policy-service[bot] commented 2 weeks ago

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