https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79256

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
So there's ADJUST_FIELD_ALIGN (x86_field_alignment) but the interface is not
usable from within get_object_alignment_2 at

      /* When EXP is an actual memory reference then we can use
         TYPE_ALIGN of a pointer indirection to derive alignment.
         Do so only if get_pointer_alignment_1 did not reveal absolute
         alignment knowledge and if using that alignment would
         improve the situation.  */
      if (!addr_p
          && TYPE_ALIGN (TREE_TYPE (exp)) > align)
        align = TYPE_ALIGN (TREE_TYPE (exp));

of course there's min_align_of_type () that just builds a FIELD_DECL for
this purpose (ugh).  But it would mean that the above needs to use
min_align_of_type ().  Ugh.

Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c      (revision 244974)
+++ gcc/builtins.c      (working copy)
@@ -334,9 +334,11 @@ get_object_alignment_2 (tree exp, unsign
         Do so only if get_pointer_alignment_1 did not reveal absolute
         alignment knowledge and if using that alignment would
         improve the situation.  */
+      unsigned int talign;
       if (!addr_p && !known_alignment
-         && TYPE_ALIGN (TREE_TYPE (exp)) > align)
-       align = TYPE_ALIGN (TREE_TYPE (exp));
+         && (talign = min_align_of_type (TREE_TYPE (exp)) * BITS_PER_UNIT)
+         && talign > align)
+       align = talign;
       else
        {
          /* Else adjust bitpos accordingly.  */

Reply via email to