public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rsandifo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/99873] New: [11 Regression] GCC no longer makes as much use of ST3
Date: Thu, 01 Apr 2021 18:19:39 +0000	[thread overview]
Message-ID: <bug-99873-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 99873
           Summary: [11 Regression] GCC no longer makes as much use of ST3
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rsandifo at gcc dot gnu.org
                CC: rguenth at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64*-*-*

For:

void
f (int *restrict x, int *restrict y, int *restrict z, int n)
{
  for (int i = 0; i < n; i += 3)
    {
      x[i] = y[i] + z[i];
      x[i + 1] = y[i + 1] - z[i + 1];
      x[i + 2] = y[i + 2] | z[i + 2];
    }
}

GCC 10 produced a nice loop using LD3 and ST3:

.L4:
        ld3     {v4.4s - v6.4s}, [x4], 48
        ld3     {v16.4s - v18.4s}, [x6], 48
        add     v1.4s, v16.4s, v4.4s
        sub     v2.4s, v5.4s, v17.4s
        orr     v3.16b, v18.16b, v6.16b
        st3     {v1.4s - v3.4s}, [x5], 48
        cmp     x8, x4
        bne     .L4

But GCC 11 instead uses lane stores:

.L4:
        ld3     {v4.4s - v6.4s}, [x9], 48
        mov     x8, x4
        ld3     {v16.4s - v18.4s}, [x11], 48
        add     x16, x4, 24
        add     x15, x4, 36
        add     x14, x4, 16
        add     x13, x4, 28
        add     x12, x4, 40
        add     v2.4s, v16.4s, v4.4s
        add     x7, x4, 20
        sub     v1.4s, v5.4s, v17.4s
        add     x6, x4, 32
        orr     v0.16b, v18.16b, v6.16b
        add     x5, x4, 44
        add     x4, x4, 48
        str     s2, [x8], 12
        st1     {v2.s}[1], [x8]
        st1     {v2.s}[2], [x16]
        st1     {v2.s}[3], [x15]
        str     s1, [x4, -44]
        st1     {v1.s}[1], [x14]
        st1     {v1.s}[2], [x13]
        st1     {v1.s}[3], [x12]
        str     s0, [x4, -40]
        st1     {v0.s}[1], [x7]
        st1     {v0.s}[2], [x6]
        st1     {v0.s}[3], [x5]
        cmp     x10, x9
        bne     .L4

I think this is due to r11-3966 optimistically splitting store groups
in a way that we can't recover from if SLP subsequently fails.

Maybe the easiest thing for GCC 11 would be to block the split if the
target supports IFN_STORE_LANES for the group size and element type.
That restores the above case.  Of the two tests affected by r11-3966,
vect-complex-5.c seems better with LD2 & ST4, while the motivating
case (pr97428.c) still uses SLP as intended.

             reply	other threads:[~2021-04-01 18:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-01 18:19 rsandifo at gcc dot gnu.org [this message]
2021-04-01 18:38 ` [Bug tree-optimization/99873] " rsandifo at gcc dot gnu.org
2021-04-06  7:34 ` rguenth at gcc dot gnu.org
2021-04-06  8:46 ` rsandifo at gcc dot gnu.org
2021-04-07 14:22 ` cvs-commit at gcc dot gnu.org
2021-04-07 18:04 ` rsandifo 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-99873-4@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).