This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

may_be_unaligned_p bug?


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]