[System.Runtime.Intrinsics] API suggestion: Introduce an intrinsic all bits set field to Vector intrinsic types #30659
Labels
api-approved
API was approved in API review, it can be implemented
area-System.Runtime.Intrinsics
help wanted
[up-for-grabs] Good issue for external contributors
Milestone
Currently we have
Vector{nnn}<T>.Zero
type which the JIT recognises and transforms into axorps
or similar. It would be useful to have a.AllBitsSet
property, which is the inverse, having all bits set. The JIT could ideally generate this to becmpps <dest>, xmm0, xmm0, 0x0
which is recognised as dependency breaking on modern intel architectures for minimal cost. An all-ones value is useful, and can be frequently used for masking and mixing elements alongside the all-zero value.Rational and Usage
It is commonly used, for example it can be used as
Xor(left, AllBitsSet)
to implement aNot
using SIMD, as well as frequently for masking and mixing elements, e.g withShuffle/And/Or
Proposed API
Details
It should be implemented as an intrinsic which results in
which is recognised as dependency breaking on Haswell+ archs. Software fallback is relatively simple, effectively
Vector128.Create(-1).As<int, T>()
Open Questions
Is the name ok?
Pull Request
None yet
Updates
The text was updated successfully, but these errors were encountered: