public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/109543] New: Avoid using BLKmode for unions with a non-BLKmode member when possible
@ 2023-04-18 10:57 avieira at gcc dot gnu.org
  2023-04-18 11:25 ` [Bug tree-optimization/109543] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: avieira at gcc dot gnu.org @ 2023-04-18 10:57 UTC (permalink / raw)
  To: gcc-bugs

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?

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-12-15  7:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 10:57 [Bug tree-optimization/109543] New: Avoid using BLKmode for unions with a non-BLKmode member when possible avieira at gcc dot gnu.org
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

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).