]> git.ipfire.org Git - thirdparty/gcc.git/commit
Improve memcmpeq for 512-bit vector with vpcmpeq + kortest.
authorliuhongt <hongtao.liu@intel.com>
Mon, 9 Oct 2023 07:07:54 +0000 (15:07 +0800)
committerliuhongt <hongtao.liu@intel.com>
Mon, 30 Oct 2023 03:10:01 +0000 (11:10 +0800)
commit8c40b72036c967fbb1d1150515cf70aec382f0a2
tree416aba24f88619b92a2d3ebcd5689e1a7f58a3a8
parent8111b5c23bd14f80607bd35af58ec31e38a0378e
Improve memcmpeq for 512-bit vector with vpcmpeq + kortest.

When 2 vectors are equal, kmask is allones and kortest will set CF,
else CF will be cleared.

So CF bit can be used to check for the result of the comparison.

Before:
        vmovdqu (%rsi), %ymm0
        vpxorq  (%rdi), %ymm0, %ymm0
        vptest  %ymm0, %ymm0
        jne     .L2
        vmovdqu 32(%rsi), %ymm0
        vpxorq  32(%rdi), %ymm0, %ymm0
        vptest  %ymm0, %ymm0
        je      .L5
.L2:
        movl    $1, %eax
        xorl    $1, %eax
        vzeroupper
        ret

After:
        vmovdqu64       (%rsi), %zmm0
        xorl    %eax, %eax
        vpcmpeqd        (%rdi), %zmm0, %k0
        kortestw        %k0, %k0
        setc    %al
        vzeroupper
        ret

gcc/ChangeLog:

PR target/104610
* config/i386/i386-expand.cc (ix86_expand_branch): Handle
512-bit vector with vpcmpeq + kortest.
* config/i386/i386.md (cbranchxi4): New expander.
* config/i386/sse.md: (cbranch<mode>4): Extend to V16SImode
and V8DImode.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr104610-2.c: New test.
gcc/config/i386/i386-expand.cc
gcc/config/i386/i386.md
gcc/config/i386/sse.md
gcc/testsuite/gcc.target/i386/pr104610-2.c [new file with mode: 0644]