public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/109240] New: Missed fneg/fsub optimization
Date: Tue, 21 Mar 2023 19:25:49 +0000	[thread overview]
Message-ID: <bug-109240-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 109240
           Summary: Missed fneg/fsub optimization
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
                CC: avieira at gcc dot gnu.org, burnus at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, marxin at gcc dot gnu.org,
                    tnfchris at gcc dot gnu.org
        Depends on: 109230
  Target Milestone: ---
              Host: aarch64-linux-gnu
            Target: aarch64-linux-gnu

+++ This bug was initially created as a clone of Bug #109230 +++

On aarch64 we optimize at -O2 only half of the following routines:
typedef float V __attribute__((vector_size (4 * sizeof (float))));
typedef int VI __attribute__((vector_size (4 * sizeof (float))));

__attribute__((noipa)) V
foo (V x, V y)
{
  V a = x - y;
  V b = y + x;
  return __builtin_shuffle (b, a, (VI) { 0, 5, 2, 7 });
}

__attribute__((noipa)) V
bar (V x, V y)
{
  V a = x - y;
  V b = y + x;
  return __builtin_shuffle (a, b, (VI) { 4, 1, 6, 3 });
}

__attribute__((noipa)) V
baz (V x, V y)
{
  V a = x - y;
  V b = y + x;
  return __builtin_shuffle (b, a, (VI) { 4, 1, 6, 3 });
}

__attribute__((noipa)) V
qux (V x, V y)
{
  V a = x - y;
  V b = y + x;
  return __builtin_shuffle (a, b, (VI) { 0, 5, 2, 7 });
}

__attribute__((noipa)) V
boo (V x, V y)
{
  V a = x + y;
  V b = y - x;
  return __builtin_shuffle (b, a, (VI) { 0, 5, 2, 7 });
}

__attribute__((noipa)) V
corge (V x, V y)
{
  V a = x + y;
  V b = y - x;
  return __builtin_shuffle (a, b, (VI) { 4, 1, 6, 3 });
}

__attribute__((noipa)) V
fred (V x, V y)
{
  V a = x + y;
  V b = y - x;
  return __builtin_shuffle (b, a, (VI) { 4, 1, 6, 3 });
}

__attribute__((noipa)) V
garply (V x, V y)
{
  V a = x + y;
  V b = y - x;
  return __builtin_shuffle (a, b, (VI) { 0, 5, 2, 7 });
}

starting with r13-4024-gb2bb611d90d01f64a24 (plus r13-4122-g1bc7efa948f751
bugfix).
The other half could be handled similarly, just with fneg+fsub rather than
fneg+fadd.

Unfortunately, match.pd canonicalizes those, we still have 0, 5, 2, 7
permutations for all of them, but the two operations swapped.  Unfortunately
match.pd doesn't allow :c
on vec_perm, and if we use (for op (plus minus)
                                otherop (minus plus)
then we couldn't add :c to the plus one.  So, copy and paste the whole large
simplification, swap (plus:c @0 @1) and (minus @0 @1) and replace (plus at the
end with (minus?  Or handle the commutativity manually?
(for op (plus minus)
     otherop (minus plus)
 (simplify
  (vec_perm (op @0 @1) (otherop @2 @3) VECTOR_CST@4)
and use operand_equal_p manually to allow all forms we want?


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109230
[Bug 109230] [13 Regression] Maybe wrong code for opus package on aarch64 since
r13-4122-g1bc7efa948f751

             reply	other threads:[~2023-03-21 19:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21 19:25 jakub at gcc dot gnu.org [this message]
2023-03-22  7:43 ` [Bug tree-optimization/109240] " rguenth at gcc dot gnu.org
2023-03-22  9:39 ` jakub at gcc dot gnu.org
2023-03-26 18:44 ` jakub at gcc dot gnu.org
2023-04-18  9:02 ` cvs-commit at gcc dot gnu.org
2023-04-18  9:03 ` 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-109240-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).