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
This issue was authored by GitHub Copilot CLI on @AndyAyersMS's machine,
based on a bug surfaced by an experimental in-development fuzzer.
The C# repro and disassembly are verified; the hypothesis about the
offending phase is informed speculation.
Repros on dotnet/runtime at HEAD a8b2c92ce21 (2026-06-05) on osx-arm64 Checked. Does not repro on preview-5 — appears to be a regression introduced since then.
The whole post-branch return has been folded to (v3 != 0) ? 1 : 99. The correct fold would be (v3 != 0) ? 0 : 99 — i.e., the THEN constant should be 0, not 1.
For comparison, MinOpts emits the actual mvn/cmn/cset ge sequence and returns the correct value.
Hypothesis
After if (v3 == 0) return 99, the JIT knows v3 ∈ {1} (since v3 is a compare result with range {0, 1} and the branch narrowed it). It then evaluates (~v3 >= -1):
Correct:(~v3 >= -1) ⇔ (v3 <= 0) (complementing both sides reverses the comparison). With v3 ∈ {1} this is false, so the THEN constant is 0.
What the JIT seems to do:(~v3 >= -1) ⇔ (v3 >= 0) (forgot to invert the comparison direction). With v3 ∈ {1} (or any non-negative range) this is true, so the THEN constant is 1.
Looks like a peephole / fgOptimizeRelationalComparisonWithCasts-style rewrite of ~x op k to x op ~k that missed reversing the comparison sign for ordered (non-EQ/NE) compares.
Candidate offending PRs
All merged between preview-5 and HEAD a8b2c92ce21:
ReifyCs (a from-scratch implementation of the PLDI 2026 semantic-reification
technique adapted to C#) ran a 500-trial, 4-type, 7-config differential
campaign and reported exactly one mismatch. Manual reduction took the
generated method down to the 5-line body above.
Note
This issue was authored by GitHub Copilot CLI on @AndyAyersMS's machine,
based on a bug surfaced by an experimental in-development fuzzer.
The C# repro and disassembly are verified; the hypothesis about the
offending phase is informed speculation.
Repro
Manual trace:
p0 = 0x800335C5,p1 = 0⇒v1 = 0,v3 = (0 != p0) ? 1 : 0 = 1, branch not taken,v4 = ~1 = -2,(-2 >= -1) ? 1 : 0 = 0. Expected:0.Observed
DOTNET_JITMinOpts=100000000DOTNET_TieredCompilation=1 DOTNET_TC_QuickJitForLoops=1(Tier1 via tiering)00000000DOTNET_TieredCompilation=0(FullOpts direct)00000001dotnet 11.0.100-preview.5.26227.104(any config)00000000Repros on
dotnet/runtimeat HEADa8b2c92ce21(2026-06-05) onosx-arm64Checked. Does not repro on preview-5 — appears to be a regression introduced since then.Disassembly (osx-arm64 Checked,
DOTNET_TieredCompilation=0)The whole post-branch return has been folded to
(v3 != 0) ? 1 : 99. The correct fold would be(v3 != 0) ? 0 : 99— i.e., the THEN constant should be0, not1.For comparison, MinOpts emits the actual
mvn/cmn/cset gesequence and returns the correct value.Hypothesis
After
if (v3 == 0) return 99, the JIT knowsv3 ∈ {1}(sincev3is a compare result with range{0, 1}and the branch narrowed it). It then evaluates(~v3 >= -1):(~v3 >= -1)⇔(v3 <= 0)(complementing both sides reverses the comparison). Withv3 ∈ {1}this isfalse, so the THEN constant is0.(~v3 >= -1)⇔(v3 >= 0)(forgot to invert the comparison direction). Withv3 ∈ {1}(or any non-negative range) this istrue, so the THEN constant is1.Looks like a peephole /
fgOptimizeRelationalComparisonWithCasts-style rewrite of~x op ktox op ~kthat missed reversing the comparison sign for ordered (non-EQ/NE) compares.Candidate offending PRs
All merged between preview-5 and HEAD
a8b2c92ce21:fgOptimizeRelationalComparisonWithCastsfor EQ/NE #128091 — JIT: EnablefgOptimizeRelationalComparisonWithCastsfor EQ/NE (2026-06-01)fgOptimizeRelationalComparison#127883 — JIT: Unify post-order cmp transforms intofgOptimizeRelationalCompari…(2026-05-21)How it was found
ReifyCs (a from-scratch implementation of the PLDI 2026 semantic-reification
technique adapted to C#) ran a 500-trial, 4-type, 7-config differential
campaign and reported exactly one mismatch. Manual reduction took the
generated method down to the 5-line body above.