diff options
author | Richard Guenther <rguenther@suse.de> | 2006-03-17 17:38:51 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2006-03-17 17:38:51 +0000 |
commit | 445a6ba4c1bbfd362d30cb04f36b2baed793cb61 (patch) | |
tree | a8e9ab37adf91c6a9904b0ff2841525c952788e3 | |
parent | d550ef0bf6d072706ae7d03468ade5b7c267cb6b (diff) | |
download | gcc-445a6ba4c1bbfd362d30cb04f36b2baed793cb61.zip gcc-445a6ba4c1bbfd362d30cb04f36b2baed793cb61.tar.gz gcc-445a6ba4c1bbfd362d30cb04f36b2baed793cb61.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/builtins.c | 7 |
2 files changed, 13 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f844e61..67c4e20 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/builtins.c b/gcc/builtins.c index a628342..999d777 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -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); |