Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue 23568: Set the result type of vector comparisons to an integer vector type #14715

Merged
merged 1 commit into from
Dec 19, 2022

Conversation

ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Dec 19, 2022

The result of vector comparisons is a single or doubleword mask of all 1s (comparison true) or all 0s (comparison false). This SIMD mask type does not have an equivalent D type, however its closest equivalent would be an integer vector of the same unit size and length.

Rationale: Currently the result of vector float comparison and equality operations is either NaNs or 0s, which requires an explicit cast to a vector int in order to use it for checking the result post operation.

For example, GDC's ternary (? :) vector intrinsic blendvector can work with the following:

blendvector(a, b, a < b);

However if the condition is a vector float type...

blendvector(f, g, cast(__vector[uint[4])(f < g));

This removes the need for such boilerplate.

@dlang-bot
Copy link
Contributor

dlang-bot commented Dec 19, 2022

Thanks for your pull request, @ibuclaw!

Bugzilla references

Auto-close Bugzilla Severity Description
23568 major Error: cannot implicitly convert expression 'a < b' of type 'float4' to 'int4'

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#14715"

@ibuclaw ibuclaw changed the title SIMD: Set the result type of vector comparisons to an integer vector type fix Issue 23568: Set the result type of vector comparisons to an integer vector type Dec 19, 2022
@dlang-bot dlang-bot merged commit edcbcdf into dlang:master Dec 19, 2022
@ibuclaw ibuclaw deleted the vectorbool branch December 19, 2022 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants