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: stray block in gtNewSimdMinMaxNode clobbers needsFixup, miscompiling Min with a signed-zero constant #130831
While auditing gentree.cpp, I found a stray unconditional block in the min branch of gtNewSimdMinMaxNode (xarch, floating constant fast path) that clobbers the needsFixup computation:
The trailing block makes the whole if/else chain dead, so needsFixup is always IsVectorNegativeZero(simdBaseType) (which is false for a scalar DblCon). For three of the four cases this yields the wrong value; when it wrongly lands false, the constant-fold fast path emits a bare MIN/MINSSwithout the required signed-zero fixup, on all hardware.
The correct min branch mirrors the (already-correct) max branch: the non-scalar non-number case uses IsVectorNegativeZero(simdBaseType) and the stray block is removed.
Effect
The min/max constant-fold fast path relies on needsFixup only for the finite opposite-signed-zero case (min(+0, -0) -> sign of zero); NaN cases are handled separately (operand swap for isNumber, natural propagation otherwise). So this is a signed-zero miscompile of Min with a signed-zero constant.
Existing coverage in JitBlue/Runtime_98068 exercises Min/MinNumber const-folding but always pairs an operand with NaN; the finite opposite-signed-zero combination is never tested, which is why this survived. Latent on current main, found by inspection.
Note
This issue was authored with the help of GitHub Copilot.
Activity
dotnet-policy-service commentedon Jul 16, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
Fix two latent HWIntrinsic miscompiles in gentree.cpp (#130832)
tannergooding commentedon Aug 7, 2026
Fixed with #130832