Skip to content

JIT: Vector128.Min/Max emit an uncompensated vminpd and lose NaN propagation when both operands are constant (regression from .NET 9) #133022

Closed

Description

@AndyAyersMS

Description

Vector128.Min and Vector128.Max are documented to propagate NaN. When both operands are compile-time constants, the JIT emits a bare vminpd/vmaxpd with none of the NaN/signed-zero compensation it emits for non-constant operands. Because vminpd returns its second source when either input is NaN, the result disagrees with the same expression written with opaque operands.

This is a regression in .NET 10. On .NET 9 the same expression is fully constant-folded to the correct value.

Reproduction Steps

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

class Repro
{
    [MethodImpl(MethodImplOptions.NoInlining)]
    static Vector128<double> Opaque(Vector128<double> v) => v;

    static string Bits(Vector128<double> v) =>
        $"[0x{BitConverter.DoubleToUInt64Bits(v[0]):X16}, 0x{BitConverter.DoubleToUInt64Bits(v[1]):X16}]";

    // both operands constant
    static Vector128<double> FoldedMin()
    {
        var x = Vector128.Create(double.NaN, 3.0);
        var y = Vector128.Create(3.0, double.NaN);
        return Vector128.Min(x, y);
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    static Vector128<double> RuntimeMin(Vector128<double> a, Vector128<double> b) => Vector128.Min(a, b);

    static void Main()
    {
        var x = Opaque(Vector128.Create(double.NaN, 3.0));
        var y = Opaque(Vector128.Create(3.0, double.NaN));
        Console.WriteLine($"Min folded  = {Bits(FoldedMin())}");
        Console.WriteLine($"Min runtime = {Bits(RuntimeMin(x, y))}");
    }
}

dotnet run -c Release on x64.

Expected behavior

Both lines print [0xFFF8000000000000, 0xFFF8000000000000].

Lane 0 is Min(NaN, 3.0), which must propagate NaN. The scalar equivalents in the same process agree:

Math.Min(double.NaN, 3.0) = 0xFFF8000000000000
Math.Max(double.NaN, 3.0) = 0xFFF8000000000000

Actual behavior

On .NET 10 and .NET 11 preview:

Vector128.Min folded   = [0x4008000000000000, 0xFFF8000000000000]   <-- lane 0 = 3.0
Vector128.Min runtime  = [0xFFF8000000000000, 0xFFF8000000000000]
Vector128.Max folded   = [0x4008000000000000, 0xFFF8000000000000]   <-- lane 0 = 3.0
Vector128.Max runtime  = [0xFFF8000000000000, 0xFFF8000000000000]

Lane 0 of the constant path is 3.0 where NaN is required. Max is affected identically.

Regression

Same machine and SDK, changing only <TargetFramework>:

TFM runtime constant path opaque path
net8.0 8.0.30 3.0 3.0 self-consistent, pre-IEEE semantics
net9.0 9.0.19 NaN NaN correct
net10.0 10.0.11 3.0 NaN diverges
net11.0 11.0.0-preview.7.26381.103 3.0 NaN diverges

The codegen shows what changed. On .NET 9, FoldedMin is genuinely constant-folded to the right answer:

; net9.0 - Repro:FoldedMin()
       vmovups  xmm0, xmmword ptr [reloc @RWD00]
RWD00  	dq	FFF8000000000000h, FFF8000000000000h      ; [NaN, NaN]  - correct

On .NET 10, the fold no longer happens; a bare vminpd is emitted over the two constants and evaluated at run time:

; net10.0 - Repro:FoldedMin()
       vmovups  xmm0, xmmword ptr [reloc @RWD00]
       vminpd   xmm0, xmm0, xmmword ptr [reloc @RWD16]
       vmovups  xmmword ptr [rcx], xmm0
RWD00  	dq	FFF8000000000000h, 4008000000000000h
RWD16  	dq	4008000000000000h, FFF8000000000000h

For contrast, the opaque-operand version on .NET 10 emits the full compensation sequence and is correct:

; net10.0 - Repro:RuntimeMin(Vector128<double>, Vector128<double>)
       vcmpeqpd  xmm2, xmm1, xmm0
       vxorps    xmm3, xmm3, xmm3
       vpcmpgtq  xmm3, xmm3, xmm0
       vandpd    xmm2, xmm3, xmm2
       vcmpneqpd xmm3, xmm0, xmm0        ; NaN test
       vorpd     xmm2, xmm3, xmm2
       vcmpltpd  xmm3, xmm0, xmm1
       vorpd     xmm2, xmm3, xmm2
       vblendvpd xmm0, xmm1, xmm0, xmm2

So the defect is path selection: with two constant operands the JIT takes neither the fold nor the compensation sequence.

Suspected cause

I have not built the JIT to confirm this, so please treat it as a reading of the source rather than a verified diagnosis.

In gtNewSimdMinMaxNode (src/coreclr/jit/gentree.cpp, ~line 26486) the NaN and signed-zero compensation is gated on:

else if ((cnsNode != nullptr) && !otherNode->OperIsConst())

The block contains the correct NaN guard (if (isNaN) { return isNumber ? otherNode : cnsNode; }), but the !otherNode->OperIsConst() clause requires exactly one constant operand. With both constant the block is skipped and an uncompensated NI_X86Base_Min/Max is emitted, which matches the codegen above.

Also possibly relevant: GenTreeVecCon::IsNaN (~line 20949) is all-lanes, so a partially-NaN constant such as the one here is not recognized as NaN. I tested that case against the single-constant path and it currently produces correct results, so it appears latent rather than separately exploitable.

Related

#130831 is the same function but a distinct defect: one constant operand, signed zero, and a wrongly-computed needsFixup inside the block. Here the block is never entered. That issue's description notes that "NaN cases are handled separately (operand swap for isNumber, natural propagation otherwise)", which holds only while one operand is non-constant.

Configuration

  • Windows x64, Release, AVX-512-capable host
  • SDK 11.0.100-preview.7.26381.103
  • Reproduces under DOTNET_EnableAVX2=0 and at tier0
  • Correct under DOTNET_EnableHWIntrinsic=0

Other information

Found by differential testing of constant-operand versus opaque-operand spellings of the same expression. Vector128.Add/Sub/Mul/Div were checked in the same sweep and do not diverge; only Min and Max do.

Note

This issue was authored with the help of GitHub Copilot.

Activity

  1. added
    untriaged
    on Sep 1, 2026
  2. added
    area-CodeGen-coreclr
    on Sep 1, 2026
  3. dotnet-policy-service commented on Sep 1, 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. AndyAyersMS commented on Sep 1, 2026

    @AndyAyersMS
    MemberAuthor

    Additional data on this issue, including a second and more clearly live failing shape in the same function.

    A second failing cell: a partially-NaN constant with one non-constant operand

    The report above covers two constant operands. The same function also mishandles a constant that is NaN in some lanes but not all, with the other operand non-constant. On 10.0.11, x64 Release:

    [MethodImpl(MethodImplOptions.NoInlining)]
    static Vector128<double> LeftConstMin(Vector128<double> b) =>
        Vector128.Min(Vector128.Create(double.NaN, double.PositiveInfinity), b);
    
    // b = opaque(Vector128.Create(+inf, NaN))
    neither const (reference) = [0xFFF8000000000000, 0xFFF8000000000000]   correct
    left  const               = [0x7FF0000000000000, 0xFFF8000000000000]   lane 0 = +inf, WRONG
    right const               = [0xFFF8000000000000, 0x7FF0000000000000]   lane 1 = +inf, WRONG
    

    Lane 0 is Min(NaN, +inf) and must be NaN. Codegen is a bare vminpd with the constant as src1:

           vmovups  xmm1, xmmword ptr [reloc @RWD16]   ; [FFF8000000000000, 7FF0000000000000]
           vminpd   xmm6, xmm1, xmm0

    Since minpd returns src2 when either operand is NaN, the constant's NaN lanes are discarded.

    This one goes through the else if ((cnsNode != nullptr) && !otherNode->OperIsConst()) branch rather than skipping it. The early-out uses GenTreeVecCon::IsNaN, which is documented as true only when all elements are NaN, so [NaN, +inf] falls past it into code whose comment reasons only about the other operand ("if other was NaN, we want to return other") while the subsequent needsFixup analysis considers only zeros. A constant that is NaN in some lanes and not others is handled by neither path.

    Unlike the two-constant case, this branch is unchanged on current main (d2ea726dd3d), so this shape appears live there as well.

    Note on the two-constant case

    That shape is sensitive to how the operands are spelled, which is worth knowing before attempting to reproduce. On the same 10.0.11 binary, with identical values:

    // triggers: bare minpd over two rodata constants
    var x = Vector128.Create(double.NaN, 3.0);
    var y = Vector128.Create(3.0, double.NaN);
    return Vector128.Min(x, y);
    
    // does NOT trigger: folds to a single correct constant
    return Vector128.Min(Vector128.Create(double.NaN, 3.0), Vector128.Create(3.0, double.NaN));

    A version written with static readonly fields also does not trigger, because the fields are not constants at that point and the compensating sequence is emitted instead.

    I have a report that the two-constant shape returns the correct value on main, which I have not been able to confirm myself and which may be explained by the spelling sensitivity above rather than by a fix. I could not locate a corresponding change: the gate is unchanged on main, and EvaluateBinarySimd in simd.h still has no GT_MIN/GT_MAX case. Treating the partially-NaN shape as the primary live repro is probably safest.

    Related

    #130831 (closed) is the third member of this family in the same block: one constant, signed zero, needsFixup computed incorrectly inside the branch.

    Note

    This comment was authored with the help of GitHub Copilot.

  5. AndyAyersMS commented on Sep 1, 2026

    @AndyAyersMS
    MemberAuthor

    Correcting two things in my comment above, both of which affect what a fix has to cover. A checked build of main at d2ea726dd3d was used for the reproductions I could not do myself; I have independently confirmed the control results below on shipped 10.0.11.

    1. The two-constant case reproduces on main — my "may be fixed" note was wrong

    I wrote that I had a report of the two-constant shape returning the correct value on main and could not confirm it. That report has since been retracted by its author: it was the spelling sensitivity I described, not a fix. The verbatim FoldedMin/FoldedMax from the original post reproduce on main at d2ea726dd3d, and identically at tier0_min, so this is not tied to an optimizer phase.

    Please disregard the suggestion that only the partially-NaN shape should be treated as live. Both shapes are live on main.

    2. Widening the !otherNode->OperIsConst() gate would not fix the partially-NaN case

    This is the more important correction. My original post pointed at the gate as the cause, which is right for the two-constant shape but misleading as a general diagnosis: the partially-NaN case already passes that gate and enters the compensation block, then produces the wrong answer anyway.

    Three controls isolate it. All three have exactly one constant operand, so all three enter the block:

    constant operand result
    [1.0, 2.0] — no NaN lane correct
    [NaN, NaN] — every lane NaN correct (the all-lanes isNaN early-out fires)
    [NaN, 3.0] — some lanes NaN WRONG

    Measured on 10.0.11, one constant operand against an opaque [3.0, NaN]:

    no NaN lane     got=[0x3FF0000000000000, 0xFFF8000000000000]  ok
    all NaN lanes   got=[0xFFF8000000000000, 0xFFF8000000000000]  ok
    partial NaN     got=[0x4008000000000000, 0xFFF8000000000000]  MISMATCH  (lane 0 should be NaN)
    

    The mechanism is that GenTreeVecCon::IsNaN is all-lanes, so [NaN, 3.0] skips the early-out; the needsFixup analysis below it considers only zeros (IsVectorZero / IsVectorNegativeZero), so !needsFixup holds and the code emits min cns, other with the constant as src1. Since minpd returns src2 when either operand is NaN, the constant's NaN lanes are dropped.

    So there appear to be two distinct defects in this block:

    • the gate excludes the two-constant case entirely, and
    • within the block, a constant that is NaN in some lanes but not all is handled by neither the early-out nor the needsFixup path.

    A fix that only relaxes the gate would leave the second one live.

    Note

    This comment was authored with the help of GitHub Copilot.

  6. AndyAyersMS commented on Sep 1, 2026

    @AndyAyersMS
    MemberAuthor

    The same defect also loses the sign of zero, with no NaN involved

    Measured on main @ d2ea726dd3d, windows.x64.Checked, AVX-512-capable host.

    This is the same function and the same code path, but it needs one constant
    operand rather than two, and no NaN anywhere — so it is reachable in a shape the
    current repro does not cover, and a fix aimed only at the two-constant gate
    would not address it.

    Repro

    [MethodImpl(MethodImplOptions.NoInlining)]
    static Vector128<double> Opaque(Vector128<double> v) => v;
    
    // one constant operand; the constant is -0.0 in lane 1 only
    static Vector128<double> ZeroLeftConst()
    {
        var x = Vector128.Create(-1.0, -0.0);            // constant
        var y = Opaque(Vector128.Create(-0.0, 0.0));
        return Vector128.Min(x, y);
    }
    
    // same values, neither operand constant
    static Vector128<double> ZeroNeither()
    {
        var x = Opaque(Vector128.Create(-1.0, -0.0));
        var y = Opaque(Vector128.Create(-0.0, 0.0));
        return Vector128.Min(x, y);
    }

    Lane 1 is Min(-0.0, +0.0), which must be -0.0.

    ZeroLeftConst   0xBFF0000000000000, 0x0000000000000000   <- lane 1 = +0.0  WRONG
    ZeroNeither     0xBFF0000000000000, 0x8000000000000000   <- lane 1 = -0.0  correct
    

    Identical under tier0_min. The expected answer is established in the same
    process rather than quoted from the spec:

    Math.Min(-0.0, 0.0)   = 0x8000000000000000
    double.Min(-0.0, 0.0) = 0x8000000000000000
    

    Generated code

    The constant-operand form emits a bare vminpd with the constant as src1, 65
    bytes in total:

    ; Program:ZeroLeftConst()
           vmovups  xmm0, xmmword ptr [reloc @RWD16]      ; the constant
           vminpd   xmm0, xmm0, xmmword ptr [rsp+0x30]    ; no fixup
    RWD16  	dq	BFF0000000000000h, 8000000000000000h      ; [-1.0, -0.0]

    The all-opaque form emits the compensation, including the sign-of-zero handling:

    ; Program:ZeroNeither(...)
           vcmpeqpd xmm0, xmm0, xmmword ptr [rsp+0x40]
           vxorps   xmm1, xmm1, xmm1
           vpcmpgtq xmm1, xmm1, xmmword ptr [rsp+0x30]     ; sign-of-zero test
           ...

    minpd src1, src2 returns src2 when both inputs are zero of either sign, so
    with the constant as src1 the -0.0 lane is discarded.

    The boundary, with controls

    All three use exactly one constant operand, so all three enter the same block:

    constant lane 1
    [-1.0, -2.0] — no zero lane -2.0 correct
    [-0.0, -0.0] — -0.0 in every lane -0.0 correct
    [-1.0, -0.0] — -0.0 in some lanes +0.0 WRONG

    Refinement (later comment): the safe case is not “the constant is all zeros”. [-0.0, +0.0] is all zeros but counts as some, and is wrong — so it must not be used as an “all zeros, should be fine” control. A further correction narrows it again: for MinNumber even a constant with no -0.0 lane is unsafe when the other operand can contain -0.0 — so safety is a property of the operand pair, not of the constant alone.

    Cause

    gtNewSimdMinMaxNode, the !isNumber vector branch:

    needsFixup = cnsNode->IsVectorNegativeZero(simdBaseType);
    ...
    if (!needsFixup || compOpportunisticallyDependsOn(InstructionSet_AVX512))
    {
        intrinsic = NI_X86Base_Min;
        op1 = cnsNode;
        op2 = otherNode;
        canHandle = true;
    }

    The block's own comment states the requirement precisely:

    "For !isNumber we have the inverse and want min cns, other and can only
    handle cns being -0 if Avx512F is supported … if cns was -0 and other was +0
    we'd want to return -0 and so need to be able to fixup the result."

    That is right. But GenTreeVecCon::IsNegativeZero returns false at the first
    element that is not -0.0, so it recognises the situation only when every
    lane is -0.0. A constant that is -0.0 in one lane and something else in
    another therefore reports needsFixup == false, and the bare instruction is
    emitted with the very case the comment describes still present in that lane.

    This is the same shape as the IsVectorNaN observation already in the issue —
    IsNaN, IsVectorZero and IsNegativeZero are all whole-vector predicates,
    while the property they gate is per lane.

    Scope

    16 operation/pattern combinations disagree between operand spellings,
    identically at fullopts and tier0_min: Min, Max, MinNumber and
    MaxNumber, over four signed-zero lane patterns, in both operand positions.
    MinMagnitude, MaxMagnitude and their Number variants are unaffected — they
    take the isMagnitude branch, which does not perform the zero fixup.

    Suggestion for the fix

    The emission requires the absence of the special value in every lane, while
    the predicates establish only its universal presence. Complementary
    predicates — no lane -0.0, no lane zero, no lane NaN — would gate the bare
    instruction correctly and fall back to the compensation sequence for a mixed
    constant.

    For test coverage: for each of Min, Max, MinNumber, MaxNumber, sweep
    constants containing the special value in no, some and all lanes, in
    both operand positions. Only the some column is currently wrong, in both the
    NaN and the signed-zero families, and nothing existing reaches it.

    Add a width axis alongside that: Vector256<double> reproduces both families too (comment), so a fix scoped to Vector128 would be incomplete.

    Note on verification

    Results are sensitive to how the expression is spelled — the same expression can
    be wrong written one way and correct written another. The one-constant forms
    above were wrong in every spelling and configuration tried, so they are the more
    reliable regression tests.

    Found by differential testing across operand spellings (ReifyCs).

  7. AndyAyersMS commented on Sep 2, 2026

    @AndyAyersMS
    MemberAuthor

    One data point for scoping a fix: this is not Vector128-only. Vector256<double> reproduces both forms, on stock .NET 10.0.11 (release runtime, no checked JIT or stress, DOTNET_TieredCompilation=0):

    V256 NaN    const [NaN,3,3,3]      -> lane 0 = 0x4008000000000000  (3.0, should be NaN)
    V256 -0.0   const [-1,-0.0,-1,-1]  -> lane 1 = 0x0000000000000000  (+0.0, should be -0.0)
    

    with the all-opaque spelling of the same values correct in both cases, as before. Max matches Min.

    That is expected from the mechanism already described here — the branch is chosen by operand constant-ness, not simd size — but it means a fix and its test both want a width axis, not just the no/some/all-lanes axis.

    Vector64 and Vector512 did not reproduce for me, but neither is hardware-accelerated on this host, so both took software fallbacks and that result says nothing about the intrinsic path. They are unknown, not clean — Vector512 would need an AVX-512 machine and Vector64 an arm64 one.

    Standalone repro: https://github.com/AndyAyersMS/ReifyCs/blob/main/findings/2026-09-01_minmax_partial_nan_const/v256_shipping/Program.cs

  8. AndyAyersMS commented on Sep 2, 2026

    @AndyAyersMS
    MemberAuthor

    Warning

    Partially corrected below. The “no lane -0.0 → correct” clause in this
    comment is wrong for MinNumber: an all-+0.0 constant has no -0.0 lane
    but still differs when the other operand can contain -0.0. See the correction.
    Min, Max and MaxNumber are unaffected, and the rest of this comment stands.

    One refinement to the "all lanes" column above, because it can be read the wrong way round and would cost someone a regression test.

    The safe case is not "the constant is all zeros". IsVectorNegativeZero requires every lane to be -0.0 specifically, so an all-zero constant of mixed sign fails exactly like a partially-zero one. On stock .NET 10.0.11 (release, DOTNET_TieredCompilation=0), constant operand on the left, all-opaque spelling as the reference:

    
    Min([-0,+0],       op[+0,+0])   const-> +0.0,+0.0   opaque-> -0.0,+0.0   differs
    
    MinNumber([+0,-0], op[-0,+0])   const-> +0.0,-0.0   opaque-> -0.0,-0.0   differs
    
    MaxNumber([-0,+0], op[+0,+0])   const-> -0.0,+0.0   opaque-> +0.0,+0.0   differs
    
    Min([-0,-0],       op[+0,+0])   agree   (every lane -0.0)
    
    Min([1,2],         op[-0,+0])   agree   (no lane -0.0)
    
    

    So the boundary for a constant operand is: no lane -0.0 → correct; every lane -0.0 → correct; some lanes -0.0 → wrong, and [-0.0, +0.0] counts as some despite being all zeros.

    Correction (later comment): the first clause holds only for Min, Max and MaxNumber. For MinNumber a constant with no -0.0 lane is not safe — MinNumber(const[+0,+0], opaque containing -0.0) differs. Safety is a property of the operand pair, not of the constant alone. The [1,2] row below is the only case I ran for that clause, and ordinary numbers do not probe the boundary.

    Worth stating because a test using [-0.0, +0.0] as its "all zeros, should be fine" control would pass while the bug was still present.

    Repro: https://github.com/AndyAyersMS/ReifyCs/blob/main/findings/2026-09-01_minmax_partial_nan_const/mixedzero/Program.cs

  9. self-assigned this
    on Sep 2, 2026
  10. AndyAyersMS commented on Sep 2, 2026

    @AndyAyersMS
    MemberAuthor

    Correction to my comment above (5512943404): row 1 of that table is wrong for MinNumber.

    I wrote that a constant with no -0.0 lane is correct. An all-+0.0 constant has no -0.0 lane, so the table calls it safe — and for MinNumber it is not. Stock .NET 10.0.11, DOTNET_TieredCompilation=0, constant operand on the left, all-opaque spelling as the reference:

    MinNumber const[+0,+0]  opaque[-0,-0]   const-> +0,+0   opaque-> -0,-0   differs
    MinNumber const[+0,+0]  opaque[-0,+0]   const-> +0,+0   opaque-> -0,+0   differs
    Min       const[+0,+0]  opaque[-0,-0]   agree
    Max       const[+0,+0]  opaque[-0,-0]   agree
    MaxNumber const[+0,+0]  opaque[-0,-0]   agree
    

    Only MinNumber is affected on that row; Min, Max and MaxNumber are genuinely fine there.

    The reason I missed it: the only case I ran for that row was const[1.0, 2.0] — ordinary numbers with no zero in them at all. That tests the row's label, not its boundary.

    So the safety condition is not a property of the constant. It depends on the operand pair: MinNumber with a +0.0 constant is unsafe whenever the other operand can contain -0.0. Corrected:

    constant
    no lane is -0.0, op is Min / Max / MaxNumber correct
    no lane is -0.0, op is MinNumber, other operand may contain -0.0 wrong
    every lane is -0.0 correct
    some lanes -0.0, including all-zero mixed sign like [-0.0, +0.0] wrong

    Worth flagging for whoever fixes this, because it is the same shape as the defect itself: my table characterised safety per-vector when the property is per-pair — which is the mistake IsVectorNegativeZero makes by gating a per-lane property on a whole-vector predicate. A regression test derived from the original row 1 would pass while MinNumber was still wrong.

    Repro: https://github.com/AndyAyersMS/ReifyCs/blob/main/findings/2026-09-01_minmax_partial_nan_const/row1_minnumber/Program.cs

  11. AndyAyersMS commented on Sep 3, 2026

    @AndyAyersMS
    MemberAuthor

    Data point on hardware coverage: this defect's reach appears to be wider on AVX512 hardware, and everything reported on this issue so far — including my comments — was measured on hosts without it.

    The gate

    gtNewSimdMinMaxNode (src/coreclr/jit/gentree.cpp, line 26554 on d2ea726dd3d) only takes the constant-operand path when the needed fixup is available:

    if (!needsFixup || compOpportunisticallyDependsOn(InstructionSet_AVX512))
    {
        // Given the checks, op1 can safely be the cns and op2 the other node
        intrinsic = isScalar ? NI_X86Base_MaxScalar : NI_X86Base_Max;
        op1 = cnsNode;
        op2 = otherNode;
        canHandle = true;
    }

    with needsFixup set from IsVectorZero() / IsVectorNegativeZero() just above, and the block comment stating the intent directly:

    …can only handle cns being -0 if Avx512F is supported … if cns was -0 and other was +0 we'd want to return -0 and so need to be able to fixup the result.

    So on a host without AVX512, a zero constant that sets needsFixup makes canHandle false and the JIT declines the constant path entirely. With AVX512 the second disjunct fires, the bare min/max is emitted, and correctness depends on the fixup. A non-AVX512 host therefore cannot exercise the path at all.

    Measurement

    Differential fuzzing of constant-vs-opaque spellings of the same min/max expressions, identical generator commit so identical programs, identical four-config matrix (fullopts, fullopts_no_avx512, fullopts_no_avx2, tier0_min), identical seed range:

    host Avx512F.IsSupported trials disagreeing
    Xeon Platinum 8370C True 2500 1032 (41%), all MinNumber/MaxNumber, fullopts only
    non-AVX512 x64 False 300 0

    At a 41% rate, 300 trials on the second host would be expected to produce ~120 disagreements. It produced none.

    I want to be precise about what is and is not mine: the AVX512 row is a report from another machine that I have not reproduced myself — I have no AVX512 hardware. What I verified directly is the non-AVX512 row, that the two runs use byte-identical generated programs, and the source gate quoted above.

    Why it matters for the fix

    • A fix validated only on non-AVX512 hardware would not execute the gated path.
    • A regression test derived from this issue's current text may pass on CI hardware lacking AVX512 while the defect is live on hardware that has it.

    So it would be worth running any candidate fix, and any new regression test, on an AVX512 machine specifically — and worth an Avx512F.IsSupported line in the repro output so a clean result cannot be mistaken for a correct one.

    One correction to my own earlier comments

    The five-case table I used to characterise this family is not a probe of the gate above, and I do not want it read as one. An all-NaN constant returns early at line 26499 (return otherNode for MinNumber/MaxNumber, return cnsNode otherwise) and never reaches the needsFixup logic at all. And IsVectorZero() is all-bits-zero, so only a +0.0 constant sets needsFixup for MinNumber — a -0.0 constant does not. Cases built from all-NaN or -0.0 constants exercise neither branch of the gate.

  12. AndyAyersMS commented on Sep 3, 2026

    @AndyAyersMS
    MemberAuthor

    Upshot of above, make sure we test fixes on both AVX-512 and non-AVX-512 HW.

  13. added a commit that references this issue on Sep 4, 2026
    a6bb62d
  14. removed
    untriaged
    on Sep 4, 2026
  15. locked and limited conversation to collaborators on Oct 5, 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

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions