'SIMD - "sorting" zeros in a vector [duplicate]

Please tell me on this issue, for example, I have a vector __m128i - filled as an int, that is, each value takes 4 bytes:

__m128i my_m128i = _mm_set_epi32 ( 12, 0 , 0 , 350);

Is it possible somehow in this vector or in a new vector to make all zero values move to one edge to the left or right? To make it look like this:

0 0 12 350

or

12 350 0 0

?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source