re PR target/45212 (FAIL: gcc.target/alpha/pr24178.c scan-assembler ldl.*,18\\\\()

2010-08-09  Richard Guenther  <rguenther@suse.de>

	PR middle-end/45212
	* emit-rtl.c (set_mem_attributes_minus_bitpos): Adjust
	alignment from MEM_REF offset only if we took it from the
	base object.

	* gcc.target/i386/pr24178.c: New testcase.

From-SVN: r163029
This commit is contained in:
Richard Guenther 2010-08-09 11:43:23 +00:00 committed by Richard Biener
parent cee00e2290
commit 3e32c76185
4 changed files with 49 additions and 15 deletions

View file

@ -1,3 +1,10 @@
2010-08-09 Richard Guenther <rguenther@suse.de>
PR middle-end/45212
* emit-rtl.c (set_mem_attributes_minus_bitpos): Adjust
alignment from MEM_REF offset only if we took it from the
base object.
2010-08-09 Eric Fisher <joefoxreal@gmail.com>
* doc/sourcebuild.texi (vect_int_mult): Remove duplicate entry.

View file

@ -1587,29 +1587,31 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp,
else if (TREE_CODE (t) == MEM_REF)
{
tree op0 = TREE_OPERAND (t, 0);
unsigned HOST_WIDE_INT aoff = BITS_PER_UNIT;
if (host_integerp (TREE_OPERAND (t, 1), 1))
if (TREE_CODE (op0) == ADDR_EXPR
&& (DECL_P (TREE_OPERAND (op0, 0))
|| CONSTANT_CLASS_P (TREE_OPERAND (op0, 0))))
{
unsigned HOST_WIDE_INT ioff = TREE_INT_CST_LOW (TREE_OPERAND (t, 1));
aoff = (ioff & -ioff) * BITS_PER_UNIT;
}
if (TREE_CODE (op0) == ADDR_EXPR && DECL_P (TREE_OPERAND (op0, 0)))
align = MAX (align, DECL_ALIGN (TREE_OPERAND (op0, 0)));
else if (TREE_CODE (op0) == ADDR_EXPR
&& CONSTANT_CLASS_P (TREE_OPERAND (op0, 0)))
{
align = TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (op0, 0)));
if (DECL_P (TREE_OPERAND (op0, 0)))
align = DECL_ALIGN (TREE_OPERAND (op0, 0));
else if (CONSTANT_CLASS_P (TREE_OPERAND (op0, 0)))
{
align = TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (op0, 0)));
#ifdef CONSTANT_ALIGNMENT
align = CONSTANT_ALIGNMENT (TREE_OPERAND (op0, 0), align);
align = CONSTANT_ALIGNMENT (TREE_OPERAND (op0, 0), align);
#endif
}
if (TREE_INT_CST_LOW (TREE_OPERAND (t, 1)) != 0)
{
unsigned HOST_WIDE_INT ioff
= TREE_INT_CST_LOW (TREE_OPERAND (t, 1));
unsigned HOST_WIDE_INT aoff = (ioff & -ioff) * BITS_PER_UNIT;
align = MIN (aoff, align);
}
}
else
/* ??? This isn't fully correct, we can't set the alignment from the
type in all cases. */
align = MAX (align, TYPE_ALIGN (type));
if (!integer_zerop (TREE_OPERAND (t, 1)) && aoff < align)
align = aoff;
}
else if (TREE_CODE (t) == MISALIGNED_INDIRECT_REF)

View file

@ -1,3 +1,12 @@
2010-08-09 Richard Guenther <rguenther@suse.de>
PR middle-end/45212
* emit-rtl.c (set_mem_attributes_minus_bitpos): Adjust
alignment from MEM_REF offset only if we took it from the
base object.
* gcc.target/i386/pr24178.c: New testcase.
2010-08-08 Uros Bizjak <ubizjak@gmail.com>
* gcc.dg/20030107-1.c: Do not call cleanup-coverage-files.

View file

@ -0,0 +1,16 @@
/* { dg-do compile } */
/* { dg-options "-O -fdump-rtl-expand" } */
struct S {
int l;
unsigned char c;
};
unsigned long f(unsigned char *p10) {
struct S *p = (struct S *) (p10 + 10);
return p->c;
}
/* The p->c memory access should have alignment of 4 bytes. */
/* { dg-final { scan-rtl-dump "MEM\[^\\n\]*A32" "expand" } } */
/* { dg-final { cleanup-rtl-dump "expand" } } */