This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
may_be_unaligned_p bug?
- From: DJ Delorie <dj at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 9 Apr 2010 22:47:56 -0400
- Subject: 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.