Skip to content

Investigate emitting movq for the CreateScalarUnsafe helper intrinsics that take a long/ulong on x86 #11626

Closed

Description

@tannergooding

For the CreateScalarUnsafe helper intrinsics that take a long/ulong, it may be beneficial to emit the movq xmm, [mem] instruction on x86, rather than falling back to emulating the behavior in software.

Given that the input is a regular long/ulong, but on x86 the instruction requires the second operand come from memory, this may require some additional work to make happen or we may find it not worthwhile to do at all.

category:cq
theme:hardware-intrinsics
skill-level:beginner
cost:small

Activity

  1. CarolEidt commented on Dec 6, 2018

    @CarolEidt
    Contributor

    @tannergooding - thanks for capturing this.

  2. transferred this issue fromdotnet/coreclron Jan 31, 2020
  3. added this to the Future milestone on Jan 31, 2020
  4. anthonycanino commented on Sep 12, 2022

    @anthonycanino
    Contributor

    @tannergooding I think this is no longer applicable.

    On SharpLab

    using System;
    
    using System.Runtime.Intrinsics;
    using System.Runtime.Intrinsics.X86;
    
    public class C {
        public Vector128<long> Foo(long u1) {
            return Vector128.CreateScalarUnsafe(u1);
        }
    }

    gives

    C.Foo(Int64)
        L0000: vzeroupper
        L0003: vmovq xmm0, r8
        L0008: vmovupd [rdx], xmm0
        L000c: mov rax, rdx
        L000f: ret
  5. saucecontrol commented on Sep 12, 2022

    @saucecontrol
    Member

    mov rax, rdx

    that's x64 code.

    here's x86

    C.Foo(Int64)
        L0000: push dword ptr [esp+8]
        L0004: push dword ptr [esp+8]
        L0008: mov ecx, edx
        L000a: call System.Runtime.Intrinsics.Vector128.CreateScalarUnsafe(Int64)
        L000f: ret 8
  6. anthonycanino commented on Sep 12, 2022

    @anthonycanino
    Contributor

    Got it --- thanks for that. My mistake.

  7. added
    in-prThere is an active PR which will close this issue when it is merged
    on Feb 28, 2025
  8. locked and limited conversation to collaborators on Apr 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-x86area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIin-prThere is an active PR which will close this issue when it is merged

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions