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) RBO jump threading leaves stale PHI SSA that strength reduction treats as loop-invariant (wrong result) #135812
Redundant branch opts threads the second if (c) through the dominating identical one, orphaning the join block that holds the PHI of y while a later use of that PHI stays in place. "Optimize Induction Variables" then treats the orphaned def as loop-invariant and reads the never-assigned y (0) in the loop preheader, producing a wrong result.
2450. With DOTNET_JitMinOpts=1 the result is correct (2550).
DOTNET_JitDisasm=Test shows k and m are never read: the strength-reduced IV rat0 is initialized to 0 (xor edx, edx) and only steps by 2, i.e. y is treated as 0.
Without AggressiveOptimization and with default tiering, the result is correct at tier-0 and becomes 2450 once the method is rejitted at tier-1.
Regression?
Yes, a regression in .NET 9. .NET 8 (8.0.x) prints 2550; .NET 9, .NET 10 (10.0.13), 11.0 RC1 and main print 2450.
Notes
Reproduced with a Checked JIT built from main @ c6d6546 and with the released 11.0 RC1 runtime.
Root cause: for non-PHI RBO, optJumpThreadCheck neglects PHI stores ("This can leave SSA in an incorrect state"). After threading, BB05 (holding PHI V07.4) is unreachable but BB06 still uses V07.4.
SCEV (ScalarEvolutionContext::AnalyzeNew, scev.cpp) treats an SSA def whose block is not in the loop as invariant, so StrengthReductionContext emits rat0 = LCL_VAR y in the preheader.
Related: A JIT bug in IV or RBO #130189 (closed) hardened only optWidenPrimaryIV for the same root cause, and Investigate repairing SSA after RBO #130241 (open) tracks repairing SSA after RBO in general; this is another test case for it. A fix would be to repair/invalidate SSA when optJumpThreadDom orphans a block with live PHI defs, or to make SCEV reject defs from unreachable blocks.
Activity
dotnet-policy-service commentedon Oct 14, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
JIT: rebuild SSA and VN after RBO jump threading (#137972)