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) wrong result when (m & Vector128.Create(a)) == <zero with side effects> is folded to vptest with a stale memory operand #136306
The AND + compare-with-zero is folded to vptest that reuses the AND's contained memory operand, so the memory is read after the RHS side effect (Interlocked.Exchange) instead of before it.
False (m & a is evaluated first = {1,0,0,0}, then a[0] is cleared; {1,0,0,0} != 0)
Actual
True (prints False with DOTNET_JitMinOpts=1)
moveax, dword ptr [rdx+0x08]cmpeax,4jl SHORT G_M65395_IG04vmovupsxmm0, xmmword ptr [rcx]addrdx,16xoreax,eaxxchg dword ptr [rdx],eaxvptestxmm0, xmmword ptr [rdx] ; reads a[0..3] after the xchg sete almovzxeax,al
Regression?
Same xchg + vptest xmm0, xmmword ptr [rdx] sequence and output True on net8.0 (8.0.32), net9.0 (9.0.21), net10.0 (10.0.13) and net11.0 (11.0.0-rc.2) with the release JIT. Not a regression.
Notes
Safe C# only, default config.
Root cause: in Lowering::LowerHWIntrinsicCmpOp (lowerxarch.cpp, GT_AND/GT_AND_NOT PTEST fold) the removed AND's already-contained memory operand is reused, so it is now read at the PTEST position, after the RHS side effect (the RHS is folded to Zero + COMMA side effects).
Activity
dotnet-policy-service commentedon Oct 22, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
JIT: Don't reuse a stale contained memory operand when folding AND in…