public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "avieira at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/109543] New: Avoid using BLKmode for unions with a non-BLKmode member when possible
Date: Tue, 18 Apr 2023 10:57:43 +0000	[thread overview]
Message-ID: <bug-109543-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 109543
           Summary: Avoid using BLKmode for unions with a non-BLKmode
                    member when possible
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: avieira at gcc dot gnu.org
  Target Milestone: ---

Hi,

So with the following C-code:
$ cat t.c
#include <arm_neon.h>
#ifdef GOOD
typedef float64x2x2_t TYPE;
#else
typedef union
{
      float64x2x2_t v;
      double d[4];
  } TYPE;
  #endif


void foo (TYPE *a, TYPE *b, TYPE *c, unsigned  n)
{
 TYPE X = a[0];
 TYPE Y = b[0];
 TYPE Z = c[0];
 for (unsigned  i = 0; i < n; ++n)
 {
  TYPE temp = X;
  X = Y;
  Y = Z;
  Z = temp;
 }
 a[0] = X;
 b[0] = Y;
 c[0] = Z;
}

If compiled for aarch64 with -DGOOD the compiler will use vector register moves
in the loop, whereas without -DGOOD it will use the stack with memmoves.

The reason for this is because when picking the mode to address a UNION with
gcc will always choose BLKmode as soon as any member of a UNION is BLKmode. In
such cases I think it would be safe to go with not-BLKmode of members that have
the same size as the entire UNION?

             reply	other threads:[~2023-04-18 10:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-18 10:57 avieira at gcc dot gnu.org [this message]
2023-04-18 11:25 ` [Bug tree-optimization/109543] " rguenth at gcc dot gnu.org
2023-04-24 10:10 ` avieira at gcc dot gnu.org
2023-04-24 10:12 ` avieira at gcc dot gnu.org
2023-07-19 13:26 ` rguenth at gcc dot gnu.org
2023-12-14 18:25 ` rsandifo at gcc dot gnu.org
2023-12-14 18:28 ` richard.sandiford at arm dot com
2023-12-15  7:35 ` 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-109543-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).