You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JIT: (bug) [ARM64] TryLowerCselToCSOp creates GT_SELECT_NEG/INV/INC with a register condition, which LSRA cannot build (wrong code in Release) #134056
When TryLowerConditionToFlagsNode bails out (CCMP chain longer than its 10-node look-back), the select keeps a register condition, but Lowering::TryLowerCselToCSOp still converts it to the GTK_SPECIALGT_SELECT_NEG/_INV/_INC. LSRA has no BuildSelect path for those opers, so Checked asserts and Release emits a csneg/csinv reading a vector register — silent wrong results. .NET 11 regression.
Minimal Repro
usingSystem;usingSystem.Runtime.CompilerServices;classProg{[MethodImpl(MethodImplOptions.NoInlining|MethodImplOptions.AggressiveOptimization)]staticintTest(inta,intb)=>(a>0&a>1&a>2&a>3&a>4&a>5&a>6&a>7&a>8&a>9&a>10&a>11)?b:-a;// Same shape with `~a` hits GT_SELECT_INV; `? 5 : 4` hits GT_SELECT_INC.staticvoidMain()=>Console.WriteLine(Test(3,7));// expected -3}
Exactly 12 &-ed comparisons are needed; with 2..11 the JIT produces correct code.
Expected
-3
Actual
Release arm64 (deterministic, 3/3 runs):
0
Checked arm64:
Assertion failed '(kind & GTK_SMPOP) != 0' in 'Prog:Test(int,int):int' during 'Linear scan register alloc'
File: src/coreclr/jit/lsrabuild.cpp:4221
Release codegen ends with:
cset x0, gtcmp w0, #0mov q0, w0 ; value moved into a *vector* register csneg w0, w1, q0, ne ; vector register used as a GPR source operand
The ~a variant returns -1 instead of -4 with mov q0, w0 / csinv w0, w1, q0, ne.
Notes
SELECT_INC/SELECT_INV/SELECT_NEG are GTK_SPECIAL in gtlist.h (their *CC siblings are GTK_BINOP), and LinearScan::BuildNode on arm64 only routes GT_SELECT/GT_SELECTCC to BuildSelect; the rest fall through to BuildSimple, which never builds uses for gtCond/the false
arm. genCodeForSelect does handle these opers, so the gap is purely LSRA plus the lowering contract.
Fix direction: either handle the non-CC GT_SELECT_* opers in LSRA, or have TryLowerCselToCSOp / TryLowerCnsIntCselToCinc bail out when the select was not converted to GT_SELECTCC.
Activity
dotnet-policy-service commentedon Sep 16, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
JIT: support register-condition SELECT_INC/NEG/INV on arm64 (dotnet#1…