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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
In patch form what I wrote above (completely untested):
--- gcc/config/aarch64/aarch64.cc.jj    2023-04-14 09:15:08.470312336 +0200
+++ gcc/config/aarch64/aarch64.cc       2023-04-14 12:08:59.785137542 +0200
@@ -7459,6 +7459,8 @@ aarch64_vfp_is_call_candidate (cumulativ
                                                  nregs, NULL, pcum->silent_p);
 }

+static HOST_WIDE_INT aarch64_simd_vector_alignment (const_tree);
+
 /* Given MODE and TYPE of a function argument, return the alignment in
    bits.  The idea is to suppress any stronger alignment requested by
    the user and opt for the natural alignment (specified in AAPCS64 \S
@@ -7487,16 +7489,16 @@ aarch64_function_arg_alignment (machine_
     {
       /* The ABI alignment is the natural alignment of the type, without
         any attributes applied.  Normally this is the alignment of the
-        TYPE_MAIN_VARIANT, but not always; see PR108910 for a counterexample.
-        For now we just handle the known exceptions explicitly.  */
+        TYPE_MAIN_VARIANT, but not always; see PR108910 for a
+        counterexample.  */
+      unsigned int ret;
       type = TYPE_MAIN_VARIANT (type);
-      if (POINTER_TYPE_P (type))
-       {
-         gcc_assert (known_eq (POINTER_SIZE, GET_MODE_BITSIZE (mode)));
-         return POINTER_SIZE;
-       }
-      gcc_assert (!TYPE_USER_ALIGN (type));
-      return TYPE_ALIGN (type);
+      if (VECTOR_TYPE_P (type))
+       ret = aarch64_simd_vector_alignment (type);
+      else
+       ret = GET_MODE_ALIGNMENT (TYPE_MODE (type));
+      gcc_assert (TYPE_USER_ALIGN (type) || ret == TYPE_ALIGN (type));
+      return ret;
     }

   if (TREE_CODE (type) == ARRAY_TYPE)

Reply via email to