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: LowerHWIntrinsicCmpOp passes the wrong base type to TryInvertMask #130844
When lowering a vector equality/inequality comparison, LowerHWIntrinsicCmpOp calls TryInvertMask(maskNode, simdSize, simdBaseType). It passes the node's simdBaseType, but the mask's own base type (maskBaseType) can legitimately differ -- e.g. an op_Equality declared TYP_INT over a mask whose underlying element type is TYP_DOUBLE. The block comment right above already documents that these can differ.
TryInvertMask uses its base-type parameter in the constant-mask branch (node->IsCnsMsk()) to compute elemCount = simdSize / genTypeSize(base) and then GetBitMask(elemCount). When the types differ the inverted constant mask ends up with the wrong number of valid bits (e.g. GetBitMask(4) = 0xF instead of 0x3), producing spurious high bits and a wrong KORTEST result.
Every other consumer in that block uses maskBaseType (the element count, and the NotMask/ShiftLeftMask/ShiftRightMask fallback), so the TryInvertMask call should as well.
Only reachable on AVX512 (EVEX mask + KORTEST) and only in the IsCnsMsk() const-mask branch.
Note
This issue was authored with the assistance 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 three xarch lowering correctness/invariant issues (#130843)