This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Does malloc tell us anything about alignment modulo k?
On Thu, Jul 15, 2004 at 07:35:10PM +0000, Joseph S. Myers wrote:
> As you say, this probably isn't particularly useful.
Alpha, pre-bwx instructions, can make use of this.
struct S
{
unsigned char x, y;
};
int foo()
{
struct S *s = malloc(sizeof (struct S));
fill(s);
return s->x + s->y;
}
The return line compiles to, with alignment 1,
ldq_u $2,0($9)
ldq_u $3,1($9)
lda $1,1($9)
extbl $2,$9,$2
ldq $9,8($30)
extbl $3,$1,$1
addl $2,$1,$0
with alignment 4,
ldl $2,0($9)
extbl $2,1,$1
and $2,0xff,$2
addl $2,$1,$0
That we can assume alignment 2 based on the object size of 2 isn't good
enough, since pre-bwx only has 4 and 8 byte load instructions.
r~