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

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
I'm testing a patch for the V2SImode case which we'll code-generate as the
following (with -fno-vect-cost-model):

foo:
.LFB0:
        .cfi_startproc
        vmovupd (%rsi), %xmm2
        vmovddup        %xmm0, %xmm1
        vmovd   %edi, %xmm3
        movabsq $4294967297, %rax
        vpshufd $0xe0, %xmm3, %xmm0
        vcmppd  $1, %xmm1, %xmm2, %k1
        vmovq   (%rdx), %xmm1
        vpcmpgtd        %xmm1, %xmm0, %xmm0
        vmovdqa32       %xmm0, %xmm1{%k1}{z}  (A)
        vmovq   %rax, %xmm0
        vpand   %xmm1, %xmm0, %xmm0
        vmovd   %xmm0, %eax
        vpextrd $1, %xmm0, %edx
        addl    %edx, %eax
        ret

it's nice that we are able to combine the %kN -> SSE mask representation
with the bitwise and using (A).  The V4SImode variant manages the
-1 -> 1 transition with

        vpsrld  $31, %xmm1, %xmm0{%k1}{z}

not sure why we chose

        movabsq $4294967297, %rax
        vmovq   %rax, %xmm0
        vpand   %xmm1, %xmm0, %xmm0

here over

        vpsrld  $31, %xmm0, %xmm0

it's both from a .VCOND_MASK (mask, {1, 1}, {0, 0}) expansion.  With
AVX2 we'll get earlier folding to & { 1, 1, 1, 1 } though.

Reply via email to