Skip to content

JIT: (bug) AvxVnni.V512.MultiplyWideningAndAdd folded into BlendVariable loses the merge operand #133753

Closed

Description

@EgorBo

Minimal repro

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

public static class Program
{
    [MethodImpl(MethodImplOptions.NoInlining)]
    public static Vector512<int> Test(Vector512<int> fallback, Vector512<int> addend,
                                      Vector512<byte> left, Vector512<sbyte> right,
                                      Vector512<int> a, Vector512<int> b)
    {
        Vector512<int> mask = Avx512F.CompareEqual(a, b);
        return Avx512F.BlendVariable(fallback, AvxVnni.V512.MultiplyWideningAndAdd(addend, left, right), mask);
    }

    public static void Main()
    {
        if (!AvxVnni.V512.IsSupported) { Console.WriteLine("unsupported"); return; }
        Console.WriteLine(Test(
            Vector512.Create(7),            // fallback
            Vector512.Create(5),            // addend (left*right == 0, so the product is 5)
            Vector512<byte>.Zero,
            Vector512<sbyte>.Zero,
            Vector512.Create(1),
            Vector512.Create(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1)));
    }
}

Expected

<7, 5, 7, 5, 7, 5, 7, 5, 7, 5, 7, 5, 7, 5, 7, 5>

Actual

<5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5>

Notes

Repros under DOTNET_TieredCompilation=0; DOTNET_JitMinOpts=1 prints the expected value.
MultiplyWideningAndAddSaturate behaves the same way.

Activity

  1. added this to the 12.0.0 milestone on Sep 11, 2026
  2. added
    area-CodeGen-coreclr
    on Sep 11, 2026
  3. dotnet-policy-service commented on Sep 11, 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. MihuBot commented on Sep 11, 2026

    @MihuBot

    I'm a bot. Here are possible related and/or duplicate issues (I may be wrong):

  5. EgorBo commented on Sep 18, 2026

    @EgorBo
    MemberAuthor

    Affected SDK versions:

    • 11.0.100-rc.2.26467.112
  6. added a commit that references this issue on Sep 22, 2026
    f2ecb6b
  7. locked and limited conversation to collaborators on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions