Skip to content

Test failure: System.Runtime.Intrinsics.Tests.Vectors.Vector512Tests.ConvertToInt32Test #127440

Closed

Description

@VincentBu

Failed in: runtime-coreclr libraries-jitstress-random 20260425.1

Failed tests:

net11.0-linux-Release-x64-jitstress_random_1-AzureLinux.3.Amd64.Open
- System.Runtime.Intrinsics.Tests.Vectors.Vector512Tests.ConvertToInt32Test
net11.0-linux-Release-x64-jitstress_random_2-AzureLinux.3.Amd64.Open
- System.Runtime.Intrinsics.Tests.Vectors.Vector512Tests.ConvertToInt32Test

Error message:

Assert.Equal() Failure: Values differ
Expected: <-2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648>
Actual:   <-107374176, -107374176, -107374176, -107374176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>

Stack trace:

   at System.Runtime.Intrinsics.Tests.Vectors.Vector512Tests.ConvertToInt32Test() in /_/src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector512Tests.cs:line 6367
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args) in /_/src/coreclr/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.CoreCLR.cs:line 39
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) in /_/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs:line 57

Kusto query result:

Queued Pipeline Pipeline Configuration OS Arch Test Outcome Properties Build Reason
2026-04-26 10:56:04.460000+00:00 runtime-extra-platforms Release osx.15.amd64.open x64 System.Runtime.Intrinsics.Tests.Vectors.Vector512Tests.ConvertToInt32Test Failed {"operatingSystem":"OSX.15.Amd64.Open","System.PhaseAttempt":"2","BuildNumber":"20260425.1","System.JobAttempt":"2","System.JobId":"440ea7f6-c32f-5952-47d6-56dae7644f8a","configuration":"Release","BuildId":"1396883","Project":"public","DefinitionName":"runtime-extra-platforms","System.StageAttempt":"2","System.JobName":"__default","CollectionUri":"https://dev.azure.com/dnceng-public/","DefinitionId":"154","System.StageName":"Build","runtimeFlavor":"coreclr","AzurePipelinesTestRunId":"38961892","System.PhaseName":"build_iossimulator_x64_Release_AllSubsets_CoreCLR","Reason":"Schedule","architecture":"x64"} Schedule
2026-04-26 04:30:03.811000+00:00 runtime-extra-platforms Release osx.15.amd64.open x64 System.Runtime.Intrinsics.Tests.Vectors.Vector512Tests.ConvertToInt32Test Failed {"Project":"public","BuildNumber":"20260425.1","System.JobAttempt":"1","DefinitionId":"154","BuildId":"1396883","Reason":"Schedule","configuration":"Release","System.PhaseAttempt":"1","DefinitionName":"runtime-extra-platforms","CollectionUri":"https://dev.azure.com/dnceng-public/","System.PhaseName":"build_iossimulator_x64_Release_AllSubsets_CoreCLR","System.JobId":"d413ef91-6ac1-5648-b23b-ad89eaf81672","System.StageName":"Build","runtimeFlavor":"coreclr","architecture":"x64","System.JobName":"__default","AzurePipelinesTestRunId":"38959244","System.StageAttempt":"1","operatingSystem":"OSX.15.Amd64.Open"} Schedule
2026-04-25 22:32:01.769000+00:00 runtime-nativeaot-outerloop Release azurelinux.3.amd64.open.rt x64 System.Runtime.Intrinsics.Tests.Vectors.Vector512Tests.ConvertToInt32Test Failed {"System.JobId":"abdbb26b-d534-5e94-28a6-1260271ac680","AzurePipelinesTestRunId":"38955702","DefinitionId":"265","configuration":"Release","System.JobName":"__default","BuildId":"1396680","DefinitionName":"runtime-nativeaot-outerloop","System.StageAttempt":"1","Reason":"Schedule","runtimeFlavor":"coreclr","CollectionUri":"https://dev.azure.com/dnceng-public/","System.PhaseName":"build_linux_x64_Release_NativeAOT_Libs","System.StageName":"Build","architecture":"x64","Project":"public","operatingSystem":"(Debian.13.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:debian-13-helix-amd64","BuildNumber":"20260425.2","System.JobAttempt":"1","System.PhaseAttempt":"1"} Schedule
2026-04-25 10:34:35.249000+00:00 runtime-nativeaot-outerloop Release azurelinux.3.amd64.open.rt x64 System.Runtime.Intrinsics.Tests.Vectors.Vector512Tests.ConvertToInt32Test Failed {"System.StageName":"Build","architecture":"x64","System.PhaseName":"build_linux_musl_x64_Release_NativeAOT_Libs","System.StageAttempt":"1","System.JobId":"20e6f673-0b0c-5c85-377c-5d941d4c8ee3","runtimeFlavor":"coreclr","BuildNumber":"20260425.1","operatingSystem":"(Alpine.323.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:alpine-3.23-helix-amd64","Project":"public","System.PhaseAttempt":"1","BuildId":"1396429","Reason":"Schedule","System.JobAttempt":"1","DefinitionName":"runtime-nativeaot-outerloop","configuration":"Release","System.JobName":"__default","AzurePipelinesTestRunId":"38949484","DefinitionId":"265","CollectionUri":"https://dev.azure.com/dnceng-public/"} Schedule
2026-04-25 05:16:22.563000+00:00 runtime-extra-platforms Release osx.15.amd64.open x64 System.Runtime.Intrinsics.Tests.Vectors.Vector512Tests.ConvertToInt32Test Failed {"BuildId":"1396313","System.StageName":"Build","System.StageAttempt":"1","operatingSystem":"OSX.15.Amd64.Open","configuration":"Release","AzurePipelinesTestRunId":"38946736","architecture":"x64","BuildNumber":"20260424.6","System.JobId":"d413ef91-6ac1-5648-b23b-ad89eaf81672","Project":"public","CollectionUri":"https://dev.azure.com/dnceng-public/","System.JobName":"__default","System.PhaseName":"build_iossimulator_x64_Release_AllSubsets_CoreCLR","DefinitionId":"154","DefinitionName":"runtime-extra-platforms","Reason":"Schedule","System.JobAttempt":"1","System.PhaseAttempt":"1","runtimeFlavor":"coreclr"} Schedule

Activity

  1. added
    JitStress
    blocking-clean-ci-optional
    on Apr 27, 2026
  2. added
    untriaged
    on Apr 27, 2026
  3. added
    area-CodeGen-coreclr
    on Apr 27, 2026
  4. dotnet-policy-service commented on Apr 27, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
    See info in area-owners.md if you want to be subscribed.

  5. mangod9 commented on Apr 28, 2026

    @mangod9
    Member

    Some analysis is below, @EgorBo and @tannergooding to validate:

    Symptoms

    Vector512Tests.ConvertToInt32Test produces wrong results on all non-AVX512 x64 platforms:

    Expected: <-2147483648 × 16>   (Int32.MinValue for all 16 elements)
    Actual:   <-107374176, -107374176, -107374176, -107374176, 0, 0, 0, 0, ...>
    
    • Only 4 of 16 elements populated (128-bit operation instead of 512-bit)
    • The 4 computed values are wrong (0xF99999A0 instead of 0x80000000)
    • Remaining elements are zero/uninitialized — vary between runs

    Failing platforms (all Release, all non-AVX512):

    • runtime-coreclr libraries-jitstress-random — Linux x64
    • runtime-extra-platforms — macOS x64 iossimulator
    • runtime-nativeaot-outerloop — Linux x64 (Alpine + AzureLinux)

    First failure: April 25, 2026 05:16 UTC


    Root Cause: Missing ISA Guard + Recent Trigger

    The missing guard (since April 2023)

    PR: #84932 — "Accelerate Vector512 ConvertToSingle and ConvertToInt32"

    When NI_Vector512_ConvertToInt32 was added to impSpecialIntrinsic in hwintrinsicxarch.cpp, the Vector512 case was grouped with Vector128/Vector256 without an AVX-512 ISA check:

    case NI_Vector128_ConvertToInt32:
    case NI_Vector256_ConvertToInt32:
    case NI_Vector512_ConvertToInt32:   // ← no ISA gate for Vector512!
    {
        op1     = impSIMDPopStack();
        retNode = gtNewSimdCvtNode(retType, op1, TYP_INT, simdBaseType, simdSize);
        break;
    }

    Vector128 and Vector256 work fine without AVX-512 (using SSE/AVX instructions). But when the Vector512 case enters gtNewSimdCvtNode → gtNewSimdCvtNativeNode, it unconditionally selects NI_AVX512_ConvertToVector512Int32WithTruncation — an AVX-512 instruction — for simdSize=64.

    Compare with ConvertToInt64 which correctly gates on AVX-512:

    case NI_Vector512_ConvertToInt64:
    {
        if (compOpportunisticallyDependsOn(InstructionSet_AVX512))  // ← proper gate
        {
            op1     = impSIMDPopStack();
            retNode = gtNewSimdCvtNode(retType, op1, TYP_LONG, simdBaseType, simdSize);
        }
        break;  // falls back to managed when AVX512 unavailable
    }

    Why it was harmless for 3 years: On non-AVX512 machines, the JIT never reached this code path. The managed fallback in Vector512.ConvertToInt32 (which splits into two Vector256 operations) always ran instead — the JIT had no reason to intrinsify a Vector512 call that would be expanded from the managed code.

    The trigger — PR #127124 + PR #127402 (April 24, 2026)

    PR: #127124 — "JIT: propagate vector constants through assertion prop"
    PR: #127402 — "Allow O2K_CONST_VEC to handle all TYP_SIMD32/64"
    Author: @EgorBo

    These PRs enable the JIT to constant-propagate Vector512 values. The test does:

    Vector512.ConvertToInt32(Vector512.Create(float.MinValue))

    With the new constant propagation, Vector512.Create(float.MinValue) becomes a compile-time constant. The JIT now attempts to fold the ConvertToInt32 call through the intrinsic path (gtNewSimdCvtNode) instead of falling back to managed code — even on non-AVX512 machines. This hits the missing guard for the first time.

    Timeline

    Date Event
    Apr 2023 PR #84932 adds NI_Vector512_ConvertToInt32 without AVX-512 gate
    Apr 2024 PR #97529 adds gtNewSimdCvtNode saturation logic (correctly gated by assert, but only in Debug)
    Apr 2024 PR #100993 adds ConvertToInt32Test (test has existed for 2 years)
    Apr 24, 2026 PR #127124 + #127402 enable Vector512 constant prop (bug exposed)
    Apr 25, 2026 First test failures on iossimulator, NativeAOT

    The Bug in Detail

    In hwintrinsicxarch.cpp (line 1849-1858), when the JIT recognizes NI_Vector512_ConvertToInt32, it calls gtNewSimdCvtNode without checking for AVX-512 support:

    case NI_Vector128_ConvertToInt32:
    case NI_Vector256_ConvertToInt32:
    case NI_Vector512_ConvertToInt32:   // ← no ISA gate for Vector512!
    {
        op1     = impSIMDPopStack();
        retNode = gtNewSimdCvtNode(retType, op1, TYP_INT, simdBaseType, simdSize);
        break;
    }

    Compare with ConvertToInt64 which correctly gates:

    case NI_Vector512_ConvertToInt64:
    {
        if (compOpportunisticallyDependsOn(InstructionSet_AVX512))  // ← proper gate
        {
            op1     = impSIMDPopStack();
            retNode = gtNewSimdCvtNode(retType, op1, TYP_LONG, simdBaseType, simdSize);
        }
        break;  // falls back to managed when AVX512 unavailable
    }

    For ConvertToInt32, Vector128 and Vector256 work fine without AVX-512 (using SSE/AVX instructions). But Vector512 requires AVX-512 for the native truncation instruction, and there's no fallback in gtNewSimdCvtNativeNode for simdSize=64 without it.


    Fix

    File: src/coreclr/jit/hwintrinsicxarch.cpp — Gate Vector512 ConvertToInt32 on AVX-512, matching the ConvertToInt64 pattern:

    case NI_Vector128_ConvertToInt32:
    case NI_Vector256_ConvertToInt32:
    case NI_Vector512_ConvertToInt32:
    {
        assert(sig->numArgs == 1);
        assert(simdBaseType == TYP_FLOAT);
    
        if ((simdSize == 64) && !compOpportunisticallyDependsOn(InstructionSet_AVX512))
        {
            // Vector512 float->int conversion requires AVX-512 for the native
            // truncation instruction. Fall back to managed implementation.
            break;
        }
    
        op1     = impSIMDPopStack();
        retNode = gtNewSimdCvtNode(retType, op1, TYP_INT, simdBaseType, simdSize);
        break;
    }

    Same pattern applied to ConvertToInt32Native.

    When AVX-512 is unavailable and simdSize == 64, retNode stays null and the JIT falls back to the managed Vector512.ConvertToInt32 implementation, which correctly splits into two Vector256.ConvertToInt32 calls using SSE/AVX instructions.

    Optionally, the assertions in gtNewSimdCvtNode and gtNewSimdCvtNativeNode in gentree.cpp can also be tightened to add (simdSize != 64) to the non-AVX512 condition — this would catch the issue in Debug/Checked builds if any other caller bypasses the gate in the future.

  6. added a commit that references this issue on Apr 28, 2026
    bfa8018
  7. EgorBo commented on Apr 28, 2026

    @EgorBo
    Member

    @mangod9 in case if you're interested in feedback for the analysis, it seems like it's not correct, my local copilot identified a use-before-def bug elsewhere https://github.com/dotnet/runtime/pull/127524/changes

  8. mangod9 commented on Apr 28, 2026

    @mangod9
    Member

    ok interesting, so the determination that it was a pre-existing issue exposed by the latest PR was incorrect, or the suggested fix was not right? Maybe it over pivoted on the fact that it was failing on all non-avx512 legs?

  9. EgorBo commented on Apr 29, 2026

    @EgorBo
    Member

    ok interesting, so the determination that it was a pre-existing issue exposed by the latest PR was incorrect, or the suggested fix was not right? Maybe it over pivoted on the fact that it was failing on all non-avx512 legs?

    The bug was pre-existing, but the suggested fix doesn't fix the problem and effectively incorrect. But I am not sure the analysis could catch that easily, my local one had dive into JitDump

  10. mangod9 commented on Apr 29, 2026

    @mangod9
    Member

    ok makes sense, yeah its been somewhat off finding the exact fix, but good that it's still finding a reasonable root cause.

  11. added a commit that references this issue on Apr 29, 2026
    9a6034a
  12. removed
    untriaged
    on Apr 29, 2026
  13. locked and limited conversation to collaborators on May 29, 2026
  14. added a commit that references this issue on Jul 15, 2026
    f8d6eb2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

JitStressarea-CodeGen-coreclrblocking-clean-ci-optional

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions