Skip to content

JIT: (bug) Vector128.Create((int)Vector128.Dot(shortVec, shortVec)) returns the Dot result broadcast as shorts #134479

Description

@EgorBo

Create<int>(ToScalar(Dot<short>(...))) is folded into the Dot<short> vector even though the element types differ, so the sum is replicated per 16-bit lane.

Minimal Repro

using System;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;

public class Program
{
    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
    static Vector128<int> Test(Vector128<short> a, Vector128<short> b) => Vector128.Create((int)Vector128.Dot(a, b));

    public static void Main()
    {
        Vector128<short> v = Vector128.Create((short)1);
        Console.WriteLine(Test(v, v));
    }
}

Expected

<8, 8, 8, 8>

Actual

<524296, 524296, 524296, 524296>

Regression?

Not a regression. Reproduces on .NET 8, 9, 10, 11 RC2 and main (win-x64).

Notes

In fgOptimizeHWIntrinsic, the NI_Vector_Create case only checks hwop1->TypeGet() == retType (the vector size), not the SIMD base type.

Activity

  1. added this to the 12.0.0 milestone on Sep 22, 2026
  2. added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Sep 22, 2026
  3. dotnet-policy-service commented on Sep 22, 2026

    @dotnet-policy-service
    Contributor

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

  4. added a commit that references this issue on Sep 23, 2026
    be8eaf9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions