Skip to content

JIT: (bug) [ARM64] Assert '!isRefPositionActive(recentAssignedRef, refLocation)' allocating a 4-register tbx table under register pressure #135509

Closed

Description

@EgorBo

While selecting consecutive registers for a 4-register tbx table, LSRA considers spilling a register whose assigned interval is active at the current location, which asserts in canSpillReg.

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[64 * 16];
        for (int i = 0; i < a.Length; i++) a[i] = (byte)(i * 7 + 3);
        Console.WriteLine(Test(a, 3));
        return 100;
    }

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

    [MethodImpl(MethodImplOptions.NoInlining)]
    static ulong Test(byte[] a, int k)
    {
        Vector128<byte> v0=L(a,0),v1=L(a,1),v2=L(a,2),v3=L(a,3),v4=L(a,4),v5=L(a,5),v6=L(a,6),v7=L(a,7),v8=L(a,8),v9=L(a,9);
        Vector128<byte> v10=L(a,10),v11=L(a,11),v12=L(a,12),v13=L(a,13),v14=L(a,14),v15=L(a,15),v16=L(a,16),v17=L(a,17),v18=L(a,18),v19=L(a,19);
        Vector128<byte> v20=L(a,20),v21=L(a,21),v22=L(a,22),v23=L(a,23),v24=L(a,24),v25=L(a,25),v26=L(a,26);
        Vector128<byte> idx = L(a, 30) & Vector128.Create((byte)63);
        Vector128<byte> r = Vector128<byte>.Zero;
        for (int i = 0; i < k; i++)
        {
            r ^= AdvSimd.Arm64.VectorTableLookupExtension(v0, (v1, v2, v3, v4), idx);
            r ^= AdvSimd.Arm64.VectorTableLookupExtension(v4, (v5, v6, v7, v9), idx + v8);
            r ^= AdvSimd.Arm64.VectorTableLookupExtension(v9, (v10, v11, v12, v14), idx + v13);
            r ^= AdvSimd.Arm64.VectorTableLookupExtension(v14, (v15, v16, v17, v19), idx + v18);
            r ^= AdvSimd.Arm64.VectorTableLookupExtension(v19, (v20, v21, v22, v24), idx + v23);
            r ^= AdvSimd.Arm64.VectorTableLookupExtension(v24, (v25, v26, v1, v3), idx + v2);
            r ^= AdvSimd.Arm64.VectorTableLookupExtension(v26, (v0, v25, v1, v5), idx + v3);
        }
        r = r ^ v0 ^ v1 ^ v2 ^ v3 ^ v4 ^ v5 ^ v6 ^ v7 ^ v8 ^ v9 ^ v10 ^ v11 ^ v12 ^ v13 ^ v14 ^ v15 ^ v16 ^ v17 ^ v18 ^ v19 ^ v20 ^ v21 ^ v22 ^ v23 ^ v24 ^ v25 ^ v26;
        return r.AsUInt64().GetElement(0);
    }
}

Run with DOTNET_TieredCompilation=0 on arm64.

Expected

4292821915693441957, which is also what DOTNET_JITMinOpts=1 prints.

Actual

Assertion failed '!isRefPositionActive(recentAssignedRef, refLocation)' in 'Program:Test(byte[],int):ulong' during 'LSRA build intervals' (IL size 760; hash 0x50ca1d6a; FullOpts)
    File: src/coreclr/jit/lsra.cpp:2945

Regression?

Unknown, because the assert is Checked-only. .NET 10.0.12 (Release) compiles Test with FullOpts and prints the expected value.

Notes

  • The assert is reached via try_SPILL_COST -> isSpillCandidate -> canSpillReg while allocating the consecutive registers for the last tbx. The busy candidates include d13, whose RegRecord still points to v26 from an earlier consecutive copy. v26 now lives in d10 and is the in-use defaultValues operand, but only d10 is excluded as in-use.
  • The SVE multi-vector APIs (Sve.StoreAndZip, Sve.Load2x/3x/4xVectorAndUnzip) share this consecutive-register path. This is a different root cause from the wraparound-mask bug in filterConsecutiveCandidates: the repro still asserts with that bug fixed.

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 27, 2026
    22cf5c8
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