i386: Use PUNPCKL?? to implement vector extend and zero_extend for TARGET_SSE2.
commit4123b5609da53c8f8ac01c90aef127ad6375e9df
authorUros Bizjak <ubizjak@gmail.com>
Fri, 18 Aug 2023 17:06:38 +0000 (18 19:06 +0200)
committerUros Bizjak <ubizjak@gmail.com>
Fri, 18 Aug 2023 17:08:23 +0000 (18 19:08 +0200)
treed56c958e2b23159865645e57f759f65a17a0cc6d
parent53fcd3bdbc9104a8acdc79134d8d272d7eead0fd
i386: Use PUNPCKL?? to implement vector extend and zero_extend for TARGET_SSE2.

Implement vector extend and zero_extend functionality for TARGET_SSE2 using
PUNPCKL?? family of instructions. The code for e.g. zero-extend from V2SI to
V2DImode improves from:

        movd    %xmm0, %edx
        pshufd  $85, %xmm0, %xmm0
        movd    %xmm0, %eax
        movq    %rdx, (%rdi)
        movq    %rax, 8(%rdi)

to:
        pxor    %xmm1, %xmm1
        punpckldq       %xmm1, %xmm0
        movaps  %xmm0, (%rdi)

And the code for sign-extend from V2SI to V2DImode from:

        movd    %xmm0, %edx
        pshufd  $85, %xmm0, %xmm0
        movd    %xmm0, %eax
        movslq  %edx, %rdx
        cltq
        movq    %rdx, (%rdi)
        movq    %rax, 8(%rdi)

to:
        pxor    %xmm1, %xmm1
        pcmpgtd %xmm0, %xmm1
        punpckldq       %xmm1, %xmm0
        movaps  %xmm0, (%rdi)

PR target/111023

gcc/ChangeLog:

* config/i386/i386-expand.cc (ix86_split_mmx_punpck):
Also handle V2QImode.
(ix86_expand_sse_extend): New function.
* config/i386/i386-protos.h (ix86_expand_sse_extend): New prototype.
* config/i386/mmx.md (<any_extend:insn>v4qiv4hi2): Enable for
TARGET_SSE2.  Expand through ix86_expand_sse_extend for !TARGET_SSE4_1.
(<any_extend:insn>v2hiv2si2): Ditto.
(<any_extend:insn>v2qiv2hi2): Ditto.
* config/i386/sse.md (<any_extend:insn>v8qiv8hi2): Ditto.
(<any_extend:insn>v4hiv4si2): Ditto.
(<any_extend:insn>v2siv2di2): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr111023-2.c: New test.
* gcc.target/i386/pr111023-4b.c: New test.
* gcc.target/i386/pr111023-8b.c: New test.
* gcc.target/i386/pr111023.c: New test.
gcc/config/i386/i386-expand.cc
gcc/config/i386/i386-protos.h
gcc/config/i386/mmx.md
gcc/config/i386/sse.md
gcc/testsuite/gcc.target/i386/pr111023-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr111023-4b.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr111023-8b.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr111023.c [new file with mode: 0644]