Skip to content

JIT: (bug) CompareNotGreaterThan feeding a conditional select is evaluated as GreaterThan #133550

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 float Test(Vector128<float> a, Vector128<float> b, Vector128<float> x, Vector128<float> y) =>
        Vector128.ConditionalSelect(Sse.CompareNotGreaterThan(a, b), x, y).GetElement(0);

    static void Main()
    {
        if (!Avx512F.IsSupported)
            throw new PlatformNotSupportedException("AVX-512F is required.");

        var x = Vector128.Create(111.0f);
        var y = Vector128.Create(222.0f);

        // 1 is not greater than 2, so the mask is all-ones and x must be selected.
        Console.WriteLine(Test(Vector128.Create(1.0f), Vector128.Create(2.0f), x, y));
        // 2 is not greater than 2, so the mask is all-ones and x must be selected.
        Console.WriteLine(Test(Vector128.Create(2.0f), Vector128.Create(2.0f), x, y));
        // 3 is greater than 2, so the mask is all-zeros and y must be selected.
        Console.WriteLine(Test(Vector128.Create(3.0f), Vector128.Create(2.0f), x, y));
    }
}

Expected

111
111
222

Actual

222
222
111

The comparison result is inverted: every lane selects the opposite operand. Running the same
program with DOTNET_EnableAVX512=0 prints the expected values, so only the AVX-512 path is
affected.

Platform

Windows x64 with AVX-512F, local Checked build of dotnet/runtime main (ef97eb5).

Activity

  1. added this to the 12.0.0 milestone on Sep 10, 2026
  2. added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Sep 10, 2026
  3. dotnet-policy-service commented on Sep 10, 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 11, 2026
    d0d1509
  5. EgorBo commented on Sep 18, 2026

    @EgorBo
    MemberAuthor

    Affected SDK versions:

    • 11.0.100-rc.2.26467.112
  6. EgorBo commented on Sep 18, 2026

    @EgorBo
    MemberAuthor

    @tannergooding would you consider backporting the fix from #133589 to release/11.0?

    It currently only exists in main (12.0). The repro still fails on the shipped 11.0 RC2 SDK (11.0.100-rc.2.26467.112), while 8.0.425, 9.0.318 and 10.0.401 all behave correctly, so this is a regression introduced during the 11.0 cycle rather than a long-standing bug — 11.0 would ship with it.

    Note: this comment was produced by an AI agent; the repro was re-run against all four released SDKs to confirm the results above.

  7. added a commit that references this issue on Sep 20, 2026
    03c9811
  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