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.
Minimal repro
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=1prints the expected value.MultiplyWideningAndAddSaturatebehaves the same way.