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 tree-optimization/101895] [11/12 Regression] SLP Vectorizer change pushes VEC_PERM_EXPR into bad location spoiling further optimization opportunities
Date: Tue, 15 Mar 2022 09:06:45 +0000	[thread overview]
Message-ID: <bug-101895-4-ENJA856ihq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101895-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:

https://gcc.gnu.org/g:49fb0af9bf8f16907980d383c2bbc85e185ec2e0

commit r12-7653-g49fb0af9bf8f16907980d383c2bbc85e185ec2e0
Author: Roger Sayle <roger@nextmovesoftware.com>
Date:   Tue Mar 15 09:05:28 2022 +0000

    PR tree-optimization/101895: Fold VEC_PERM to help recognize FMA.

    This patch resolves PR tree-optimization/101895 a missed optimization
    regression, by adding a costant folding simplification to match.pd to
    simplify the transform "mult; vec_perm; plus" into "vec_perm; mult; plus"
    with the aim that keeping the multiplication and addition next to each
    other allows them to be recognized as fused-multiply-add on suitable
    targets.  This transformation requires a tweak to match.pd's
    vec_same_elem_p predicate to handle CONSTRUCTOR_EXPRs using the same
    SSA_NAME_DEF_STMT idiom used for constructors elsewhere in match.pd.

    The net effect is that the following code example:

    void foo(float * __restrict__ a, float b, float *c) {
      a[0] = c[0]*b + a[0];
      a[1] = c[2]*b + a[1];
      a[2] = c[1]*b + a[2];
      a[3] = c[3]*b + a[3];
    }

    when compiled on x86_64-pc-linux-gnu with -O2 -march=cascadelake
    currently generates:

            vbroadcastss    %xmm0, %xmm0
            vmulps  (%rsi), %xmm0, %xmm0
            vpermilps       $216, %xmm0, %xmm0
            vaddps  (%rdi), %xmm0, %xmm0
            vmovups %xmm0, (%rdi)
            ret

    but with this patch now generates the improved:

            vpermilps       $216, (%rsi), %xmm1
            vbroadcastss    %xmm0, %xmm0
            vfmadd213ps     (%rdi), %xmm0, %xmm1
            vmovups %xmm1, (%rdi)
            ret

    2022-03-15  Roger Sayle  <roger@nextmovesoftware.com>
                Marc Glisse  <marc.glisse@inria.fr>
                Richard Biener  <rguenther@suse.de>

    gcc/ChangeLog
            PR tree-optimization/101895
            * match.pd (vec_same_elem_p): Handle CONSTRUCTOR_EXPR def.
            (plus (vec_perm (mult ...) ...) ...): New reordering
simplification.

    gcc/testsuite/ChangeLog
            PR tree-optimization/101895
            * gcc.target/i386/pr101895.c: New test case.

  parent reply	other threads:[~2022-03-15  9:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13  5:01 [Bug tree-optimization/101895] New: " law at gcc dot gnu.org
2021-08-13  5:24 ` [Bug tree-optimization/101895] " pinskia at gcc dot gnu.org
2021-08-13  5:24 ` pinskia at gcc dot gnu.org
2021-08-16  7:49 ` rguenth at gcc dot gnu.org
2021-08-25  4:40 ` law at gcc dot gnu.org
2021-08-25  7:19 ` rguenth at gcc dot gnu.org
2022-03-11 23:51 ` roger at nextmovesoftware dot com
2022-03-15  9:06 ` cvs-commit at gcc dot gnu.org [this message]
2022-03-15 23:44 ` roger at nextmovesoftware dot com
2022-03-16  7:10 ` [Bug tree-optimization/101895] [11 " rguenth at gcc dot gnu.org
2022-03-16 23:13 ` law at gcc dot gnu.org
2022-03-17 23:18 ` law at gcc dot gnu.org
2022-04-21  7:50 ` rguenth at gcc dot gnu.org
2023-05-29 10:05 ` jakub 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-101895-4-ENJA856ihq@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).