https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80517

--- Comment #4 from Matthias Kretz <kretz at kde dot org> ---
A similar test case showing that something is still missing
(https://gcc.godbolt.org/z/t1DT7E):

#include <x86intrin.h>

inline __m128i cmp(__m128i x, __m128i y) {
    return _mm_cmpeq_epi16(x, y);
}
inline unsigned to_bits(__m128i mask0) {
    return _pext_u32(_mm_movemask_epi8(mask0), 0xaaaa);
}

inline __m128i to_vmask(unsigned bits) {
    __m128i mask = _mm_set1_epi16(bits);
    mask = _mm_and_si128(mask, _mm_setr_epi16(1, 2, 4, 8, 16, 32, 64, 128));
    mask = _mm_cmpeq_epi16(mask, _mm_setzero_si128());
    mask = _mm_xor_si128(mask, _mm_cmpeq_epi16(mask, mask));
    return mask;
}

auto f(__m128i x, __m128i y) {
    // should be:
    // vpcmpeqw %xmm1, %xmm0, %xmm0
    // ret
    return to_vmask(to_bits(cmp(x, y)));
}

auto f(unsigned bits) {
    // should be equivalent to `return 0xff & bits;`
    return to_bits(to_vmask(bits));
}

Reply via email to