public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/67676] New: Implicit alignment of struct not applied to members
@ 2015-09-22  2:06 olegendo at gcc dot gnu.org
  2015-09-22  8:04 ` [Bug rtl-optimization/67676] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: olegendo at gcc dot gnu.org @ 2015-09-22  2:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67676
           Summary: Implicit alignment of struct not applied to members
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olegendo at gcc dot gnu.org
  Target Milestone: ---
            Target: sh*-*-*

I've noticed this while doing PR 67675...


On strict-alignment targets (like SH) a pointer to a struct is always assumed
to be aligned:

struct S
{
  int a, b, c;
  char s[64];
};

'struct S*' will always be 4 byte aligned.

Accessing a member works as expected:

int foo4 (struct S* x)
{
  return x->b;
}

        mov.l   @(4,r4),r0
        rts/n

However, when the address of a member is passed to __builtin_strcmp, the
alignment is lost somehow:

int foo5 (struct S* x)
{
  return __builtin_strcmp (x->s, "1234");
}

Here the builtin strcmp expander will see x->s with an alignment of 1, although
it's 4.

Adding an alignment hint gives the expected result:

int foo6 (struct S* x)
{
  struct S* xx = (struct S*)__builtin_assume_aligned (x, 4);
  return __builtin_strcmp (xx->s, "1234");
}

I'm not sure whether this is a tree or RTL problem.  Happens for C and C++.
Possibly related: PR 23467, PR 50417


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

* [Bug rtl-optimization/67676] Implicit alignment of struct not applied to members
  2015-09-22  2:06 [Bug rtl-optimization/67676] New: Implicit alignment of struct not applied to members olegendo at gcc dot gnu.org
@ 2015-09-22  8:04 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-09-22  8:04 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Duplicate.

*** This bug has been marked as a duplicate of bug 50417 ***


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

end of thread, other threads:[~2015-09-22  8:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-22  2:06 [Bug rtl-optimization/67676] New: Implicit alignment of struct not applied to members olegendo at gcc dot gnu.org
2015-09-22  8:04 ` [Bug rtl-optimization/67676] " 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).