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) a branch on the bitwise complement of a comparison makes a later identical comparison fold to the wrong value #133557
usingSystem;usingSystem.Runtime.CompilerServices;classProgram{[MethodImpl(MethodImplOptions.NoInlining|MethodImplOptions.AggressiveOptimization)]staticintTest(inta,intb){intt=(a!=b)?1:0;intu=~t;// -1 or -2, so u is never zeroif(u!=0){if(a!=b)return1;}return0;}staticvoidMain()=>Console.WriteLine(Test(3,5));}
Expected
1
Actual
0
The outer condition ~t != 0 is a tautology that carries no information about a != b, but the
inner comparison is folded from it anyway.
Platform
Windows x64, local Checked build of dotnet/runtime main (ef97eb5). Not target-specific.
MinOpts and release .NET 11.0.100-rc.1.26420.103 both produce the correct 1.
Activity
dotnet-policy-service commentedon Sep 10, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
MihuBot commentedon Sep 10, 2026
I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):
~x op kwithout inverting the comparison #129076AndyAyersMS commentedon Sep 10, 2026
Bad RBO inferences from GT_NOT. We fixed them in VN, but didn't fix them in RBO. Grr.
JIT: stop inferring through bitwise complement (#133700)
EgorBo commentedon Sep 18, 2026
Affected SDK versions: