public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* may_be_unaligned_p bug?
@ 2010-04-10 11:02 DJ Delorie
  2010-04-10 13:03 ` Eric Botcazou
  0 siblings, 1 reply; 7+ messages in thread
From: DJ Delorie @ 2010-04-10 11:02 UTC (permalink / raw)
  To: gcc


In tree-ssa-loop-ivopts.c:may_be_unaligned_p(), we call
get_inner_reference to figure out bitpos, but we don't take into
account toffset - which may make the reference less aligned than we
expect.  Is this supposed to be accounted for by STEP ?  It doesn't
always work with nested arrays - STEP is the innermost array, but
doesn't account for outer arrays.

struct packed_struct
{
  struct packed_struct1
  {
    unsigned char cc11;
    unsigned char cc12;
  } __attribute__ ((packed)) pst1;
  struct packed_struct2
  {
    unsigned char cc21;
    unsigned char cc22;
    unsigned short ss[104];
    unsigned char cc23[13];
  } __attribute__ ((packed)) pst2[4];
} __attribute__ ((packed));

typedef struct
{
  int ii;
  struct packed_struct buf;
} info_t;

int
foo (info_t * info)
{
  int i, j;

  for (i = 0; i < info->buf.pst1.cc11; i++)
    {
      for (j = 0; j < info->buf.pst2[i].cc22; j++)
        {
          dj1 (info->buf.pst2[i].ss[j]);
        }
    }

  return 0;
}


As a workaround, I had may_be_unaligned_p() return true if toffset is
set, but there's likely times when that results in suboptimal code.

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

end of thread, other threads:[~2010-04-13 21:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-10 11:02 may_be_unaligned_p bug? DJ Delorie
2010-04-10 13:03 ` Eric Botcazou
2010-04-11  2:28   ` Eric Botcazou
2010-04-12 21:08     ` DJ Delorie
2010-04-12 22:17       ` Eric Botcazou
2010-04-12 22:25         ` DJ Delorie
2010-04-13 22:15           ` Eric Botcazou

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