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

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
The reason for the legacy on x86 targets is indeed not present on
strict-alignment platforms if it is the case that on strict-alignment platforms
unaligned accesses trap (and are not merely slow).

Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c      (revision 235005)
+++ gcc/builtins.c      (working copy)
@@ -339,7 +339,8 @@ 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.  */
-      if (!addr_p && !known_alignment
+      if (!addr_p
+         && (!known_alignment || STRICT_ALIGNMENT)
          && TYPE_ALIGN (TREE_TYPE (exp)) > align)
        align = TYPE_ALIGN (TREE_TYPE (exp));
       else

Reply via email to