Skip to content

JIT: (bug) [ARM64] LSRA consecutive-register wraparound filter accepts V31,V0,V1 while V1 is busy (assert "Not sufficient consecutive registers available") #135508

Closed

Description

@EgorBo

LinearScan::filterConsecutiveCandidates accepts a wraparound start register even when the sequence includes a busy register. Checked JITs then assert. Release JITs silently fall back to MinOpts.

Minimal Repro

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

public static class Program
{
    public static int Main()
    {
        var a = new byte[256];
        for (int i = 0; i < a.Length; i++) a[i] = (byte)i;
        Console.WriteLine(Test(default, Vector128.Create((byte)0xAA), Vector128.Create((byte)5), a));
        return 100;
    }

    static Vector128<byte> L(byte[] a, int i) => Vector128.Create(a, i * 16);

    [MethodImpl(MethodImplOptions.NoInlining)]
    static ulong Test(Vector128<byte> unused, Vector128<byte> def, Vector128<byte> idx, byte[] a)
    {
        Vector128<byte> l0 = L(a, 0), l1 = L(a, 1), l2 = L(a, 2), l3 = L(a, 3), l4 = L(a, 4), l5 = L(a, 5), l6 = L(a, 6), l7 = L(a, 7);
        Vector128<byte> l8 = L(a, 8), l9 = L(a, 9), l10 = L(a, 10), l11 = L(a, 11), l12 = L(a, 12), l13 = L(a, 13), l14 = L(a, 14);
        Vector128<byte> r = AdvSimd.Arm64.VectorTableLookupExtension(def, (l3, l7, l1), idx & Vector128.Create((byte)63));
        return (r ^ l0 ^ l1 ^ l2 ^ l3 ^ l4 ^ l5 ^ l6 ^ l7 ^ l8 ^ l9 ^ l10 ^ l11 ^ l12 ^ l13 ^ l14).AsUInt64().GetElement(0);
    }
}

Run with DOTNET_TieredCompilation=0 on arm64.

Expected

14034272802312799429, which is also what DOTNET_JITMinOpts=1 prints.

Actual

Assertion failed '!"Not sufficient consecutive registers available."' in 'Program:Test(System.Runtime.Intrinsics.Vector128`1[byte],System.Runtime.Intrinsics.Vector128`1[byte],System.Runtime.Intrinsics.Vector128`1[byte],byte[]):ulong' during 'LSRA build intervals' (IL size 278; hash 0xf75fa69d; FullOpts)
    File: src/coreclr/jit/lsra.cpp:13742

Regression?

No. On .NET 10.0.12 (Release), the same noway_assert silently makes Test fall back to MinOpts.

Notes

  • filterConsecutiveCandidates (lsraarm64.cpp) checks wraparound sequences with (floatCandidates & mask) != RBM_NONE instead of == mask. With V31 and V0 free, it accepts V31 as the start of a 3-register sequence even though V1 (holding def, in use at the tbx) isn't a candidate.
  • The 4-register wraparound masks are copy-pasted (all three are V0|V29|V30|V31), so starts V30 and V31 are never validated against the right registers.
  • The same code is used by the SVE multi-register APIs (Sve.StoreAndZip, Sve.Load3xVectorAndUnzip/Load4xVectorAndUnzip).
  • Related but separate V31 -> V0 wraparound bug: ARM64 JIT: incorrect code when Load4xVector128 result registers wrap from V31 to V0 #134604.

Activity

  1. added this to the 12.0.0 milestone on Oct 9, 2026
  2. added
    area-CodeGen-coreclr
    on Oct 9, 2026
  3. dotnet-policy-service commented on Oct 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. added a commit that references this issue on Oct 31, 2026
    22adabc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-CodeGen-coreclr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions