Skip to content

JIT: (bug) negating an AVX-512 multiply changes its explicit rounding mode #133519

Closed

Description

@EgorBo

Repro

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

class Program {
    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
    static Vector512<float> Test(Vector512<float> x) =>
        -Avx512F.Multiply(x, Vector512.Create(1.5f), FloatRoundingMode.ToPositiveInfinity);

    static void Main() {
        if (!Avx512F.IsSupported)
            throw new PlatformNotSupportedException("AVX-512F is required.");
        float x = BitConverter.Int32BitsToSingle(0x3F800001);
        Console.WriteLine(Test(Vector512.Create(x)).AsUInt32().GetElement(0).ToString("X8"));
    }
}

Expected

BFC00002

The exact product is halfway between two floats. Rounding up gives 0x3FC00002; negating gives 0xBFC00002.

Actual

BFC00001

The negation moved inside the rounded multiply, so rounding went the wrong way.

Platform

Windows x64 with AVX-512F, .NET 11.0.0-rc.1.26425.128.

Activity

  1. added this to the 12.0.0 milestone on Sep 9, 2026
  2. added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Sep 9, 2026
  3. dotnet-policy-service commented on Sep 9, 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. self-assigned this
    on Sep 9, 2026
  5. changed the title [-]JIT: negating an AVX-512 multiply changes its explicit rounding mode[/-] [+]JIT: (bug) negating an AVX-512 multiply changes its explicit rounding mode[/+] on Sep 10, 2026
  6. added a commit that references this issue on Sep 10, 2026
    fb99e10
  7. EgorBo commented on Sep 18, 2026

    @EgorBo
    MemberAuthor

    Affected SDK versions:

    • 10.0.401
    • 11.0.100-rc.2.26467.112
  8. locked and limited conversation to collaborators on Oct 19, 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-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