re PR target/26721 (Gcc generates unaligned access)

2006-03-17  Richard Guenther  <rguenther@suse.de>

	PR middle-end/26721
	* builtins.c (get_pointer_alignment): For component style references
	adjust alignment to the component type alignment.  Make sure
	to adjust alignment for component access of constants.

From-SVN: r112177
This commit is contained in:
Richard Guenther 2006-03-17 17:38:51 +00:00 committed by Richard Biener
parent d550ef0bf6
commit 445a6ba4c1
2 changed files with 13 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2006-03-17 Richard Guenther <rguenther@suse.de>
PR middle-end/26721
* builtins.c (get_pointer_alignment): For component style references
adjust alignment to the component type alignment. Make sure
to adjust alignment for component access of constants.
2006-03-17 David Edelsohn <edelsohn@gnu.org>
* config/rs6000/rs6000.md (strlensi): Emit barrier after

View File

@ -278,8 +278,13 @@ get_pointer_alignment (tree exp, unsigned int max_align)
inner = max_align;
while (handled_component_p (exp))
{
/* Fields in a structure can be packed, honour DECL_ALIGN
of the FIELD_DECL. For all other references the conservative
alignment is the element type alignment. */
if (TREE_CODE (exp) == COMPONENT_REF)
inner = MIN (inner, DECL_ALIGN (TREE_OPERAND (exp, 1)));
else
inner = MIN (inner, TYPE_ALIGN (TREE_TYPE (exp)));
exp = TREE_OPERAND (exp, 0);
}
if (TREE_CODE (exp) == FUNCTION_DECL)
@ -288,7 +293,7 @@ get_pointer_alignment (tree exp, unsigned int max_align)
align = MIN (inner, DECL_ALIGN (exp));
#ifdef CONSTANT_ALIGNMENT
else if (CONSTANT_CLASS_P (exp))
align = CONSTANT_ALIGNMENT (exp, align);
align = MIN (inner, (unsigned)CONSTANT_ALIGNMENT (exp, align));
#endif
else
align = MIN (align, inner);