public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/107546] [10/11/12/13 Regression] simd, redundant pcmpeqb and pxor
Date: Tue, 08 Nov 2022 11:24:13 +0000	[thread overview]
Message-ID: <bug-107546-4-qGxdUlLVkZ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107546-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:fa271afb58423014e2feef9f15c1a87428e64ddc

commit r13-3803-gfa271afb58423014e2feef9f15c1a87428e64ddc
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Nov 8 12:21:55 2022 +0100

    i386: Improve vector [GL]E{,U} comparison against vector constants
[PR107546]

    For integer vector comparisons without XOP before AVX512{F,VL} we are
    constrained by only GT and EQ being supported in HW.
    For GTU we play tricks to implement it using GT or unsigned saturating
    subtraction, for LT/LTU we swap the operands and thus turn it into
    GT/GTU.  For LE/LEU we handle it by using GT/GTU and negating the
    result and for GE/GEU by using GT/GTU on swapped operands and negating
    the result.
    If the second operand is a CONST_VECTOR, we can usually do better though,
    we can avoid the negation.  For LE/LEU cst by doing LT/LTU cst+1 (and
    then cst+1 GT/GTU x) and for GE/GEU cst by doing GT/GTU cst-1, provided
    there is no wrap-around on those cst+1 or cst-1.
    GIMPLE canonicalizes x < cst to x <= cst-1 etc. (the rule is smaller
    absolute value on constant), but only for scalars or uniform vectors,
    so in some cases this undoes that canonicalization in order to avoid
    the extra negation, but it handles also non-uniform constants.
    E.g. with -mavx2 the testcase assembly difference is:
    -       movl    $47, %eax
    +       movl    $48, %eax
            vmovdqa %xmm0, %xmm1
            vmovd   %eax, %xmm0
            vpbroadcastb    %xmm0, %xmm0
    -       vpminsb %xmm0, %xmm1, %xmm0
    -       vpcmpeqb        %xmm1, %xmm0, %xmm0
    +       vpcmpgtb        %xmm1, %xmm0, %xmm0
    and
    -       vmovdqa %xmm0, %xmm1
    -       vmovdqa .LC1(%rip), %xmm0
    -       vpminsb %xmm1, %xmm0, %xmm1
    -       vpcmpeqb        %xmm1, %xmm0, %xmm0
    +       vpcmpgtb        .LC1(%rip), %xmm0, %xmm0
    while with just SSE2:
    -       pcmpgtb .LC0(%rip), %xmm0
    -       pxor    %xmm1, %xmm1
    -       pcmpeqb %xmm1, %xmm0
    +       movdqa  %xmm0, %xmm1
    +       movdqa  .LC0(%rip), %xmm0
    +       pcmpgtb %xmm1, %xmm0
    and
    -       movdqa  %xmm0, %xmm1
    -       movdqa  .LC1(%rip), %xmm0
    -       pcmpgtb %xmm1, %xmm0
    -       pxor    %xmm1, %xmm1
    -       pcmpeqb %xmm1, %xmm0
    +       pcmpgtb .LC1(%rip), %xmm0

    2022-11-08  Jakub Jelinek  <jakub@redhat.com>

            PR target/107546
            * config/i386/predicates.md (vector_or_const_vector_operand): New
            predicate.
            * config/i386/sse.md (vec_cmp<mode><sseintvecmodelower>,
            vec_cmpv2div2di, vec_cmpu<mode><sseintvecmodelower>,
            vec_cmpuv2div2di): Use nonimmediate_or_const_vector_operand
            predicate instead of nonimmediate_operand and
            vector_or_const_vector_operand instead of vector_operand.
            * config/i386/i386-expand.cc (ix86_expand_int_sse_cmp): For
            LE/LEU or GE/GEU with CONST_VECTOR cop1 try to transform those
            into LE/LEU or GT/GTU with larger or smaller by one cop1 if
            there is no wrap-around.  Force CONST_VECTOR cop0 or cop1 into
            REG.  Formatting fix.

            * gcc.target/i386/pr107546.c: New test.

  parent reply	other threads:[~2022-11-08 11:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07  6:39 [Bug rtl-optimization/107546] New: " i.nixman at autistici dot org
2022-11-07  6:51 ` [Bug target/107546] " pinskia at gcc dot gnu.org
2022-11-07  6:58 ` [Bug target/107546] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
2022-11-07  7:07 ` rguenth at gcc dot gnu.org
2022-11-07  7:07 ` crazylht at gmail dot com
2022-11-07  7:14 ` crazylht at gmail dot com
2022-11-07  7:16 ` glisse at gcc dot gnu.org
2022-11-07  7:20 ` pinskia at gcc dot gnu.org
2022-11-07  8:27 ` crazylht at gmail dot com
2022-11-07 10:22 ` jakub at gcc dot gnu.org
2022-11-07 12:02 ` jakub at gcc dot gnu.org
2022-11-07 12:05 ` i.nixman at autistici dot org
2022-11-07 13:47 ` i.nixman at autistici dot org
2022-11-08 11:24 ` cvs-commit at gcc dot gnu.org [this message]
2022-11-08 11:59 ` [Bug target/107546] [10/11/12 " jakub at gcc dot gnu.org
2022-11-10 10:48 ` cvs-commit at gcc dot gnu.org
2023-07-07 10:44 ` [Bug target/107546] [11/12 " rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107546-4-qGxdUlLVkZ@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).