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
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.
While auditing
gentree.cpp, I found a stray unconditional block in the min branch ofgtNewSimdMinMaxNode(xarch, floating constant fast path) that clobbers theneedsFixupcomputation:The trailing block makes the whole if/else chain dead, so
needsFixupis alwaysIsVectorNegativeZero(simdBaseType)(which isfalsefor a scalarDblCon). For three of the four cases this yields the wrong value; when it wrongly landsfalse, the constant-fold fast path emits a bareMIN/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
needsFixuponly for the finite opposite-signed-zero case (min(+0, -0)-> sign of zero); NaN cases are handled separately (operand swap forisNumber, natural propagation otherwise). So this is a signed-zero miscompile ofMinwith a signed-zero constant.Repro
Existing coverage in
JitBlue/Runtime_98068exercisesMin/MinNumberconst-folding but always pairs an operand withNaN; the finite opposite-signed-zero combination is never tested, which is why this survived. Latent on currentmain, found by inspection.Note
This issue was authored with the help of GitHub Copilot.