OSDN Git Service

2006-03-17 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 17 Mar 2006 17:38:51 +0000 (17:38 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 17 Mar 2006 17:38:51 +0000 (17:38 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@112177 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/builtins.c

index f844e61..67c4e20 100644 (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
index a628342..999d777 100644 (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);