Skip to content

Guid(ReadOnlySpan<Byte>) could be optimized #78440

Description

@xtqqczze
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

Guid M0() => new Guid((ReadOnlySpan<byte>)new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10});
Guid M1() => Unsafe.ReadUnaligned<Guid>(ref MemoryMarshal.GetReference((ReadOnlySpan<byte>)new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10}));
M0()
    L0000: push rsi
    L0001: sub rsp, 0x40
    L0005: vzeroupper
    L0008: xor eax, eax
    L000a: mov [rsp+0x20], rax
    L000f: mov rsi, rdx
    L0012: mov rdx, 0x23dfaf408d8
    L001c: vxorps xmm0, xmm0, xmm0
    L0020: vmovupd [rsp+0x30], xmm0
    L0026: mov [rsp+0x20], rdx
    L002b: mov dword ptr [rsp+0x28], 0x10
    L0033: lea rdx, [rsp+0x20]
    L0038: lea rcx, [rsp+0x30]
    L003d: mov rax, 0x7ffce3d4d540
    L0047: call qword ptr [rax]
    L0049: vmovupd xmm0, [rsp+0x30]
    L004f: vmovupd [rsi], xmm0
    L0053: mov rax, rsi
    L0056: add rsp, 0x40
    L005a: pop rsi
    L005b: ret

M1()
    L0000: vzeroupper
    L0003: mov rax, 0x23dfaf408d8
    L000d: vmovupd xmm0, [rax]
    L0011: vmovupd [rdx], xmm0
    L0015: mov rax, rdx
    L0018: ret

sharplab

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions